int main(argc, argv)
int argc;
char *argv[];
{
  char name1[80];
  char name2[80];
  char low_high[80];
  int i, j, size, type;
  long bits_per_pixel, length, width;
  short **the_image, **out_image, filter[3][3];
  if (argc < 5 || argc > 6) {
    printf("\nusage 1: mfilter in-image out-image g Low-High type"
           "\n                 OR"
           "\nusage 2: mfilter in-image out-image High-Low-Median size"
           "\n                   h - high pixel"
           "\n                   l - low pixel"
           "\n                   m - median pixel"
           "\n                  "
           "\n Using the General type requires entering "
           "\n the type per the following table"
           "\n L -  6"
           "\n L -  9"
           "\n L - 10"
           "\n L - 16"
           "\n L - 32"
           "\n H -  1"
           "\n H -  2"
           "\n H -  3"
           "\n Using the High-Low-Median type requirs entering "
           "\n the size of the filtered area 3 (3x3) 5, 7, 9, etc.\n");
    exit(0);
  }
  strcpy(name1, argv[1]);
  strcpy(name2, argv[2]);
  if (does_not_exist(name1)) {
    printf("\nERROR input file %s does not exist", name1);
    exit(0);
  }
  create_image_file(name1, name2);
  get_image_size(name1, &length, &width);
  get_bitsperpixel(name1, &bits_per_pixel);
  the_image = allocate_image_array(length, width);
  out_image = allocate_image_array(length, width);
  read_image_array(name1, the_image);
  if (argc == 6) {
    strcpy(low_high, argv[4]);
    type = atoi(argv[5]);
    filter_image(the_image, out_image, length, width, bits_per_pixel, filter,
                 type, low_high);
  }
  if (argc == 5) {
    strcpy(low_high, argv[3]);
    size = atoi(argv[4]);
    if (low_high[0] == 'h' || low_high[0] == 'H')
      high_pixel(the_image, out_image, length, width, size);
    if (low_high[0] == 'l' || low_high[0] == 'L')
      low_pixel(the_image, out_image, length, width, size);
    if (low_high[0] == 'm' || low_high[0] == 'M')
      median_filter(the_image, out_image, length, width, size);
  }
  write_image_array(name2, out_image);
  free_image_array(the_image, length);
  free_image_array(out_image, length);
}


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)
cmpl   $0x5,-0x8(%rbp)
jl     122d <main+0x2d>
cmpl   $0x6,-0x8(%rbp)
jle    1242 <main+0x42>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10f0 <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    -0x60(%rbp),%rdi
mov    $0x0,%al
call   10a0 <does_not_exist@plt>
cmp    $0x0,%eax
je     1294 <main+0x94>
lea    -0x60(%rbp),%rsi
lea    0xf6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x0,%al
call   1030 <create_image_file@plt>
lea    -0x60(%rbp),%rdi
lea    -0x120(%rbp),%rsi
lea    -0x128(%rbp),%rdx
mov    $0x0,%al
call   1070 <get_image_size@plt>
lea    -0x60(%rbp),%rdi
lea    -0x118(%rbp),%rsi
mov    $0x0,%al
call   1100 <get_bitsperpixel@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   1110 <allocate_image_array@plt>
cltq
mov    %rax,-0x130(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x0,%al
call   1110 <allocate_image_array@plt>
cltq
mov    %rax,-0x138(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x130(%rbp),%rsi
mov    $0x0,%al
call   10b0 <read_image_array@plt>
cmpl   $0x6,-0x8(%rbp)
jne    139a <main+0x19a>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
mov    $0x0,%al
call   10e0 <atoi@plt>
mov    %eax,-0x110(%rbp)
mov    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x128(%rbp),%rcx
mov    -0x118(%rbp),%r8
lea    -0x150(%rbp),%r9
mov    -0x110(%rbp),%r10d
lea    -0x100(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1080 <filter_image@plt>
cmpl   $0x5,-0x8(%rbp)
jne    14b0 <main+0x2b0>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    $0x0,%al
call   10e0 <atoi@plt>
mov    %eax,-0x10c(%rbp)
movsbl -0x100(%rbp),%eax
cmp    $0x68,%eax
je     13ed <main+0x1ed>
movsbl -0x100(%rbp),%eax
cmp    $0x48,%eax
jne    1417 <main+0x217>
mov    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x128(%rbp),%rcx
mov    -0x10c(%rbp),%r8d
mov    $0x0,%al
call   10c0 <high_pixel@plt>
movsbl -0x100(%rbp),%eax
cmp    $0x6c,%eax
je     1437 <main+0x237>
movsbl -0x100(%rbp),%eax
cmp    $0x4c,%eax
jne    1461 <main+0x261>
mov    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x128(%rbp),%rcx
mov    -0x10c(%rbp),%r8d
mov    $0x0,%al
call   10d0 <low_pixel@plt>
movsbl -0x100(%rbp),%eax
cmp    $0x6d,%eax
je     1481 <main+0x281>
movsbl -0x100(%rbp),%eax
cmp    $0x4d,%eax
jne    14ab <main+0x2ab>
mov    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    -0x120(%rbp),%rdx
mov    -0x128(%rbp),%rcx
mov    -0x10c(%rbp),%r8d
mov    $0x0,%al
call   1090 <median_filter@plt>
jmp    14b0 <main+0x2b0>
lea    -0xb0(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    $0x0,%al
call   1060 <write_image_array@plt>
mov    -0x130(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x0,%al
call   1120 <free_image_array@plt>
mov    -0x138(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    $0x0,%al
call   1120 <free_image_array@plt>
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %edi,%r12d
lea    -0x7(%r12),%eax
cmp    $0xfffffffd,%eax
jbe    140a <main+0x1fa>
mov    %rsi,%r13
mov    0x8(%rsi),%rsi
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    0x10(%r13),%rsi
lea    0x90(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <does_not_exist@plt>
test   %eax,%eax
jne    141d <main+0x20d>
lea    0xe0(%rsp),%rbx
lea    0x90(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <create_image_file@plt>
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <get_image_size@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1110 <get_bitsperpixel@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1120 <allocate_image_array@plt>
movslq %eax,%r14
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1120 <allocate_image_array@plt>
movslq %eax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10c0 <read_image_array@plt>
cmp    $0x5,%r12d
je     1338 <main+0x128>
cmp    $0x6,%r12d
jne    13c7 <main+0x1b7>
mov    0x20(%r13),%rsi
lea    0x20(%rsp),%r12
mov    %r12,%rdi
call   1040 <strcpy@plt>
mov    0x28(%r13),%rdi
xor    %eax,%eax
call   10f0 <atoi@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
lea    0x70(%rsp),%r9
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
push   %r12
push   %rbx
call   1090 <filter_image@plt>
add    $0x10,%rsp
jmp    13c7 <main+0x1b7>
mov    0x18(%r13),%rsi
lea    0x20(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x20(%r13),%rdi
xor    %eax,%eax
call   10f0 <atoi@plt>
mov    %eax,%ebx
mov    0x20(%rsp),%al
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x48,%cl
jne    137f <main+0x16f>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%r8d
xor    %eax,%eax
call   10d0 <high_pixel@plt>
mov    0x20(%rsp),%al
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x4c,%cl
jne    13a7 <main+0x197>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%r8d
xor    %eax,%eax
call   10e0 <low_pixel@plt>
mov    0x20(%rsp),%al
and    $0xdf,%al
cmp    $0x4d,%al
jne    13c7 <main+0x1b7>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%r8d
xor    %eax,%eax
call   10a0 <median_filter@plt>
lea    0x90(%rsp),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <write_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1130 <free_image_array@plt>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1130 <free_image_array@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xc13(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xbdc(%rip),%rdi
lea    0xe0(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [497 x i8] c"\0Ausage 1: mfilter in-image out-image g Low-High type\0A OR\0Ausage 2: mfilter in-image out-image High-Low-Median size\0A h - high pixel\0A l - low pixel\0A m - median pixel\0A \0A Using the General type requires entering \0A the type per the following table\0A L - 6\0A L - 9\0A L - 10\0A L - 16\0A L - 32\0A H - 1\0A H - 2\0A H - 3\0A Using the High-Low-Median type requirs entering \0A the size of the filtered area 3 (3x3) 5, 7, 9, etc.\0A\00"
@.str.1 = [36 x i8] c"\0AERROR input file %s does not exist\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 i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i16**
%17 = alloca i16**
%18 = alloca [3 x [3 x 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 %24, label %21
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 6
br i1 %23, label %24, label %26
24: ; preds = %21, %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([497 x i8], [497 x i8]* @.str, i64 0, i64 0))
unreachable
26: ; preds = %21
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i8* @strcpy(i8* %27, i8* %30)
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i8* @strcpy(i8* %32, i8* %35)
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @does_not_exist to i32 (i8*, ...)*)(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %26
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %41)
unreachable
43: ; preds = %26
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%46 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %44, i8* %45)
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%48 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %47, i64* %14, i64* %15)
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%50 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @get_bitsperpixel to i32 (i8*, i64*, ...)*)(i8* %49, i64* %13)
%51 = load i64, i64* %14
%52 = load i64, i64* %15
%53 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %51, i64 %52)
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to i16**
store i16** %55, i16*** %16
%56 = load i64, i64* %14
%57 = load i64, i64* %15
%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**
store i16** %60, i16*** %17
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%62 = load i16**, i16*** %16
%63 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %61, i16** %62)
%64 = load i32, i32* %4
%65 = icmp eq i32 %64, 6
br i1 %65, label %66, label %85
66: ; preds = %43
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 4
%70 = load i8*, i8** %69
%71 = call i8* @strcpy(i8* %67, i8* %70)
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 5
%74 = load i8*, i8** %73
%75 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %74)
store i32 %75, i32* %12
%76 = load i16**, i16*** %16
%77 = load i16**, i16*** %17
%78 = load i64, i64* %14
%79 = load i64, i64* %15
%80 = load i64, i64* %13
%81 = getelementptr inbounds [3 x [3 x i16]], [3 x [3 x i16]]* %18, i64 0, i64 0
%82 = load i32, i32* %12
%83 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%84 = call i32 (i16**, i16**, i64, i64, i64, [3 x i16]*, i32, i8*, ...) bitcast (i32 (...)* @filter_image to i32 (i16**, i16**, i64, i64, i64, [3 x i16]*, i32, i8*, ...)*)(i16** %76, i16** %77, i64 %78, i64 %79, i64 %80, [3 x i16]* %81, i32 %82, i8* %83)
br label %85
85: ; preds = %66, %43
%86 = load i32, i32* %4
%87 = icmp eq i32 %86, 5
br i1 %87, label %88, label %149
88: ; preds = %85
%89 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 3
%92 = load i8*, i8** %91
%93 = call i8* @strcpy(i8* %89, i8* %92)
%94 = load i8**, i8*** %5
%95 = getelementptr inbounds i8*, i8** %94, i64 4
%96 = load i8*, i8** %95
%97 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %96)
store i32 %97, i32* %11
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 104
br i1 %101, label %107, label %102
102: ; preds = %88
%103 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 72
br i1 %106, label %107, label %114
107: ; preds = %102, %88
%108 = load i16**, i16*** %16
%109 = load i16**, i16*** %17
%110 = load i64, i64* %14
%111 = load i64, i64* %15
%112 = load i32, i32* %11
%113 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @high_pixel to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %108, i16** %109, i64 %110, i64 %111, i32 %112)
br label %114
114: ; preds = %107, %102
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 108
br i1 %118, label %124, label %119
119: ; preds = %114
%120 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 76
br i1 %123, label %124, label %131
124: ; preds = %119, %114
%125 = load i16**, i16*** %16
%126 = load i16**, i16*** %17
%127 = load i64, i64* %14
%128 = load i64, i64* %15
%129 = load i32, i32* %11
%130 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @low_pixel to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %125, i16** %126, i64 %127, i64 %128, i32 %129)
br label %131
131: ; preds = %124, %119
%132 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 109
br i1 %135, label %141, label %136
136: ; preds = %131
%137 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 77
br i1 %140, label %141, label %148
141: ; preds = %136, %131
%142 = load i16**, i16*** %16
%143 = load i16**, i16*** %17
%144 = load i64, i64* %14
%145 = load i64, i64* %15
%146 = load i32, i32* %11
%147 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @median_filter to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %142, i16** %143, i64 %144, i64 %145, i32 %146)
br label %148
148: ; preds = %141, %136
br label %149
149: ; preds = %148, %85
%150 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%151 = load i16**, i16*** %17
%152 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %150, i16** %151)
%153 = load i16**, i16*** %16
%154 = load i64, i64* %14
%155 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %153, i64 %154)
%156 = load i16**, i16*** %17
%157 = load i64, i64* %14
%158 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %156, i64 %157)
%159 = load i32, i32* %3
ret i32 %159
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"\0AERROR input file %s does not exist\00"
@str = [496 x i8] c"\0Ausage 1: mfilter in-image out-image g Low-High type\0A OR\0Ausage 2: mfilter in-image out-image High-Low-Median size\0A h - high pixel\0A l - low pixel\0A m - median pixel\0A \0A Using the General type requires entering \0A the type per the following table\0A L - 6\0A L - 9\0A L - 10\0A L - 16\0A L - 32\0A H - 1\0A H - 2\0A H - 3\0A Using the High-Low-Median type requirs entering \0A the size of the filtered area 3 (3x3) 5, 7, 9, etc.\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 = alloca [3 x [3 x i16]]
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%13 = bitcast i64* %6 to i8*
%14 = bitcast i64* %7 to i8*
%15 = bitcast i64* %8 to i8*
%16 = bitcast [3 x [3 x i16]]* %9 to i8*
%17 = add i32 %0, -7
%18 = icmp ult i32 %17, -2
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([496 x i8], [496 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i8* @strcpy(i8* %10, i8* dereferenceable(1) %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%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* %10)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %10)
unreachable
32: ; preds = %21
%33 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @create_image_file to i32 (i8*, i8*, ...)*)(i8* %10, i8* %11)
%34 = call i32 (i8*, i64*, i64*, ...) bitcast (i32 (...)* @get_image_size to i32 (i8*, i64*, i64*, ...)*)(i8* %10, i64* %7, i64* %8)
%35 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @get_bitsperpixel to i32 (i8*, i64*, ...)*)(i8* %10, i64* %6)
%36 = load i64, i64* %7
%37 = load i64, i64* %8
%38 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %36, i64 %37)
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i16**
%41 = load i64, i64* %7
%42 = load i64, i64* %8
%43 = call i32 (i64, i64, ...) bitcast (i32 (...)* @allocate_image_array to i32 (i64, i64, ...)*)(i64 %41, i64 %42)
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i16**
%46 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @read_image_array to i32 (i8*, i16**, ...)*)(i8* %10, i16** %40)
switch i32 %0, label %91 [
i32 6, label %47
i32 5, label %59
]
47: ; preds = %32
%48 = getelementptr inbounds i8*, i8** %1, i64 4
%49 = load i8*, i8** %48
%50 = call i8* @strcpy(i8* %12, i8* dereferenceable(1) %49)
%51 = getelementptr inbounds i8*, i8** %1, i64 5
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %52)
%54 = load i64, i64* %7
%55 = load i64, i64* %8
%56 = load i64, i64* %6
%57 = getelementptr inbounds [3 x [3 x i16]], [3 x [3 x i16]]* %9, i64 0, i64 0
%58 = call i32 (i16**, i16**, i64, i64, i64, [3 x i16]*, i32, i8*, ...) bitcast (i32 (...)* @filter_image to i32 (i16**, i16**, i64, i64, i64, [3 x i16]*, i32, i8*, ...)*)(i16** %40, i16** %45, i64 %54, i64 %55, i64 %56, [3 x i16]* %57, i32 %53, i8* %12)
br label %91
59: ; preds = %32
%60 = getelementptr inbounds i8*, i8** %1, i64 3
%61 = load i8*, i8** %60
%62 = call i8* @strcpy(i8* %12, i8* dereferenceable(1) %61)
%63 = getelementptr inbounds i8*, i8** %1, i64 4
%64 = load i8*, i8** %63
%65 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %64)
%66 = load i8, i8* %12
%67 = and i8 %66, -33
%68 = icmp eq i8 %67, 72
br i1 %68, label %69, label %74
69: ; preds = %59
%70 = load i64, i64* %7
%71 = load i64, i64* %8
%72 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @high_pixel to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %40, i16** %45, i64 %70, i64 %71, i32 %65)
%73 = load i8, i8* %12
br label %74
74: ; preds = %59, %69
%75 = phi i8 [ %66, %59 ], [ %73, %69 ]
%76 = and i8 %75, -33
%77 = icmp eq i8 %76, 76
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = load i64, i64* %7
%80 = load i64, i64* %8
%81 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @low_pixel to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %40, i16** %45, i64 %79, i64 %80, i32 %65)
%82 = load i8, i8* %12
br label %83
83: ; preds = %74, %78
%84 = phi i8 [ %75, %74 ], [ %82, %78 ]
%85 = and i8 %84, -33
%86 = icmp eq i8 %85, 77
br i1 %86, label %87, label %91
87: ; preds = %83
%88 = load i64, i64* %7
%89 = load i64, i64* %8
%90 = call i32 (i16**, i16**, i64, i64, i32, ...) bitcast (i32 (...)* @median_filter to i32 (i16**, i16**, i64, i64, i32, ...)*)(i16** %40, i16** %45, i64 %88, i64 %89, i32 %65)
br label %91
91: ; preds = %47, %32, %87, %83
%92 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_image_array to i32 (i8*, i16**, ...)*)(i8* %11, i16** %45)
%93 = load i64, i64* %7
%94 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %40, i64 %93)
%95 = load i64, i64* %7
%96 = call i32 (i16**, i64, ...) bitcast (i32 (...)* @free_image_array to i32 (i16**, i64, ...)*)(i16** %45, i64 %95)
ret i32 0
}