int main(int argc, char **argv) {
  int imgdim[3] = {64, 80, 32};
  float voxdim[3] = {1., 2., 3.};
  float f0 = 0.02, crit = 0.3;
  float *imgt;
  int *mask;
  int vdim;
  char program[256];
  setprog(program, argv);
  vdim = imgdim[0] * imgdim[1] * imgdim[2];
  if (!(imgt = (float *)calloc(vdim, sizeof(float))))
    errm(program);
  if (!(mask = (int *)calloc(vdim, sizeof(int))))
    errm(program);
  printf("before img2lmask\n");
  img2lmask(imgdim + 0, imgdim + 1, imgdim + 2, imgt, mask, voxdim, &f0, &crit);
  printf("after  img2lmask\n");
  free(imgt);
  free(mask);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe78(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xe76(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe6e(%rip),%eax
mov    %eax,-0x20(%rbp)
movss  0xe4b(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xe3a(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1090 <setprog@plt>
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rdi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1215 <main+0xa5>
lea    -0x150(%rbp),%rdi
mov    $0x0,%al
call   1050 <errm@plt>
movslq -0x44(%rbp),%rdi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    123f <main+0xcf>
lea    -0x150(%rbp),%rdi
mov    $0x0,%al
call   1050 <errm@plt>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
add    $0x4,%rsi
lea    -0x1c(%rbp),%rdx
add    $0x8,%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
lea    -0x28(%rbp),%r9
lea    -0x2c(%rbp),%r10
lea    -0x30(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1070 <img2lmask@plt>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    0xe84(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xe71(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0xe7a(%rip),%eax
mov    %eax,0x28(%rsp)
mov    0xe67(%rip),%rax
mov    %rax,0x20(%rsp)
movl   $0x3ca3d70a,0xc(%rsp)
3c
movl   $0x3e99999a,0x8(%rsp)
3e
lea    0x30(%rsp),%rdi
xor    %eax,%eax
call   1090 <setprog@plt>
mov    $0x28000,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11e9 <main+0x79>
lea    0x30(%rsp),%rdi
xor    %eax,%eax
call   1050 <errm@plt>
mov    $0x28000,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    120c <main+0x9c>
lea    0x30(%rsp),%rdi
xor    %eax,%eax
call   1050 <errm@plt>
lea    0x18(%rsp),%r15
lea    0x14(%rsp),%r12
lea    0xdfb(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%r10
lea    0xc(%rsp),%r11
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%r9
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
push   %r10
push   %r11
call   1070 <img2lmask@plt>
add    $0x10,%rsp
lea    0xdd1(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@__const.main.imgdim = [3 x i32] [i32 64, i32 80, i32 32]
@__const.main.voxdim = [3 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00]
@.str = [18 x i8] c"before img2lmask\0A\00"
@.str.1 = [18 x i8] c"after img2lmask\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca [3 x float]
%8 = alloca float
%9 = alloca float
%10 = alloca float*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [3 x i32]* %6 to i8*
%15 = bitcast [3 x float]* %7 to i8*
store float 0x3F947AE140000000, float* %8
store float 0x3FD3333340000000, float* %9
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @setprog to i32 (i8*, i8**, ...)*)(i8* %16, i8** %17)
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
%22 = load i32, i32* %21
%23 = mul nsw i32 %20, %22
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
%25 = load i32, i32* %24
%26 = mul nsw i32 %23, %25
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = sext i32 %27 to i64
%29 = call i8* @calloc(i64 %28, i64 4)
%30 = bitcast i8* %29 to float*
store float* %30, float** %10
%31 = icmp ne float* %30, null
br i1 %31, label %35, label %32
32: ; preds = %2
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%34 = call i32 (i8*, ...) bitcast (i32 (...)* @errm to i32 (i8*, ...)*)(i8* %33)
br label %35
35: ; preds = %32, %2
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = call i8* @calloc(i64 %37, i64 4)
%39 = bitcast i8* %38 to i32*
store i32* %39, i32** %11
%40 = icmp ne i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %35
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @errm to i32 (i8*, ...)*)(i8* %42)
br label %44
44: ; preds = %41, %35
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%47 = getelementptr inbounds i32, i32* %46, i64 0
%48 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%49 = getelementptr inbounds i32, i32* %48, i64 1
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%51 = getelementptr inbounds i32, i32* %50, i64 2
%52 = load float*, float** %10
%53 = load i32*, i32** %11
%54 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%55 = call i32 (i32*, i32*, i32*, float*, i32*, float*, float*, float*, ...) bitcast (i32 (...)* @img2lmask to i32 (i32*, i32*, i32*, float*, i32*, float*, float*, float*, ...)*)(i32* %47, i32* %49, i32* %51, float* %52, i32* %53, float* %54, float* %8, float* %9)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%57 = load float*, float** %10
%58 = bitcast float* %57 to i8*
%59 = load i32*, i32** %11
%60 = bitcast i32* %59 to i8*
unreachable
}

LLVM IR (-O2):
@__const.main.imgdim = [3 x i32] [i32 64, i32 80, i32 32]
@__const.main.voxdim = [3 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00]
@str = [17 x i8] c"before img2lmask\00"
@str.2 = [17 x i8] c"after img2lmask\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [3 x i32]
%4 = alloca [3 x float]
%5 = alloca float
%6 = alloca float
%7 = alloca [256 x i8]
%8 = bitcast [3 x i32]* %3 to i8*
%9 = bitcast [3 x float]* %4 to i8*
%10 = bitcast float* %5 to i8*
store float 0x3F947AE140000000, float* %5
%11 = bitcast float* %6 to i8*
store float 0x3FD3333340000000, float* %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @setprog to i32 (i8*, i8**, ...)*)(i8* %12, i8** %1)
%14 = call dereferenceable_or_null(655360) i8* @calloc(i64 163840, i64 4)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @errm to i32 (i8*, ...)*)(i8* %12)
br label %18
18: ; preds = %16, %2
%19 = call dereferenceable_or_null(655360) i8* @calloc(i64 163840, i64 4)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @errm to i32 (i8*, ...)*)(i8* %12)
br label %23
23: ; preds = %21, %18
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%27 = bitcast i8* %19 to i32*
%28 = bitcast i8* %14 to float*
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%30 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%31 = call i32 (i32*, i32*, i32*, float*, i32*, float*, float*, float*, ...) bitcast (i32 (...)* @img2lmask to i32 (i32*, i32*, i32*, float*, i32*, float*, float*, float*, ...)*)(i32* %26, i32* %25, i32* %24, float* %28, i32* %27, float* %30, float* %5, float* %6)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
unreachable
}