int main(argc, argv)
int argc;
char *argv[];
{
  char name1[80], name2[80];
  float k_diffuse, k_specular, eta, L[3];
  long length, width;
  short **the_image;
  short **out_image;
  if (argc != 9) {
    show_mainl_usage();
    exit(0);
  }
  strcpy(name1, argv[1]);
  strcpy(name2, argv[2]);
  k_diffuse = atof(argv[3]);
  k_specular = atof(argv[4]);
  eta = atof(argv[5]);
  L[0] = atof(argv[6]);
  L[1] = atof(argv[7]);
  L[2] = atof(argv[8]);
  if (does_not_exist(name1)) {
    printf("\nERROR input file %s does not exist", name1);
    exit(0);
  }
  get_image_size(name1, &length, &width);
  the_image = allocate_image_array(length, width);
  out_image = allocate_image_array(length, width);
  create_image_file(name1, name2);
  read_image_array(name1, the_image);
  lambert(the_image, out_image, k_diffuse, k_specular, eta, L, length, width);
  write_image_array(name2, out_image);
  free_image_array(out_image, length);
  free_image_array(the_image, length);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x9,-0x4(%rbp)
je     11fa <main+0x2a>
mov    $0x0,%al
call   10a0 <show_mainl_usage@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xb4(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xb8(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xbc(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc8(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc4(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x40(%rax),%rdi
mov    $0x0,%al
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc0(%rbp)
ff
lea    -0x60(%rbp),%rdi
mov    $0x0,%al
call   1090 <does_not_exist@plt>
cmp    $0x0,%eax
je     12ee <main+0x11e>
lea    -0x60(%rbp),%rsi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x60(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0xd8(%rbp),%rdx
mov    $0x0,%al
call   1080 <get_image_size@plt>
mov    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    $0x0,%al
call   10e0 <allocate_image_array@plt>
cltq
mov    %rax,-0xe0(%rbp)
mov    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    $0x0,%al
call   10e0 <allocate_image_array@plt>
cltq
mov    %rax,-0xe8(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x0,%al
call   1030 <create_image_file@plt>
lea    -0x60(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    $0x0,%al
call   10c0 <read_image_array@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0xb8(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0xbc(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    -0xc8(%rbp),%rdx
mov    -0xd0(%rbp),%rcx
mov    -0xd8(%rbp),%r8
mov    $0x3,%al
call   10b0 <lambert@plt>
lea    -0xb0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
mov    $0x0,%al
call   1070 <write_image_array@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    $0x0,%al
call   10f0 <free_image_array@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    $0x0,%al
call   10f0 <free_image_array@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
cmp    $0x9,%edi
jne    1390 <main+0x1c0>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0x80(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x18(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
mov    %eax,%r15d
mov    0x20(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
mov    %eax,%r12d
mov    0x28(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
mov    %eax,%ebp
mov    0x30(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x24(%rsp)
mov    0x38(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x28(%rsp)
mov    0x40(%rbx),%rdi
xor    %eax,%eax
call   1050 <atof@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x2c(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <does_not_exist@plt>
test   %eax,%eax
jne    139e <main+0x1ce>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r12d,%xmm0
movss  %xmm0,0x1c(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
movss  %xmm0,0x18(%rsp)
lea    0x30(%rsp),%r14
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <get_image_size@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   10e0 <allocate_image_array@plt>
movslq %eax,%rbx
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   10e0 <allocate_image_array@plt>
movslq %eax,%rbp
lea    0x80(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <create_image_file@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10c0 <read_image_array@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x20(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
lea    0x24(%rsp),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%al
call   10b0 <lambert@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <write_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   10f0 <free_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <free_image_array@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10a0 <show_mainl_usage@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xc5b(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"\0AERROR input file %s does not exist\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca [3 x float]
%11 = alloca i64
%12 = alloca i64
%13 = alloca i16**
%14 = alloca i16**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 9
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (...) @show_mainl_usage()
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%21 = load i8**, i8*** %4
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i8* @strcpy(i8* %20, i8* %23)
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i8* @strcpy(i8* %25, i8* %28)
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %32)
%34 = sitofp i32 %33 to float
store float %34, float* %7
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %37)
%39 = sitofp i32 %38 to float
store float %39, float* %8
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 5
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %42)
%44 = sitofp i32 %43 to float
store float %44, float* %9
%45 = load i8**, i8*** %4
%46 = getelementptr inbounds i8*, i8** %45, i64 6
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %47)
%49 = sitofp i32 %48 to float
%50 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
store float %49, float* %50
%51 = load i8**, i8*** %4
%52 = getelementptr inbounds i8*, i8** %51, i64 7
%53 = load i8*, i8** %52
%54 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %53)
%55 = sitofp i32 %54 to float
%56 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
store float %55, float* %56
%57 = load i8**, i8*** %4
%58 = getelementptr inbounds i8*, i8** %57, i64 8
%59 = load i8*, i8** %58
%60 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %59)
%61 = sitofp i32 %60 to float
%62 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
store float %61, float* %62
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%64 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %19
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %67)
unreachable
69: ; preds = %19
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%71 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %70, i64* %11, i64* %12)
%72 = load i64, i64* %11
%73 = load i64, i64* %12
%74 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %72, i64 %73)
%75 = sext i32 %74 to i64
%76 = inttoptr i64 %75 to i16**
store i16** %76, i16*** %13
%77 = load i64, i64* %11
%78 = load i64, i64* %12
%79 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %77, i64 %78)
%80 = sext i32 %79 to i64
%81 = inttoptr i64 %80 to i16**
store i16** %81, i16*** %14
%82 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%84 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %82, i8* %83)
%85 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%86 = load i16**, i16*** %13
%87 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %85, i16** %86)
%88 = load i16**, i16*** %13
%89 = load i16**, i16*** %14
%90 = load float, float* %7
%91 = fpext float %90 to double
%92 = load float, float* %8
%93 = fpext float %92 to double
%94 = load float, float* %9
%95 = fpext float %94 to double
%96 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%97 = load i64, i64* %11
%98 = load i64, i64* %12
%99 = call i32 (i16**, i16**, double, double, double, float*, i64, i64, ...) bitcast (i32 (...)* @lambert to i32 (i16**, i16**, double, double, double, float*, i64, i64, ...)*)(i16** %88, i16** %89, double %91, double %93, double %95, float* %96, i64 %97, i64 %98)
%100 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%101 = load i16**, i16*** %14
%102 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %100, i16** %101)
%103 = load i16**, i16*** %14
%104 = load i64, i64* %11
%105 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %103, i64 %104)
%106 = load i16**, i16*** %13
%107 = load i64, i64* %11
%108 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %106, i64 %107)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0AERROR input file %s does not exist\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [3 x float]
%6 = alloca i64
%7 = alloca i64
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = bitcast [3 x float]* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = icmp eq i32 %0, 9
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = tail call i32 (...) @show_mainl_usage()
tail call void @exit(i32 0)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i8* @strcpy(i8* %8, i8* dereferenceable(1) %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = call i8* @strcpy(i8* %9, i8* dereferenceable(1) %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 4
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %27)
%29 = getelementptr inbounds i8*, i8** %1, i64 5
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %30)
%32 = getelementptr inbounds i8*, i8** %1, i64 6
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %33)
%35 = sitofp i32 %34 to float
%36 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %35, float* %36
%37 = getelementptr inbounds i8*, i8** %1, i64 7
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %38)
%40 = sitofp i32 %39 to float
%41 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %40, float* %41
%42 = getelementptr inbounds i8*, i8** %1, i64 8
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) bitcast (i32 (...)* @atof to i32 (i8*, ...)*)(i8* %43)
%45 = sitofp i32 %44 to float
%46 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %45, float* %46
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %8)
%48 = icmp eq i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %16
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %8)
unreachable
51: ; preds = %16
%52 = sitofp i32 %31 to float
%53 = sitofp i32 %28 to float
%54 = sitofp i32 %25 to float
%55 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %8, i64* %6, i64* %7)
%56 = load i64, i64* %6
%57 = load i64, i64* %7
%58 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %56, i64 %57)
%59 = sext i32 %58 to i64
%60 = inttoptr i64 %59 to i16**
%61 = load i64, i64* %6
%62 = load i64, i64* %7
%63 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %61, i64 %62)
%64 = sext i32 %63 to i64
%65 = inttoptr i64 %64 to i16**
%66 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %8, i8* %9)
%67 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %8, i16** %60)
%68 = fpext float %54 to double
%69 = fpext float %53 to double
%70 = fpext float %52 to double
%71 = load i64, i64* %6
%72 = load i64, i64* %7
%73 = call i32 (i16**, i16**, double, double, double, float*, i64, i64, ...) bitcast (i32 (...)* @lambert to i32 (i16**, i16**, double, double, double, float*, i64, i64, ...)*)(i16** %60, i16** %65, double %68, double %69, double %70, float* %36, i64 %71, i64 %72)
%74 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %9, i16** %65)
%75 = load i64, i64* %6
%76 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %65, i64 %75)
%77 = load i64, i64* %6
%78 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %60, i64 %77)
ret i32 0
}