// #target: macos-x64
module test;

fn int foo1()
{
  char *pp @noinit;
  uint w_cnt @noinit;

  w_cnt += *pp;

  return (int)(w_cnt);
}

extern fn void test2(int, double, float);

fn void foo2(int x)
{
    test2(x, x ? 1.0 : 12.5, 1.0);
}

fn int trys(ichar* s, int x)
{
    int asa @noinit;
    double val @noinit;
    int lls @noinit;
    if (x)
    {
        asa = lls + asa;
    }
    else
    {
    }
    return asa + (int)(val);
}

struct InternalFPF
{
    char type;
}

fn void setInternalFPFZero(InternalFPF* dest) @noinline
{
    dest.type = 0;
}

fn void denormalize(InternalFPF* ptr)
{
    setInternalFPFZero(ptr);
}


/* #expect: test.ll


define i32 @test.foo1() #0 {
entry:
  %pp = alloca ptr, align 8
  %w_cnt = alloca i32, align 4
  %0 = load i32, ptr %w_cnt, align 4
  %1 = load ptr, ptr %pp, align 8
  %2 = load i8, ptr %1, align 1
  %zext = zext i8 %2 to i32
  %add = add i32 %0, %zext
  store i32 %add, ptr %w_cnt, align 4
  %3 = load i32, ptr %w_cnt, align 4
  ret i32 %3
}

; Function Attrs:
define void @test.foo2(i32 %0) #0 {
entry:
  %i2b = icmp ne i32 %0, 0
  %ternary = select i1 %i2b, double 1.000000e+00, double 1.250000e+01
  call void @test2(i32 %0, double %ternary, float 1.000000e+00)
  ret void
}

; Function Attrs:
define i32 @test.trys(ptr %0, i32 %1) #0 {
entry:
  %asa = alloca i32, align 4
  %val = alloca double, align 8
  %lls = alloca i32, align 4
  %i2b = icmp ne i32 %1, 0
  br i1 %i2b, label %if.then, label %if.exit

if.then:                                          ; preds = %entry
  %2 = load i32, ptr %lls, align 4
  %3 = load i32, ptr %asa, align 4
  %add = add i32 %2, %3
  store i32 %add, ptr %asa, align 4
  br label %if.exit

if.exit:                                          ; preds = %if.then, %entry
  %4 = load i32, ptr %asa, align 4
  %5 = load double, ptr %val, align 8
  %fpsi = fptosi double %5 to i32
  %add1 = add i32 %4, %fpsi
  ret i32 %add1
}

define void @test.setInternalFPFZero(ptr %0) #1 {
entry:
  store i8 0, ptr %0, align 1
  ret void
}

; Function Attrs:
define void @test.denormalize(ptr %0) #0 {
entry:
  call void @test.setInternalFPFZero(ptr %0)
  ret void
}
