// #target: macos-x64
module test;
import std::io;

faultdef HELLO, WORLD;
fn void main()
{
	fault x = WORLD;
	io::printf("%s %s\n", HELLO.nameof, x.nameof);
}

/* #expect: test.ll

define void @test.main() #0 {
entry:
  %x = alloca i64, align 8
  %varargslots = alloca [2 x %any], align 16
  %taddr = alloca %"char[]", align 8
  %faultname_zero = alloca %"char[]", align 8
  %retparam = alloca i64, align 8
  store i64 ptrtoint (ptr @test.WORLD to i64), ptr %x, align 8
  store %"char[]" { ptr @.str.1, i64 5 }, ptr %taddr, align 8
  %0 = insertvalue %any undef, ptr %taddr, 0
  %1 = insertvalue %any %0, i64 ptrtoint (ptr @"$ct.String" to i64), 1
  store %any %1, ptr %varargslots, align 16
  %2 = load i64, ptr %x, align 8
  %eq = icmp eq i64 %2, 0
  br i1 %eq, label %faultname_no, label %faultname_ok

faultname_no:                                     ; preds = %entry
  call void @llvm.memset.p0.i64(ptr align 8 %faultname_zero, i8 0, i64 16, i1 false)
  br label %faultname_exit

faultname_ok:                                     ; preds = %entry
  %3 = inttoptr i64 %2 to ptr
  br label %faultname_exit

faultname_exit:                                   ; preds = %faultname_ok, %faultname_no
  %faultname.phi = phi ptr [ %faultname_zero, %faultname_no ], [ %3, %faultname_ok ]
  %4 = insertvalue %any undef, ptr %faultname.phi, 0
  %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.String" to i64), 1
  %ptradd = getelementptr inbounds i8, ptr %varargslots, i64 16
  store %any %5, ptr %ptradd, align 16
  %6 = call i64 @std.io.printf(ptr %retparam, ptr @.str, i64 6, ptr %varargslots, i64 2)
  ret void
}

; Function Attrs:
define i32 @main(i32 %0, ptr %1) #0 {
entry:
  call void @test.main()
  ret i32 0
}

