int main(argc, argv)
int argc;
char *argv[];
{
  char name1[80], name2[80], type[80];
  int i, j, mask_type, number, threshold;
  long length, width;
  short value;
  short **the_image;
  short **out_image;
  if (argc < 5) {
    show_mainsk_usage();
    exit(0);
  }
  strcpy(name1, argv[1]);
  strcpy(name2, argv[2]);
  strcpy(type, argv[3]);
  value = atoi(argv[4]);
  if (does_not_exist(name1)) {
    printf("\nERROR input file %s does not exist", name1);
    exit(0);
  }
  if (argc >= 5) {
    threshold = atoi(argv[5]);
    mask_type = atoi(argv[5]);
  }
  if (argc >= 6)
    number = atoi(argv[6]);
  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);
  for (i = 0; i < length; i++)
    for (j = 0; j < width; j++)
      out_image[i][j] = 0;
  if (strncmp("thi", type, 3) == 0) {
    thinning(the_image, out_image, value, threshold, 0, length, width);
  }
  if (strncmp("dnj", type, 3) == 0) {
    dilate_not_join(the_image, out_image, value, threshold, length, width);
  }
  if (strncmp("ero", type, 3) == 0) {
    erosion(the_image, out_image, value, threshold, length, width);
  }
  if (strncmp("dil", type, 3) == 0) {
    dilation(the_image, out_image, value, threshold, length, width);
  }
  if (strncmp("mer", type, 3) == 0) {
    mask_erosion(the_image, out_image, value, mask_type, length, width);
  }
  if (strncmp("mdi", type, 3) == 0) {
    mask_dilation(the_image, out_image, value, mask_type, length, width);
  }
  if (strncmp("int", type, 3) == 0) {
    interior_outline(the_image, out_image, value, mask_type, length, width);
  }
  if (strncmp("ext", type, 3) == 0) {
    exterior_outline(the_image, out_image, value, mask_type, length, width);
  }
  if (strncmp("ope", type, 3) == 0) {
    opening(the_image, out_image, value, mask_type, number, length, width);
  }
  if (strncmp("clo", type, 3) == 0) {
    closing(the_image, out_image, value, mask_type, number, length, width);
  }
  if (strncmp("spo", type, 3) == 0) {
    special_opening(the_image, out_image, value, threshold, number, length,
                    width);
  }
  if (strncmp("spc", type, 3) == 0) {
    special_closing(the_image, out_image, value, threshold, number, length,
                    width);
  }
  if (strncmp("edm", type, 3) == 0) {
    edm(the_image, out_image, value, length, width);
  }
  if (strncmp("mat", type, 3) == 0) {
    mat(the_image, out_image, value, 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    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    12e1 <main+0x31>
mov    $0x0,%al
call   1160 <show_mainsk_usage@plt>
xor    %edi,%edi
call   11b0 <exit@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1060 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <strcpy@plt>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    $0x0,%al
call   11a0 <atoi@plt>
mov    %ax,-0x12a(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x0,%al
call   1120 <does_not_exist@plt>
cmp    $0x0,%eax
je     135d <main+0xad>
lea    -0x60(%rbp),%rsi
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xor    %edi,%edi
call   11b0 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jl     1391 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
mov    $0x0,%al
call   11a0 <atoi@plt>
mov    %eax,-0x114(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
mov    $0x0,%al
call   11a0 <atoi@plt>
mov    %eax,-0x10c(%rbp)
cmpl   $0x6,-0x8(%rbp)
jl     13b0 <main+0x100>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
mov    $0x0,%al
call   11a0 <atoi@plt>
mov    %eax,-0x110(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x120(%rbp),%rsi
lea    -0x128(%rbp),%rdx
mov    $0x0,%al
call   1100 <get_image_size@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   11c0 <allocate_image_array@plt>
cltq
mov    %rax,-0x138(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   11c0 <allocate_image_array@plt>
cltq
mov    %rax,-0x140(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x0,%al
call   1030 <create_image_file@plt>
lea    -0x60(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    $0x0,%al
call   1190 <read_image_array@plt>
movl   $0x0,-0x104(%rbp)
movslq -0x104(%rbp),%rax
cmp    -0x120(%rbp),%rax
jge    14b1 <main+0x201>
movl   $0x0,-0x108(%rbp)
movslq -0x108(%rbp),%rax
cmp    -0x128(%rbp),%rax
jge    1498 <main+0x1e8>
mov    -0x140(%rbp),%rax
movslq -0x104(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x108(%rbp),%rcx
movw   $0x0,(%rax,%rcx,2)
mov    -0x108(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x108(%rbp)
jmp    1451 <main+0x1a1>
jmp    149d <main+0x1ed>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1433 <main+0x183>
lea    -0x100(%rbp),%rsi
lea    0xb65(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1509 <main+0x259>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x120(%rbp),%r9
mov    -0x128(%rbp),%rax
xor    %r8d,%r8d
mov    %rax,(%rsp)
mov    $0x0,%al
call   1110 <thinning@plt>
lea    -0x100(%rbp),%rsi
lea    0xb11(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    155a <main+0x2aa>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1090 <dilate_not_join@plt>
lea    -0x100(%rbp),%rsi
lea    0xac4(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    15ab <main+0x2fb>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   10d0 <erosion@plt>
lea    -0x100(%rbp),%rsi
lea    0xa77(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    15fc <main+0x34c>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1130 <dilation@plt>
lea    -0x100(%rbp),%rsi
lea    0xa2a(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    164d <main+0x39d>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1070 <mask_erosion@plt>
lea    -0x100(%rbp),%rsi
lea    0x9dd(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    169e <main+0x3ee>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1150 <mask_dilation@plt>
lea    -0x100(%rbp),%rsi
lea    0x990(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    16ef <main+0x43f>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1180 <interior_outline@plt>
lea    -0x100(%rbp),%rsi
lea    0x943(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1740 <main+0x490>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x120(%rbp),%r8
mov    -0x128(%rbp),%r9
mov    $0x0,%al
call   1040 <exterior_outline@plt>
lea    -0x100(%rbp),%rsi
lea    0x8f6(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    179c <main+0x4ec>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x110(%rbp),%r8d
mov    -0x120(%rbp),%r9
mov    -0x128(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1080 <opening@plt>
lea    -0x100(%rbp),%rsi
lea    0x89e(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    17f8 <main+0x548>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    -0x110(%rbp),%r8d
mov    -0x120(%rbp),%r9
mov    -0x128(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   10f0 <closing@plt>
lea    -0x100(%rbp),%rsi
lea    0x846(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1854 <main+0x5a4>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x110(%rbp),%r8d
mov    -0x120(%rbp),%r9
mov    -0x128(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   10c0 <special_opening@plt>
lea    -0x100(%rbp),%rsi
lea    0x7ee(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    18b0 <main+0x600>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x114(%rbp),%ecx
mov    -0x110(%rbp),%r8d
mov    -0x120(%rbp),%r9
mov    -0x128(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1170 <special_closing@plt>
lea    -0x100(%rbp),%rsi
lea    0x796(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    18fb <main+0x64b>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x120(%rbp),%rcx
mov    -0x128(%rbp),%r8
mov    $0x0,%al
call   1140 <edm@plt>
lea    -0x100(%rbp),%rsi
lea    0x74f(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1946 <main+0x696>
mov    -0x138(%rbp),%rdi
mov    -0x140(%rbp),%rsi
movswl -0x12a(%rbp),%edx
mov    -0x120(%rbp),%rcx
mov    -0x128(%rbp),%r8
mov    $0x0,%al
call   10b0 <mat@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x140(%rbp),%rsi
mov    $0x0,%al
call   10e0 <write_image_array@plt>
mov    -0x140(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x0,%al
call   11d0 <free_image_array@plt>
mov    -0x138(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x0,%al
call   11d0 <free_image_array@plt>
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
cmp    $0x4,%edi
jle    1800 <main+0x550>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x8(%rsi),%rsi
lea    0xf0(%rsp),%r15
mov    %r15,%rdi
call   1050 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0xa0(%rsp),%rdi
call   1050 <strcpy@plt>
mov    0x18(%rbx),%rsi
lea    0x40(%rsp),%rdi
call   1050 <strcpy@plt>
mov    0x20(%rbx),%rdi
xor    %eax,%eax
call   11a0 <atoi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1120 <does_not_exist@plt>
test   %eax,%eax
jne    180e <main+0x55e>
mov    %ebp,0x34(%rsp)
mov    0x28(%rbx),%rdi
xor    %eax,%eax
call   11a0 <atoi@plt>
mov    %eax,0x30(%rsp)
mov    0x28(%rbx),%rdi
xor    %eax,%eax
call   11a0 <atoi@plt>
mov    %eax,0x2c(%rsp)
cmp    $0x6,%r14d
jb     1359 <main+0xa9>
mov    0x30(%rbx),%rdi
xor    %eax,%eax
call   11a0 <atoi@plt>
mov    %eax,0x28(%rsp)
lea    0xf0(%rsp),%rbx
lea    0x10(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1100 <get_image_size@plt>
mov    0x10(%rsp),%rdi
mov    0x20(%rsp),%rsi
xor    %eax,%eax
call   11c0 <allocate_image_array@plt>
movslq %eax,%rbp
mov    0x10(%rsp),%rdi
mov    0x20(%rsp),%rsi
xor    %eax,%eax
call   11c0 <allocate_image_array@plt>
cltq
mov    %rax,0x18(%rsp)
lea    0xa0(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <create_image_file@plt>
mov    %rbx,%rdi
mov    %rbp,0x98(%rsp)
mov    %rbp,%rsi
xor    %eax,%eax
call   1190 <read_image_array@plt>
mov    0x10(%rsp),%rax
mov    %rax,0x38(%rsp)
test   %rax,%rax
jle    142e <main+0x17e>
mov    0x20(%rsp),%rbx
lea    (%rbx,%rbx,1),%r15
mov    0x38(%rsp),%r14
lea    -0x1(%r14),%rax
mov    %r14d,%r12d
and    $0x3,%r12d
cmp    $0x3,%rax
jae    179a <main+0x4ea>
xor    %r13d,%r13d
test   %r12,%r12
je     142e <main+0x17e>
mov    0x18(%rsp),%rax
lea    (%rax,%r13,8),%r14
xor    %ebp,%ebp
jmp    1419 <main+0x169>
nop
add    $0x1,%rbp
cmp    %rbp,%r12
je     142e <main+0x17e>
test   %rbx,%rbx
jle    1410 <main+0x160>
mov    (%r14,%rbp,8),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   10c0 <memset@plt>
jmp    1410 <main+0x160>
mov    $0x6874,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x69,%ecx
or     %ax,%cx
mov    0x34(%rsp),%r14d
mov    0x98(%rsp),%rbp
mov    0x30(%rsp),%r15d
jne    147d <main+0x1cd>
movswl %r14w,%edx
mov    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
xor    %r8d,%r8d
mov    0x38(%rsp),%r9
xor    %eax,%eax
call   1110 <thinning@plt>
mov    $0x6e64,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6a,%ecx
or     %ax,%cx
mov    0x2c(%rsp),%ebx
jne    14b7 <main+0x207>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <dilate_not_join@plt>
mov    $0x7265,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6f,%ecx
or     %ax,%cx
jne    14ed <main+0x23d>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
xor    %eax,%eax
call   10d0 <erosion@plt>
mov    $0x6964,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6c,%ecx
or     %ax,%cx
mov    0x28(%rsp),%r12d
jne    1528 <main+0x278>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
xor    %eax,%eax
call   1130 <dilation@plt>
mov    $0x656d,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x72,%ecx
or     %ax,%cx
jne    155d <main+0x2ad>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <mask_erosion@plt>
mov    $0x646d,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x69,%ecx
or     %ax,%cx
jne    1592 <main+0x2e2>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1150 <mask_dilation@plt>
mov    $0x6e69,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x74,%ecx
or     %ax,%cx
jne    15c7 <main+0x317>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1180 <interior_outline@plt>
mov    $0x7865,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x74,%ecx
or     %ax,%cx
jne    15fc <main+0x34c>
movswl %r14w,%edx
mov    0x10(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <exterior_outline@plt>
mov    $0x706f,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x65,%ecx
or     %ax,%cx
jne    1638 <main+0x388>
movswl %r14w,%edx
mov    0x10(%rsp),%r9
mov    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1070 <opening@plt>
mov    $0x6c63,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6f,%ecx
or     %ax,%cx
jne    1674 <main+0x3c4>
movswl %r14w,%edx
mov    0x10(%rsp),%r9
mov    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   10f0 <closing@plt>
mov    $0x7073,%ebx
mov    0x40(%rsp),%eax
xor    %ebx,%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6f,%ecx
or     %ax,%cx
jne    16b3 <main+0x403>
movswl %r14w,%edx
mov    0x10(%rsp),%r9
mov    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   10b0 <special_opening@plt>
xor    0x40(%rsp),%ebx
movzbl 0x42(%rsp),%eax
xor    $0x63,%eax
or     %bx,%ax
jne    16eb <main+0x43b>
movswl %r14w,%edx
mov    0x10(%rsp),%r9
mov    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1170 <special_closing@plt>
mov    $0x6465,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x6d,%ecx
or     %ax,%cx
jne    171e <main+0x46e>
movswl %r14w,%edx
mov    0x10(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1140 <edm@plt>
mov    $0x616d,%eax
xor    0x40(%rsp),%eax
movzbl 0x42(%rsp),%ecx
xor    $0x74,%ecx
or     %ax,%cx
jne    1751 <main+0x4a1>
movswl %r14w,%edx
mov    0x10(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   10a0 <mat@plt>
lea    0xa0(%rsp),%rdi
mov    0x18(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10e0 <write_image_array@plt>
mov    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   11d0 <free_image_array@plt>
mov    0x10(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   11d0 <free_image_array@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffffffffffc,%r14
xor    %r13d,%r13d
mov    0x18(%rsp),%rbp
jmp    17bd <main+0x50d>
nopl   0x0(%rax,%rax,1)
add    $0x4,%r13
cmp    %r13,%r14
je     13fd <main+0x14d>
test   %rbx,%rbx
jle    17b0 <main+0x500>
mov    0x0(%rbp,%r13,8),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   10c0 <memset@plt>
mov    0x8(%rbp,%r13,8),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   10c0 <memset@plt>
mov    0x10(%rbp,%r13,8),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   10c0 <memset@plt>
mov    0x18(%rbp,%r13,8),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   10c0 <memset@plt>
jmp    17b0 <main+0x500>
xor    %eax,%eax
call   1160 <show_mainsk_usage@plt>
xor    %edi,%edi
call   11b0 <exit@plt>
lea    0x7eb(%rip),%rdi
lea    0xf0(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %edi,%edi
call   11b0 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"\0AERROR input file %s does not exist\00"
@.str.1 = [4 x i8] c"thi\00"
@.str.2 = [4 x i8] c"dnj\00"
@.str.3 = [4 x i8] c"ero\00"
@.str.4 = [4 x i8] c"dil\00"
@.str.5 = [4 x i8] c"mer\00"
@.str.6 = [4 x i8] c"mdi\00"
@.str.7 = [4 x i8] c"int\00"
@.str.8 = [4 x i8] c"ext\00"
@.str.9 = [4 x i8] c"ope\00"
@.str.10 = [4 x i8] c"clo\00"
@.str.11 = [4 x i8] c"spo\00"
@.str.12 = [4 x i8] c"spc\00"
@.str.13 = [4 x i8] c"edm\00"
@.str.14 = [4 x i8] c"mat\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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i16
%17 = alloca i16**
%18 = alloca i16**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (...) @show_mainsk_usage()
unreachable
23: ; preds = %2
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i8* @strcpy(i8* %24, i8* %27)
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i8* @strcpy(i8* %29, i8* %32)
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i8* @strcpy(i8* %34, i8* %37)
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 4
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %41)
%43 = trunc i32 %42 to i16
store i16 %43, i16* %16
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%45 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %23
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %48)
unreachable
50: ; preds = %23
%51 = load i32, i32* %4
%52 = icmp sge i32 %51, 5
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 5
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %56)
store i32 %57, i32* %13
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 5
%60 = load i8*, i8** %59
%61 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %60)
store i32 %61, i32* %11
br label %62
62: ; preds = %53, %50
%63 = load i32, i32* %4
%64 = icmp sge i32 %63, 6
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 6
%68 = load i8*, i8** %67
%69 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %68)
store i32 %69, i32* %12
br label %70
70: ; preds = %65, %62
%71 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%72 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %71, i64* %14, i64* %15)
%73 = load i64, i64* %14
%74 = load i64, i64* %15
%75 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %73, i64 %74)
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i16**
store i16** %77, i16*** %17
%78 = load i64, i64* %14
%79 = load i64, i64* %15
%80 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %78, i64 %79)
%81 = sext i32 %80 to i64
%82 = inttoptr i64 %81 to i16**
store i16** %82, i16*** %18
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%84 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%85 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %83, i8* %84)
%86 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%87 = load i16**, i16*** %17
%88 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %86, i16** %87)
store i32 0, i32* %9
br label %89
89: ; preds = %113, %70
%90 = load i32, i32* %9
%91 = sext i32 %90 to i64
%92 = load i64, i64* %14
%93 = icmp slt i64 %91, %92
br i1 %93, label %94, label %116
94: ; preds = %89
store i32 0, i32* %10
br label %95
95: ; preds = %109, %94
%96 = load i32, i32* %10
%97 = sext i32 %96 to i64
%98 = load i64, i64* %15
%99 = icmp slt i64 %97, %98
br i1 %99, label %100, label %112
100: ; preds = %95
%101 = load i16**, i16*** %18
%102 = load i32, i32* %9
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i16*, i16** %101, i64 %103
%105 = load i16*, i16** %104
%106 = load i32, i32* %10
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i16, i16* %105, i64 %107
store i16 0, i16* %108
br label %109
109: ; preds = %100
%110 = load i32, i32* %10
%111 = add nsw i32 %110, 1
store i32 %111, i32* %10
br label %95
112: ; preds = %95
br label %113
113: ; preds = %112
%114 = load i32, i32* %9
%115 = add nsw i32 %114, 1
store i32 %115, i32* %9
br label %89
116: ; preds = %89
%117 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%118 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %117, i64 3)
%119 = icmp eq i32 %118, 0
br i1 %119, label %120, label %129
120: ; preds = %116
%121 = load i16**, i16*** %17
%122 = load i16**, i16*** %18
%123 = load i16, i16* %16
%124 = sext i16 %123 to i32
%125 = load i32, i32* %13
%126 = load i64, i64* %14
%127 = load i64, i64* %15
%128 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %121, i16** %122, i32 %124, i32 %125, i32 0, i64 %126, i64 %127)
br label %129
129: ; preds = %120, %116
%130 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%131 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %130, i64 3)
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %142
133: ; preds = %129
%134 = load i16**, i16*** %17
%135 = load i16**, i16*** %18
%136 = load i16, i16* %16
%137 = sext i16 %136 to i32
%138 = load i32, i32* %13
%139 = load i64, i64* %14
%140 = load i64, i64* %15
%141 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilate_not_join to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %134, i16** %135, i32 %137, i32 %138, i64 %139, i64 %140)
br label %142
142: ; preds = %133, %129
%143 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%144 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %143, i64 3)
%145 = icmp eq i32 %144, 0
br i1 %145, label %146, label %155
146: ; preds = %142
%147 = load i16**, i16*** %17
%148 = load i16**, i16*** %18
%149 = load i16, i16* %16
%150 = sext i16 %149 to i32
%151 = load i32, i32* %13
%152 = load i64, i64* %14
%153 = load i64, i64* %15
%154 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @erosion to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %147, i16** %148, i32 %150, i32 %151, i64 %152, i64 %153)
br label %155
155: ; preds = %146, %142
%156 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%157 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %156, i64 3)
%158 = icmp eq i32 %157, 0
br i1 %158, label %159, label %168
159: ; preds = %155
%160 = load i16**, i16*** %17
%161 = load i16**, i16*** %18
%162 = load i16, i16* %16
%163 = sext i16 %162 to i32
%164 = load i32, i32* %13
%165 = load i64, i64* %14
%166 = load i64, i64* %15
%167 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %160, i16** %161, i32 %163, i32 %164, i64 %165, i64 %166)
br label %168
168: ; preds = %159, %155
%169 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%170 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %169, i64 3)
%171 = icmp eq i32 %170, 0
br i1 %171, label %172, label %181
172: ; preds = %168
%173 = load i16**, i16*** %17
%174 = load i16**, i16*** %18
%175 = load i16, i16* %16
%176 = sext i16 %175 to i32
%177 = load i32, i32* %11
%178 = load i64, i64* %14
%179 = load i64, i64* %15
%180 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @mask_erosion to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %173, i16** %174, i32 %176, i32 %177, i64 %178, i64 %179)
br label %181
181: ; preds = %172, %168
%182 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%183 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %182, i64 3)
%184 = icmp eq i32 %183, 0
br i1 %184, label %185, label %194
185: ; preds = %181
%186 = load i16**, i16*** %17
%187 = load i16**, i16*** %18
%188 = load i16, i16* %16
%189 = sext i16 %188 to i32
%190 = load i32, i32* %11
%191 = load i64, i64* %14
%192 = load i64, i64* %15
%193 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @mask_dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %186, i16** %187, i32 %189, i32 %190, i64 %191, i64 %192)
br label %194
194: ; preds = %185, %181
%195 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%196 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %195, i64 3)
%197 = icmp eq i32 %196, 0
br i1 %197, label %198, label %207
198: ; preds = %194
%199 = load i16**, i16*** %17
%200 = load i16**, i16*** %18
%201 = load i16, i16* %16
%202 = sext i16 %201 to i32
%203 = load i32, i32* %11
%204 = load i64, i64* %14
%205 = load i64, i64* %15
%206 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @interior_outline to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %199, i16** %200, i32 %202, i32 %203, i64 %204, i64 %205)
br label %207
207: ; preds = %198, %194
%208 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%209 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %208, i64 3)
%210 = icmp eq i32 %209, 0
br i1 %210, label %211, label %220
211: ; preds = %207
%212 = load i16**, i16*** %17
%213 = load i16**, i16*** %18
%214 = load i16, i16* %16
%215 = sext i16 %214 to i32
%216 = load i32, i32* %11
%217 = load i64, i64* %14
%218 = load i64, i64* %15
%219 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @exterior_outline to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %212, i16** %213, i32 %215, i32 %216, i64 %217, i64 %218)
br label %220
220: ; preds = %211, %207
%221 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%222 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %221, i64 3)
%223 = icmp eq i32 %222, 0
br i1 %223, label %224, label %234
224: ; preds = %220
%225 = load i16**, i16*** %17
%226 = load i16**, i16*** %18
%227 = load i16, i16* %16
%228 = sext i16 %227 to i32
%229 = load i32, i32* %11
%230 = load i32, i32* %12
%231 = load i64, i64* %14
%232 = load i64, i64* %15
%233 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @opening to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %225, i16** %226, i32 %228, i32 %229, i32 %230, i64 %231, i64 %232)
br label %234
234: ; preds = %224, %220
%235 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%236 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %235, i64 3)
%237 = icmp eq i32 %236, 0
br i1 %237, label %238, label %248
238: ; preds = %234
%239 = load i16**, i16*** %17
%240 = load i16**, i16*** %18
%241 = load i16, i16* %16
%242 = sext i16 %241 to i32
%243 = load i32, i32* %11
%244 = load i32, i32* %12
%245 = load i64, i64* %14
%246 = load i64, i64* %15
%247 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @closing to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %239, i16** %240, i32 %242, i32 %243, i32 %244, i64 %245, i64 %246)
br label %248
248: ; preds = %238, %234
%249 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%250 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %249, i64 3)
%251 = icmp eq i32 %250, 0
br i1 %251, label %252, label %262
252: ; preds = %248
%253 = load i16**, i16*** %17
%254 = load i16**, i16*** %18
%255 = load i16, i16* %16
%256 = sext i16 %255 to i32
%257 = load i32, i32* %13
%258 = load i32, i32* %12
%259 = load i64, i64* %14
%260 = load i64, i64* %15
%261 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @special_opening to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %253, i16** %254, i32 %256, i32 %257, i32 %258, i64 %259, i64 %260)
br label %262
262: ; preds = %252, %248
%263 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%264 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %263, i64 3)
%265 = icmp eq i32 %264, 0
br i1 %265, label %266, label %276
266: ; preds = %262
%267 = load i16**, i16*** %17
%268 = load i16**, i16*** %18
%269 = load i16, i16* %16
%270 = sext i16 %269 to i32
%271 = load i32, i32* %13
%272 = load i32, i32* %12
%273 = load i64, i64* %14
%274 = load i64, i64* %15
%275 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @special_closing to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %267, i16** %268, i32 %270, i32 %271, i32 %272, i64 %273, i64 %274)
br label %276
276: ; preds = %266, %262
%277 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%278 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %277, i64 3)
%279 = icmp eq i32 %278, 0
br i1 %279, label %280, label %288
280: ; preds = %276
%281 = load i16**, i16*** %17
%282 = load i16**, i16*** %18
%283 = load i16, i16* %16
%284 = sext i16 %283 to i32
%285 = load i64, i64* %14
%286 = load i64, i64* %15
%287 = call i32 (i16**, i16**, i32, i64, i64, ...) bitcast (i32 (...)* @edm to i32 (i16**, i16**, i32, i64, i64, ...)*)(i16** %281, i16** %282, i32 %284, i64 %285, i64 %286)
br label %288
288: ; preds = %280, %276
%289 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%290 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %289, i64 3)
%291 = icmp eq i32 %290, 0
br i1 %291, label %292, label %300
292: ; preds = %288
%293 = load i16**, i16*** %17
%294 = load i16**, i16*** %18
%295 = load i16, i16* %16
%296 = sext i16 %295 to i32
%297 = load i64, i64* %14
%298 = load i64, i64* %15
%299 = call i32 (i16**, i16**, i32, i64, i64, ...) bitcast (i32 (...)* @mat to i32 (i16**, i16**, i32, i64, i64, ...)*)(i16** %293, i16** %294, i32 %296, i64 %297, i64 %298)
br label %300
300: ; preds = %292, %288
%301 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%302 = load i16**, i16*** %18
%303 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %301, i16** %302)
%304 = load i16**, i16*** %18
%305 = load i64, i64* %14
%306 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %304, i64 %305)
%307 = load i16**, i16*** %17
%308 = load i64, i64* %14
%309 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %307, i64 %308)
%310 = load i32, i32* %3
ret i32 %310
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0AERROR input file %s does not exist\00"
@.str.1 = [4 x i8] c"thi\00"
@.str.2 = [4 x i8] c"dnj\00"
@.str.3 = [4 x i8] c"ero\00"
@.str.4 = [4 x i8] c"dil\00"
@.str.5 = [4 x i8] c"mer\00"
@.str.6 = [4 x i8] c"mdi\00"
@.str.7 = [4 x i8] c"int\00"
@.str.8 = [4 x i8] c"ext\00"
@.str.9 = [4 x i8] c"ope\00"
@.str.10 = [4 x i8] c"clo\00"
@.str.11 = [4 x i8] c"spo\00"
@.str.12 = [4 x i8] c"spc\00"
@.str.13 = [4 x i8] c"edm\00"
@.str.14 = [4 x i8] c"mat\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 = 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 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%11 = bitcast i64* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = icmp slt i32 %0, 5
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 (...) @show_mainsk_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 i8* @strcpy(i8* %10, i8* dereferenceable(1) %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 4
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %27)
%29 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %8)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %16
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %8)
unreachable
33: ; preds = %16
%34 = getelementptr inbounds i8*, i8** %1, i64 5
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %35)
%37 = load i8*, i8** %34
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %37)
%39 = icmp ugt i32 %0, 5
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = getelementptr inbounds i8*, i8** %1, i64 6
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %42)
br label %44
44: ; preds = %40, %33
%45 = phi i32 [ %43, %40 ], [ undef, %33 ]
%46 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %8, i64* %6, i64* %7)
%47 = load i64, i64* %6
%48 = load i64, i64* %7
%49 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %47, i64 %48)
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i16**
%52 = load i64, i64* %6
%53 = load i64, i64* %7
%54 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %52, i64 %53)
%55 = sext i32 %54 to i64
%56 = inttoptr i64 %55 to i16**
%57 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %8, i8* %9)
%58 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %8, i16** %51)
%59 = load i64, i64* %6
%60 = icmp sgt i64 %59, 0
br i1 %60, label %61, label %107
61: ; preds = %44
%62 = load i64, i64* %7
%63 = icmp sgt i64 %62, 0
%64 = shl nuw i64 %62, 1
%65 = add i64 %59, -1
%66 = and i64 %59, 3
%67 = icmp ult i64 %65, 3
br i1 %67, label %93, label %68
68: ; preds = %61
%69 = and i64 %59, -4
br label %70
70: ; preds = %89, %68
%71 = phi i64 [ 0, %68 ], [ %90, %89 ]
%72 = phi i64 [ 0, %68 ], [ %91, %89 ]
br i1 %63, label %73, label %89
73: ; preds = %70
%74 = getelementptr inbounds i16*, i16** %56, i64 %71
%75 = bitcast i16** %74 to i8**
%76 = load i8*, i8** %75
%77 = or i64 %71, 1
%78 = getelementptr inbounds i16*, i16** %56, i64 %77
%79 = bitcast i16** %78 to i8**
%80 = load i8*, i8** %79
%81 = or i64 %71, 2
%82 = getelementptr inbounds i16*, i16** %56, i64 %81
%83 = bitcast i16** %82 to i8**
%84 = load i8*, i8** %83
%85 = or i64 %71, 3
%86 = getelementptr inbounds i16*, i16** %56, i64 %85
%87 = bitcast i16** %86 to i8**
%88 = load i8*, i8** %87
br label %89
89: ; preds = %70, %73
%90 = add nuw nsw i64 %71, 4
%91 = add i64 %72, 4
%92 = icmp eq i64 %91, %69
br i1 %92, label %93, label %70
93: ; preds = %89, %61
%94 = phi i64 [ 0, %61 ], [ %90, %89 ]
%95 = icmp eq i64 %66, 0
br i1 %95, label %107, label %96
96: ; preds = %93, %103
%97 = phi i64 [ %104, %103 ], [ %94, %93 ]
%98 = phi i64 [ %105, %103 ], [ 0, %93 ]
br i1 %63, label %99, label %103
99: ; preds = %96
%100 = getelementptr inbounds i16*, i16** %56, i64 %97
%101 = bitcast i16** %100 to i8**
%102 = load i8*, i8** %101
br label %103
103: ; preds = %99, %96
%104 = add nuw nsw i64 %97, 1
%105 = add i64 %98, 1
%106 = icmp eq i64 %105, %66
br i1 %106, label %107, label %96
107: ; preds = %93, %103, %44
%108 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %115
110: ; preds = %107
%111 = shl i32 %28, 16
%112 = ashr exact i32 %111, 16
%113 = load i64, i64* %7
%114 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @thinning to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %112, i32 %36, i32 0, i64 %59, i64 %113)
br label %115
115: ; preds = %110, %107
%116 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %115
%119 = shl i32 %28, 16
%120 = ashr exact i32 %119, 16
%121 = load i64, i64* %6
%122 = load i64, i64* %7
%123 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilate_not_join to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %120, i32 %36, i64 %121, i64 %122)
br label %124
124: ; preds = %118, %115
%125 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %133
127: ; preds = %124
%128 = shl i32 %28, 16
%129 = ashr exact i32 %128, 16
%130 = load i64, i64* %6
%131 = load i64, i64* %7
%132 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @erosion to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %129, i32 %36, i64 %130, i64 %131)
br label %133
133: ; preds = %127, %124
%134 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %142
136: ; preds = %133
%137 = shl i32 %28, 16
%138 = ashr exact i32 %137, 16
%139 = load i64, i64* %6
%140 = load i64, i64* %7
%141 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %138, i32 %36, i64 %139, i64 %140)
br label %142
142: ; preds = %136, %133
%143 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%144 = icmp eq i32 %143, 0
br i1 %144, label %145, label %151
145: ; preds = %142
%146 = shl i32 %28, 16
%147 = ashr exact i32 %146, 16
%148 = load i64, i64* %6
%149 = load i64, i64* %7
%150 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @mask_erosion to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %147, i32 %38, i64 %148, i64 %149)
br label %151
151: ; preds = %145, %142
%152 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%153 = icmp eq i32 %152, 0
br i1 %153, label %154, label %160
154: ; preds = %151
%155 = shl i32 %28, 16
%156 = ashr exact i32 %155, 16
%157 = load i64, i64* %6
%158 = load i64, i64* %7
%159 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @mask_dilation to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %156, i32 %38, i64 %157, i64 %158)
br label %160
160: ; preds = %154, %151
%161 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%162 = icmp eq i32 %161, 0
br i1 %162, label %163, label %169
163: ; preds = %160
%164 = shl i32 %28, 16
%165 = ashr exact i32 %164, 16
%166 = load i64, i64* %6
%167 = load i64, i64* %7
%168 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @interior_outline to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %165, i32 %38, i64 %166, i64 %167)
br label %169
169: ; preds = %163, %160
%170 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%171 = icmp eq i32 %170, 0
br i1 %171, label %172, label %178
172: ; preds = %169
%173 = shl i32 %28, 16
%174 = ashr exact i32 %173, 16
%175 = load i64, i64* %6
%176 = load i64, i64* %7
%177 = call i32 (i16**, i16**, i32, i32, i64, i64, ...) bitcast (i32 (...)* @exterior_outline to i32 (i16**, i16**, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %174, i32 %38, i64 %175, i64 %176)
br label %178
178: ; preds = %172, %169
%179 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %187
181: ; preds = %178
%182 = shl i32 %28, 16
%183 = ashr exact i32 %182, 16
%184 = load i64, i64* %6
%185 = load i64, i64* %7
%186 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @opening to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %183, i32 %38, i32 %45, i64 %184, i64 %185)
br label %187
187: ; preds = %181, %178
%188 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%189 = icmp eq i32 %188, 0
br i1 %189, label %190, label %196
190: ; preds = %187
%191 = shl i32 %28, 16
%192 = ashr exact i32 %191, 16
%193 = load i64, i64* %6
%194 = load i64, i64* %7
%195 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @closing to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %192, i32 %38, i32 %45, i64 %193, i64 %194)
br label %196
196: ; preds = %190, %187
%197 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%198 = icmp eq i32 %197, 0
br i1 %198, label %199, label %205
199: ; preds = %196
%200 = shl i32 %28, 16
%201 = ashr exact i32 %200, 16
%202 = load i64, i64* %6
%203 = load i64, i64* %7
%204 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @special_opening to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %201, i32 %36, i32 %45, i64 %202, i64 %203)
br label %205
205: ; preds = %199, %196
%206 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%207 = icmp eq i32 %206, 0
br i1 %207, label %208, label %214
208: ; preds = %205
%209 = shl i32 %28, 16
%210 = ashr exact i32 %209, 16
%211 = load i64, i64* %6
%212 = load i64, i64* %7
%213 = call i32 (i16**, i16**, i32, i32, i32, i64, i64, ...) bitcast (i32 (...)* @special_closing to i32 (i16**, i16**, i32, i32, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %210, i32 %36, i32 %45, i64 %211, i64 %212)
br label %214
214: ; preds = %208, %205
%215 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%216 = icmp eq i32 %215, 0
br i1 %216, label %217, label %223
217: ; preds = %214
%218 = shl i32 %28, 16
%219 = ashr exact i32 %218, 16
%220 = load i64, i64* %6
%221 = load i64, i64* %7
%222 = call i32 (i16**, i16**, i32, i64, i64, ...) bitcast (i32 (...)* @edm to i32 (i16**, i16**, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %219, i64 %220, i64 %221)
br label %223
223: ; preds = %217, %214
%224 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* dereferenceable(3) %10, i64 3)
%225 = icmp eq i32 %224, 0
br i1 %225, label %226, label %232
226: ; preds = %223
%227 = shl i32 %28, 16
%228 = ashr exact i32 %227, 16
%229 = load i64, i64* %6
%230 = load i64, i64* %7
%231 = call i32 (i16**, i16**, i32, i64, i64, ...) bitcast (i32 (...)* @mat to i32 (i16**, i16**, i32, i64, i64, ...)*)(i16** %51, i16** %56, i32 %228, i64 %229, i64 %230)
br label %232
232: ; preds = %226, %223
%233 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %9, i16** %56)
%234 = load i64, i64* %6
%235 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %56, i64 %234)
%236 = load i64, i64* %6
%237 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %51, i64 %236)
ret i32 0
}