int main(argc, argv)
int argc;
char *argv[];
{
  char name1[80], name2[80], name3[80];
  long bits_per_pixel, length, width;
  short **image1, **image2;
  short max;
  if (argc != 5) {
    printf("\n"
           "\n usage: mainas in1-file in2-file "
           "out_file add-subtract"
           "\n"
           "\n   recall add-subtract a=add s=subtract\n");
    exit(0);
  }
  strcpy(name1, argv[1]);
  strcpy(name2, argv[2]);
  strcpy(name3, argv[3]);
  if (does_not_exist(name1)) {
    printf("\nERROR input file %s does not exist", name1);
    exit(0);
  }
  if (does_not_exist(name2)) {
    printf("\nERROR input file %s does not exist", name2);
    exit(0);
  }
  if (are_not_same_size(name1, name2)) {
    printf("\nERROR Image files %s and %s are not same size", name1, name2);
    exit(0);
  }
  get_image_size(name1, &length, &width);
  get_bitsperpixel(name1, &bits_per_pixel);
  image1 = allocate_image_array(length, width);
  image2 = allocate_image_array(length, width);
  create_image_file(name1, name3);
  read_image_array(name1, image1);
  read_image_array(name2, image2);
  if (argv[4][0] == 'a' || argv[4][0] == 'A') {
    if (bits_per_pixel == 4)
      max = 16;
    else
      max = 255;
    add_image_array(image1, image2, length, width, max);
  }
  if (argv[4][0] == 's' || argv[4][0] == 'S')
    subtract_image_array(image1, image2, length, width);
  write_image_array(name3, image2);
  free_image_array(image1, length);
  free_image_array(image2, length);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1218 <main+0x38>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@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>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x60(%rbp),%rdi
mov    $0x0,%al
call   10a0 <does_not_exist@plt>
cmp    $0x0,%eax
je     127e <main+0x9e>
lea    -0x60(%rbp),%rsi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x0,%al
call   10a0 <does_not_exist@plt>
cmp    $0x0,%eax
je     12b1 <main+0xd1>
lea    -0xb0(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x0,%al
call   10c0 <are_not_same_size@plt>
cmp    $0x0,%eax
je     12ec <main+0x10c>
lea    -0x60(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x60(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x118(%rbp),%rdx
mov    $0x0,%al
call   1080 <get_image_size@plt>
lea    -0x60(%rbp),%rdi
lea    -0x108(%rbp),%rsi
mov    $0x0,%al
call   10e0 <get_bitsperpixel@plt>
mov    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rsi
mov    $0x0,%al
call   10f0 <allocate_image_array@plt>
cltq
mov    %rax,-0x120(%rbp)
mov    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rsi
mov    $0x0,%al
call   10f0 <allocate_image_array@plt>
cltq
mov    %rax,-0x128(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x100(%rbp),%rsi
mov    $0x0,%al
call   1030 <create_image_file@plt>
lea    -0x60(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x0,%al
call   10b0 <read_image_array@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   10b0 <read_image_array@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
je     13b4 <main+0x1d4>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jne    1404 <main+0x224>
cmpq   $0x4,-0x108(%rbp)
04
jne    13d0 <main+0x1f0>
movw   $0x10,-0x12a(%rbp)
jmp    13d9 <main+0x1f9>
movw   $0xff,-0x12a(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    -0x110(%rbp),%rdx
mov    -0x118(%rbp),%rcx
movswl -0x12a(%rbp),%r8d
ff
mov    $0x0,%al
call   1090 <add_image_array@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
je     142c <main+0x24c>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
jne    144f <main+0x26f>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    -0x110(%rbp),%rdx
mov    -0x118(%rbp),%rcx
mov    $0x0,%al
call   1060 <subtract_image_array@plt>
lea    -0x100(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   1070 <write_image_array@plt>
mov    -0x120(%rbp),%rdi
mov    -0x110(%rbp),%rsi
mov    $0x0,%al
call   1100 <free_image_array@plt>
mov    -0x128(%rbp),%rdi
mov    -0x110(%rbp),%rsi
mov    $0x0,%al
call   1100 <free_image_array@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x5,%edi
jne    1397 <main+0x1a7>
mov    %rsi,%r14
mov    0x8(%rsi),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    0x10(%r14),%rsi
lea    0x20(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x18(%r14),%rsi
lea    0xc0(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <does_not_exist@plt>
test   %eax,%eax
jne    13aa <main+0x1ba>
lea    0x20(%rsp),%rdi
xor    %eax,%eax
call   10b0 <does_not_exist@plt>
test   %eax,%eax
jne    13b8 <main+0x1c8>
lea    0x70(%rsp),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   10d0 <are_not_same_size@plt>
test   %eax,%eax
jne    13d2 <main+0x1e2>
lea    0x70(%rsp),%r12
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <get_image_size@plt>
lea    0x18(%rsp),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   10f0 <get_bitsperpixel@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1100 <allocate_image_array@plt>
movslq %eax,%r15
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1100 <allocate_image_array@plt>
movslq %eax,%rbx
lea    0xc0(%rsp),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <create_image_file@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10c0 <read_image_array@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10c0 <read_image_array@plt>
mov    0x20(%r14),%rax
mov    (%rax),%al
mov    %eax,%ecx
or     $0x20,%cl
cmp    $0x61,%cl
jne    1339 <main+0x149>
cmpq   $0x4,0x18(%rsp)
mov    $0x10,%eax
mov    $0xff,%r8d
cmove  %eax,%r8d
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <add_image_array@plt>
mov    0x20(%r14),%rax
mov    (%rax),%al
or     $0x20,%al
cmp    $0x73,%al
jne    1356 <main+0x166>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <subtract_image_array@plt>
lea    0xc0(%rsp),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <write_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1110 <free_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1110 <free_image_array@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xcb5(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xc4f(%rip),%rdi
lea    0x70(%rsp),%rsi
jmp    13c4 <main+0x1d4>
lea    0xc41(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xc4b(%rip),%rdi
lea    0x70(%rsp),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [99 x i8] c"\0A\0A usage: mainas in1-file in2-file out_file add-subtract\0A\0A recall add-subtract a=add s=subtract\0A\00"
@.str.1 = [36 x i8] c"\0AERROR input file %s does not exist\00"
@.str.2 = [47 x i8] c"\0AERROR Image files %s and %s are not same size\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i16**
%13 = alloca i16**
%14 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str, i64 0, i64 0))
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%21 = load i8**, i8*** %5
%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]* %7, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i8* @strcpy(i8* %25, i8* %28)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i8* @strcpy(i8* %30, i8* %33)
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%36 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %19
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %39)
unreachable
41: ; preds = %19
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %46)
unreachable
48: ; preds = %41
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%51 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @are_not_same_size to i32 (i8*, i8*, ...)*)(i8* %49, i8* %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* %55)
unreachable
57: ; preds = %48
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%59 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %58, i64* %10, i64* %11)
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%61 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @get_bitsperpixel to i32 (i8*, i64*, ...)*)(i8* %60, i64* %9)
%62 = load i64, i64* %10
%63 = load i64, i64* %11
%64 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %62, i64 %63)
%65 = sext i32 %64 to i64
%66 = inttoptr i64 %65 to i16**
store i16** %66, i16*** %12
%67 = load i64, i64* %10
%68 = load i64, i64* %11
%69 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %67, i64 %68)
%70 = sext i32 %69 to i64
%71 = inttoptr i64 %70 to i16**
store i16** %71, i16*** %13
%72 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%74 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %72, i8* %73)
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%76 = load i16**, i16*** %12
%77 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %75, i16** %76)
%78 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%79 = load i16**, i16*** %13
%80 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %78, i16** %79)
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 4
%83 = load i8*, i8** %82
%84 = getelementptr inbounds i8, i8* %83, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 97
br i1 %87, label %96, label %88
88: ; preds = %57
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 4
%91 = load i8*, i8** %90
%92 = getelementptr inbounds i8, i8* %91, i64 0
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 65
br i1 %95, label %96, label %109
96: ; preds = %88, %57
%97 = load i64, i64* %9
%98 = icmp eq i64 %97, 4
br i1 %98, label %99, label %100
99: ; preds = %96
store i16 16, i16* %14
br label %101
100: ; preds = %96
store i16 255, i16* %14
br label %101
101: ; preds = %100, %99
%102 = load i16**, i16*** %12
%103 = load i16**, i16*** %13
%104 = load i64, i64* %10
%105 = load i64, i64* %11
%106 = load i16, i16* %14
%107 = sext i16 %106 to i32
%108 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @add_image_array to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %102, i16** %103, i64 %104, i64 %105, i32 %107)
br label %109
109: ; preds = %101, %88
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 4
%112 = load i8*, i8** %111
%113 = getelementptr inbounds i8, i8* %112, i64 0
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp eq i32 %115, 115
br i1 %116, label %125, label %117
117: ; preds = %109
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 4
%120 = load i8*, i8** %119
%121 = getelementptr inbounds i8, i8* %120, i64 0
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp eq i32 %123, 83
br i1 %124, label %125, label %131
125: ; preds = %117, %109
%126 = load i16**, i16*** %12
%127 = load i16**, i16*** %13
%128 = load i64, i64* %10
%129 = load i64, i64* %11
%130 = call i32 (i16**, i16**, i64, i64, ...) bitcast (i32 (...)* @subtract_image_array to i32 (i16**, i16**, i64, i64, ...)*)(i16** %126, i16** %127, i64 %128, i64 %129)
br label %131
131: ; preds = %125, %117
%132 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%133 = load i16**, i16*** %13
%134 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %132, i16** %133)
%135 = load i16**, i16*** %12
%136 = load i64, i64* %10
%137 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %135, i64 %136)
%138 = load i16**, i16*** %13
%139 = load i64, i64* %10
%140 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %138, i64 %139)
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"\0AERROR input file %s does not exist\00"
@.str.2 = [47 x i8] c"\0AERROR Image files %s and %s are not same size\00"
@str = [98 x i8] c"\0A\0A usage: mainas in1-file in2-file out_file add-subtract\0A\0A recall add-subtract a=add s=subtract\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%12 = bitcast i64* %6 to i8*
%13 = bitcast i64* %7 to i8*
%14 = bitcast i64* %8 to i8*
%15 = icmp eq i32 %0, 5
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i8* @strcpy(i8* %9, i8* dereferenceable(1) %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i8* @strcpy(i8* %10, i8* dereferenceable(1) %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = call i8* @strcpy(i8* %11, i8* dereferenceable(1) %26)
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %9)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %9)
unreachable
32: ; preds = %18
%33 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %10)
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %10)
unreachable
37: ; preds = %32
%38 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @are_not_same_size to i32 (i8*, i8*, ...)*)(i8* %9, i8* %10)
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
unreachable
42: ; preds = %37
%43 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %9, i64* %7, i64* %8)
%44 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @get_bitsperpixel to i32 (i8*, i64*, ...)*)(i8* %9, i64* %6)
%45 = load i64, i64* %7
%46 = load i64, i64* %8
%47 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %45, i64 %46)
%48 = sext i32 %47 to i64
%49 = inttoptr i64 %48 to i16**
%50 = load i64, i64* %7
%51 = load i64, i64* %8
%52 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %50, i64 %51)
%53 = sext i32 %52 to i64
%54 = inttoptr i64 %53 to i16**
%55 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %9, i8* %11)
%56 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %9, i16** %49)
%57 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %10, i16** %54)
%58 = getelementptr inbounds i8*, i8** %1, i64 4
%59 = load i8*, i8** %58
%60 = load i8, i8* %59
switch i8 %60, label %70 [
i8 97, label %61
i8 65, label %61
]
61: ; preds = %42, %42
%62 = load i64, i64* %6
%63 = icmp eq i64 %62, 4
%64 = select i1 %63, i32 16, i32 255
%65 = load i64, i64* %7
%66 = load i64, i64* %8
%67 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @add_image_array to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %49, i16** %54, i64 %65, i64 %66, i32 %64)
%68 = load i8*, i8** %58
%69 = load i8, i8* %68
br label %70
70: ; preds = %42, %61
%71 = phi i8 [ %60, %42 ], [ %69, %61 ]
switch i8 %71, label %76 [
i8 115, label %72
i8 83, label %72
]
72: ; preds = %70, %70
%73 = load i64, i64* %7
%74 = load i64, i64* %8
%75 = call i32 (i16**, i16**, i64, i64, ...) bitcast (i32 (...)* @subtract_image_array to i32 (i16**, i16**, i64, i64, ...)*)(i16** %49, i16** %54, i64 %73, i64 %74)
br label %76
76: ; preds = %70, %72
%77 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %11, i16** %54)
%78 = load i64, i64* %7
%79 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %49, i64 %78)
%80 = load i64, i64* %7
%81 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %54, i64 %80)
ret i32 0
}