module varargs;

extern fn void printf(char* c, ...);

fn void test()
{
  printf("%d\n", true);
  printf("%d\n", 123);
  printf("%f\n", 12.3);
  ichar x1 = -123;
  bool b = false;
  float z1 = 12.3;
  printf("%d\n", b);
  printf("%d\n", x1);
  printf("%f\n", z1);
}

/* #expect: varargs.ll

define void @varargs.test() #0 {
entry:
  %x1 = alloca i8, align 1
  %b = alloca i8, align 1
  %z1 = alloca float, align 4
  call void (ptr, ...) @printf(ptr @.str, i32 1)
  call void (ptr, ...) @printf(ptr @.str.1, i32 123)
  call void (ptr, ...) @printf(ptr @.str.2, double 1.230000e+01)
  store i8 -123, ptr %x1, align 1
  store i8 0, ptr %b, align 1
  store float 0x40289999A0000000, ptr %z1, align 4
  %0 = load i8, ptr %b, align 1
  %1 = trunc i8 %0 to i1
  %zext = zext i1 %1 to i32
  call void (ptr, ...) @printf(ptr @.str.3, i32 %zext)
  %2 = load i8, ptr %x1, align 1
  %sext = sext i8 %2 to i32
  call void (ptr, ...) @printf(ptr @.str.4, i32 %sext)
  %3 = load float, ptr %z1, align 4
  %fpfpext = fpext float %3 to double
  call void (ptr, ...) @printf(ptr @.str.5, double %fpfpext)
  ret void
}
