// #target: macos-x64
module qnametest;

extern fn int printf(char *, ...);
int x;

struct Blob { int z; int f; }

fn void main()
{
    int help;
    printf("printf: %s\n", $nameof(printf));
    printf("printfq: %s\n", $qnameof(printf));
    printf("Blobq: %s\n", Blob.qnameof);
    printf("Blob: %s\n", Blob.nameof);
    printf("xq: %s\n", $qnameof(x));
    printf("x: %s\n", $nameof(x));
    printf("helpq: %s\n", $qnameof(help));
    printf("mainq: %s\n", $qnameof(main));
    printf("Blob**[3]: %s\n", Blob**[3].nameof);
}

/* #expect: qnametest.ll

@"$ct.qnametest.Blob" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@qnametest.x = local_unnamed_addr global i32 0, align 4
@.str = private unnamed_addr constant [12 x i8] c"printf: %s\0A\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"printf\00", align 1
@.str.2 = private unnamed_addr constant [13 x i8] c"printfq: %s\0A\00", align 1
@.str.3 = private unnamed_addr constant [18 x i8] c"qnametest::printf\00", align 1
@.str.4 = private unnamed_addr constant [11 x i8] c"Blobq: %s\0A\00", align 1
@.str.5 = private unnamed_addr constant [16 x i8] c"qnametest::Blob\00", align 1
@.str.6 = private unnamed_addr constant [10 x i8] c"Blob: %s\0A\00", align 1
@.str.7 = private unnamed_addr constant [5 x i8] c"Blob\00", align 1
@.str.8 = private unnamed_addr constant [8 x i8] c"xq: %s\0A\00", align 1
@.str.9 = private unnamed_addr constant [13 x i8] c"qnametest::x\00", align 1
@.str.10 = private unnamed_addr constant [7 x i8] c"x: %s\0A\00", align 1
@.str.11 = private unnamed_addr constant [2 x i8] c"x\00", align 1
@.str.12 = private unnamed_addr constant [11 x i8] c"helpq: %s\0A\00", align 1
@.str.13 = private unnamed_addr constant [5 x i8] c"help\00", align 1
@.str.14 = private unnamed_addr constant [11 x i8] c"mainq: %s\0A\00", align 1
@.str.15 = private unnamed_addr constant [16 x i8] c"qnametest::main\00", align 1
@.str.16 = private unnamed_addr constant [15 x i8] c"Blob**[3]: %s\0A\00", align 1
@.str.17 = private unnamed_addr constant [10 x i8] c"Blob**[3]\00", align 1

define void @qnametest.main() #0 {
entry:
  %help = alloca i32, align 4
  store i32 0, ptr %help, align 4
  %0 = call i32 (ptr, ...) @printf(ptr @.str, ptr @.str.1)
  %1 = call i32 (ptr, ...) @printf(ptr @.str.2, ptr @.str.3)
  %2 = call i32 (ptr, ...) @printf(ptr @.str.4, ptr @.str.5)
  %3 = call i32 (ptr, ...) @printf(ptr @.str.6, ptr @.str.7)
  %4 = call i32 (ptr, ...) @printf(ptr @.str.8, ptr @.str.9)
  %5 = call i32 (ptr, ...) @printf(ptr @.str.10, ptr @.str.11)
  %6 = call i32 (ptr, ...) @printf(ptr @.str.12, ptr @.str.13)
  %7 = call i32 (ptr, ...) @printf(ptr @.str.14, ptr @.str.15)
  %8 = call i32 (ptr, ...) @printf(ptr @.str.16, ptr @.str.17)
  ret void
}
