#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atleast(unsigned char *, int, int, int);
int atoi(char *);
int /*<<< orphan*/ average(unsigned char *, unsigned char *, int, int);
int /*<<< orphan*/ blur(unsigned char *, int, int);
int /*<<< orphan*/ brightness(unsigned char *, int, int, int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ clear(unsigned char *, int, int, int);
int /*<<< orphan*/ contrast(unsigned char *, int, int, int);
int /*<<< orphan*/ edge(unsigned char *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
unsigned char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ grow(unsigned char *, unsigned char *, int, int);
int /*<<< orphan*/ invert(unsigned char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(unsigned char, int /*<<< orphan*/ *);
int /*<<< orphan*/ shrink(unsigned char *, unsigned char *, int, int);
int main(int argc, char *argv[]) {
  int value = 0;
  int choice = 0;
  int i, j;
  char information[54];
  int width, height;
  unsigned char *image1, *image2;
  char outfilename[512];
  FILE *input, *output;
  if (argc < 3) {
    printf("usage: ./program op_num input1.bmp [value|input2.bmp]\n");
    return 1;
  }
  choice = atoi(argv[1]);
  input = fopen(argv[2], "rb");
  fread(information, 1, 54, input);
  width = *(int *)(information + 18);
  height = *(int *)(information + 22);
  image1 = (unsigned char *)calloc(width * height, 1);
  unsigned char blue, green, red;
  for (i = 0; i < height; i++)
    for (j = 0; j < width; j++) {
      blue = getc(input);
      green = getc(input);
      red = getc(input);
      image1[i * width + j] = (blue + green + red) / 3;
    }
  fclose(input);
  if (choice == 1) {
    if (argc < 4) {
      printf("usage: ./program 1 input1.bmp value\n");
      return 1;
    }
    value = atoi(argv[3]);
    if (value < -255 || value > 255) {
      printf("value must be in [-255,255] for this operation\n");
      return 1;
    }
    brightness(image1, width, height, value);
  } else if (choice == 2) {
    if (argc < 4) {
      printf("usage: ./program 2 input1.bmp value\n");
      return 1;
    }
    value = atoi(argv[3]);
    if (value < 0 || value > 255) {
      printf("value must be in [0,255] for this operation\n");
      return 1;
    }
    contrast(image1, width, height, value);
  } else if (choice == 3) {
    if (argc < 4) {
      printf("usage: ./program 3 input1.bmp input2.bmp\n");
      return 1;
    }
    input = fopen(argv[3], "rb");
    char information[54];
    fread(information, 1, 54, input);
    int width2 = *(int *)(information + 18);
    int height2 = *(int *)(information + 22);
    if (width2 != width || height2 != height) {
      printf("sizes are not compatible\n");
      return 1;
    }
    image2 = (unsigned char *)calloc(width * height, 1);
    for (i = 0; i < height; i++)
      for (j = 0; j < width; j++) {
        blue = getc(input);
        green = getc(input);
        red = getc(input);
        image2[i * width + j] = (blue + green + red) / 3;
      }
    fclose(input);
    average(image1, image2, width, height);
  } else if (choice == 4) {
    image2 = (unsigned char *)calloc(width * height * 4, 1);
    grow(image1, image2, width, height);
    width *= 2;
    height *= 2;
    free(image1);
    image1 = image2;
  } else if (choice == 5) {
    image2 = (unsigned char *)calloc(width * height / 4, 1);
    shrink(image1, image2, width, height);
    width /= 2;
    height /= 2;
    free(image1);
    image1 = image2;
  } else if (choice == 6) {
    blur(image1, width, height);
  } else if (choice == 7) {
    invert(image1, width, height);
  } else if (choice == 8) {
    edge(image1, width, height);
  } else if (choice == 9) {
    if (argc < 4) {
      printf("usage: ./program 9 input1.bmp value\n");
      return 1;
    }
    value = atoi(argv[3]);
    if (value < 0 || value > 255) {
      printf("value must be in [0,255] for this operation\n");
      return 1;
    }
    printf("%d pixels above or equal to %d\n",
           atleast(image1, width, height, value), value);
  } else if (choice == 10) {
    if (argc < 4) {
      printf("usage: ./program 10 input1.bmp value\n");
      return 1;
    }
    value = atoi(argv[3]);
    if (value < 0 || value > 255) {
      printf("value must be in [0,255] for this operation\n");
      return 1;
    }
    clear(image1, width, height, value);
  } else {
    printf("op_num must be in [1,10]\n");
    return 1;
  }
  if (choice != 9) {
    outfilename[0] = 'o';
    outfilename[1] = 'u';
    outfilename[2] = 't';
    outfilename[3] = '_';
    for (i = 0; argv[2][i] != '\0'; i++)
      outfilename[i + 4] = argv[2][i];
    outfilename[i + 4] = '\0';
    output = fopen(outfilename, "wb");
    *(int *)(information + 18) = width;
    *(int *)(information + 22) = height;
    fwrite(information, 1, 54, output);
    for (i = 0; i < height; i++)
      for (j = 0; j < width; j++) {
        putc(image1[i * width + j], output);
        putc(image1[i * width + j], output);
        putc(image1[i * width + j], output);
      }
    fclose(output);
  }
  free(image1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    128b <main+0x4b>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd8d(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x288(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x288(%rbp),%rcx
mov    $0x1,%esi
mov    $0x36,%edx
call   1060 <fread@plt>
mov    -0x4e(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x4a(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%edi
imul   -0x68(%rbp),%edi
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    13a5 <main+0x165>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1392 <main+0x152>
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x291(%rbp)
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x292(%rbp)
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x293(%rbp)
movzbl -0x291(%rbp),%eax
movzbl -0x292(%rbp),%ecx
add    %ecx,%eax
movzbl -0x293(%rbp),%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %al,%dl
mov    -0x70(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x64(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    130b <main+0xcb>
jmp    1397 <main+0x157>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f8 <main+0xb8>
mov    -0x288(%rbp),%rdi
call   1080 <fclose@plt>
cmpl   $0x1,-0x18(%rbp)
jne    143a <main+0x1fa>
cmpl   $0x4,-0x8(%rbp)
jge    13df <main+0x19f>
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffff01,-0x14(%rbp)
jl     1409 <main+0x1c9>
cmpl   $0xff,-0x14(%rbp)
jle    1423 <main+0x1e3>
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   10a0 <brightness@plt>
jmp    18ee <main+0x6ae>
cmpl   $0x2,-0x18(%rbp)
jne    14c0 <main+0x280>
cmpl   $0x4,-0x8(%rbp)
jge    1468 <main+0x228>
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     148f <main+0x24f>
cmpl   $0xff,-0x14(%rbp)
jle    14a9 <main+0x269>
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1110 <contrast@plt>
jmp    18e9 <main+0x6a9>
cmpl   $0x3,-0x18(%rbp)
jne    1663 <main+0x423>
cmpl   $0x4,-0x8(%rbp)
jge    14ee <main+0x2ae>
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xb3a(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x288(%rbp)
lea    -0x2d0(%rbp),%rdi
mov    -0x288(%rbp),%rcx
mov    $0x1,%esi
mov    $0x36,%edx
call   1060 <fread@plt>
mov    -0x2be(%rbp),%eax
mov    %eax,-0x2d4(%rbp)
mov    -0x2ba(%rbp),%eax
mov    %eax,-0x2d8(%rbp)
mov    -0x2d4(%rbp),%eax
cmp    -0x64(%rbp),%eax
jne    155c <main+0x31c>
mov    -0x2d8(%rbp),%eax
cmp    -0x68(%rbp),%eax
je     1576 <main+0x336>
lea    0xba8(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x64(%rbp),%edi
imul   -0x68(%rbp),%edi
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    163f <main+0x3ff>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    162c <main+0x3ec>
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x291(%rbp)
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x292(%rbp)
mov    -0x288(%rbp),%rdi
call   1160 <getc@plt>
mov    %al,-0x293(%rbp)
movzbl -0x291(%rbp),%eax
movzbl -0x292(%rbp),%ecx
add    %ecx,%eax
movzbl -0x293(%rbp),%ecx
add    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %al,%dl
mov    -0x78(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x64(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    15a5 <main+0x365>
jmp    1631 <main+0x3f1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1592 <main+0x352>
mov    -0x288(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x64(%rbp),%edx
mov    -0x68(%rbp),%ecx
call   10f0 <average@plt>
jmp    18e4 <main+0x6a4>
cmpl   $0x4,-0x18(%rbp)
jne    16c0 <main+0x480>
mov    -0x64(%rbp),%edi
imul   -0x68(%rbp),%edi
shl    $0x2,%edi
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x64(%rbp),%edx
mov    -0x68(%rbp),%ecx
call   1070 <grow@plt>
mov    -0x64(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    18df <main+0x69f>
cmpl   $0x5,-0x18(%rbp)
jne    172e <main+0x4ee>
mov    -0x64(%rbp),%eax
imul   -0x68(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    $0x1,%esi
call   10d0 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x64(%rbp),%edx
mov    -0x68(%rbp),%ecx
call   10b0 <shrink@plt>
mov    -0x64(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x68(%rbp)
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    18da <main+0x69a>
cmpl   $0x6,-0x18(%rbp)
jne    174c <main+0x50c>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
call   10c0 <blur@plt>
jmp    18d5 <main+0x695>
cmpl   $0x7,-0x18(%rbp)
jne    176a <main+0x52a>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
call   1040 <invert@plt>
jmp    18d0 <main+0x690>
cmpl   $0x8,-0x18(%rbp)
jne    1788 <main+0x548>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
call   1100 <edge@plt>
jmp    18cb <main+0x68b>
cmpl   $0x9,-0x18(%rbp)
jne    1821 <main+0x5e1>
cmpl   $0x4,-0x8(%rbp)
jge    17b6 <main+0x576>
lea    0x982(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     17dd <main+0x59d>
cmpl   $0xff,-0x14(%rbp)
jle    17f7 <main+0x5b7>
lea    0x8d0(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1050 <atleast@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0x935(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    18c6 <main+0x686>
cmpl   $0xa,-0x18(%rbp)
jne    18a7 <main+0x667>
cmpl   $0x4,-0x8(%rbp)
jge    184f <main+0x60f>
lea    0x92e(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1876 <main+0x636>
cmpl   $0xff,-0x14(%rbp)
jle    1890 <main+0x650>
lea    0x837(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1150 <clear@plt>
jmp    18c1 <main+0x681>
lea    0x8e2(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1a7c <main+0x83c>
jmp    18c6 <main+0x686>
jmp    18cb <main+0x68b>
jmp    18d0 <main+0x690>
jmp    18d5 <main+0x695>
jmp    18da <main+0x69a>
jmp    18df <main+0x69f>
jmp    18e4 <main+0x6a4>
jmp    18e9 <main+0x6a9>
jmp    18ee <main+0x6ae>
cmpl   $0x9,-0x18(%rbp)
je     1a6c <main+0x82c>
movb   $0x6f,-0x280(%rbp)
movb   $0x75,-0x27f(%rbp)
movb   $0x74,-0x27e(%rbp)
movb   $0x5f,-0x27d(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1960 <main+0x720>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
cltq
mov    %cl,-0x280(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    191b <main+0x6db>
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
cltq
movb   $0x0,-0x280(%rbp,%rax,1)
lea    -0x280(%rbp),%rdi
lea    0x82c(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x290(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x4e(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x4a(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x290(%rbp),%rcx
mov    $0x1,%esi
mov    $0x36,%edx
call   1140 <fwrite@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    1a60 <main+0x820>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1a4d <main+0x80d>
mov    -0x70(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x64(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0x290(%rbp),%rsi
movzbl %al,%edi
call   10e0 <putc@plt>
mov    -0x70(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x64(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0x290(%rbp),%rsi
movzbl %al,%edi
call   10e0 <putc@plt>
mov    -0x70(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x64(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0x290(%rbp),%rsi
movzbl %al,%edi
call   10e0 <putc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    19ca <main+0x78a>
jmp    1a52 <main+0x812>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    19b7 <main+0x777>
mov    -0x290(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x288,%rsp
cmp    $0x2,%edi
jg     127d <main+0x2d>
lea    0xf28(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%r12d
jmp    15f6 <main+0x3a6>
mov    %rsi,%rbx
mov    %edi,0x14(%rsp)
mov    0x8(%rsi),%rdi
call   1140 <atoi@plt>
mov    %rax,0x28(%rsp)
mov    %rbx,0x8(%rsp)
mov    0x10(%rbx),%rdi
lea    0xd86(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,%r12
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x36,%edx
mov    %rax,%rcx
call   1070 <fread@plt>
mov    0x52(%rsp),%r13d
mov    0x56(%rsp),%ebx
movslq %r13d,%rax
mov    %rax,0x38(%rsp)
mov    %ebx,%edi
imul   %r13d,%edi
mov    %rdi,0x30(%rsp)
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,(%rsp)
test   %ebx,%ebx
mov    %r13,%r15
mov    %rbx,0x18(%rsp)
jle    1387 <main+0x137>
xor    %eax,%eax
mov    (%rsp),%r14
jmp    1328 <main+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x38(%rsp),%r14
mov    0x18(%rsp),%rbx
cmp    %rbx,%rax
je     1387 <main+0x137>
mov    %rax,0x20(%rsp)
test   %r13d,%r13d
jle    1310 <main+0xc0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1170 <getc@plt>
mov    %eax,%r13d
mov    %r12,%rdi
call   1170 <getc@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1170 <getc@plt>
movzbl %r13b,%ecx
mov    %r15,%r13
movzbl %bpl,%edx
add    %ecx,%edx
movzbl %al,%eax
add    %edx,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1340 <main+0xf0>
jmp    1310 <main+0xc0>
mov    %r12,%rdi
call   1090 <fclose@plt>
mov    0x28(%rsp),%rcx
add    $0xffffffff,%ecx
cmp    $0x9,%ecx
ja     13c3 <main+0x173>
lea    0xc5d(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cmpl   $0x3,0x14(%rsp)
jg     1639 <main+0x3e9>
lea    0xdb3(%rip),%rdi
jmp    126d <main+0x1d>
lea    0xc84(%rip),%rdi
jmp    126d <main+0x1d>
cmpl   $0x3,0x14(%rsp)
jg     1665 <main+0x415>
lea    0xd3d(%rip),%rdi
jmp    126d <main+0x1d>
cmpl   $0x3,0x14(%rsp)
jg     1693 <main+0x443>
lea    0xcd1(%rip),%rdi
jmp    126d <main+0x1d>
mov    0x30(%rsp),%rdi
shl    $0x2,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,%rbp
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r13d,%edx
mov    0x18(%rsp),%rcx
call   1080 <grow@plt>
add    %r13d,%r13d
mov    0x18(%rsp),%rax
add    %eax,%eax
mov    %rax,0x18(%rsp)
mov    %rbx,%rdi
mov    0x18(%rsp),%rbx
call   1030 <free@plt>
mov    %rbp,(%rsp)
jmp    14da <main+0x28a>
mov    0x30(%rsp),%rax
lea    0x3(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0x2,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,%r14
mov    (%rsp),%r15
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   10c0 <shrink@plt>
mov    %rbx,%rax
mov    %r13d,%ebx
shr    $0x1f,%ebx
add    %r13d,%ebx
sar    %ebx
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,(%rsp)
mov    %ebp,%eax
mov    %ebx,%r13d
mov    %rax,%rbx
jmp    14da <main+0x28a>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   10d0 <blur@plt>
jmp    14da <main+0x28a>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1040 <invert@plt>
jmp    14da <main+0x28a>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1110 <edge@plt>
mov    0x8(%rsp),%rbp
movl   $0x5f74756f,0x80(%rsp)
6f 75 74 5f
mov    0x10(%rbp),%rax
mov    (%rax),%cl
test   %cl,%cl
je     1518 <main+0x2c8>
mov    $0x4,%edx
nopl   0x0(%rax)
mov    %cl,0x80(%rsp,%rdx,1)
movzbl -0x3(%rax,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1500 <main+0x2b0>
mov    %edx,%eax
jmp    151d <main+0x2cd>
mov    $0x4,%eax
movb   $0x0,0x80(%rsp,%rax,1)
lea    0xb1f(%rip),%rsi
lea    0x80(%rsp),%rdi
call   1130 <fopen@plt>
mov    %rax,%rbp
mov    %r13,0x20(%rsp)
mov    %r13d,0x52(%rsp)
mov    %ebx,0x56(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x36,%edx
mov    %rax,%rcx
call   1150 <fwrite@plt>
test   %ebx,%ebx
jle    15e2 <main+0x392>
mov    0x20(%rsp),%rax
movslq %eax,%rcx
mov    %rcx,0x18(%rsp)
mov    %ebx,%r15d
mov    %eax,%r13d
xor    %r12d,%r12d
mov    (%rsp),%rbx
jmp    159e <main+0x34e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
add    0x18(%rsp),%rbx
cmp    %r15,%r12
je     15e2 <main+0x392>
cmpl   $0x0,0x20(%rsp)
jle    1590 <main+0x340>
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r14,1),%edi
mov    %rbp,%rsi
call   10f0 <putc@plt>
movzbl (%rbx,%r14,1),%edi
mov    %rbp,%rsi
call   10f0 <putc@plt>
movzbl (%rbx,%r14,1),%edi
mov    %rbp,%rsi
call   10f0 <putc@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    15b0 <main+0x360>
jmp    1590 <main+0x340>
mov    %rbp,%rdi
call   1090 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x288,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmpl   $0x3,0x14(%rsp)
jg     1788 <main+0x538>
lea    0xa6f(%rip),%rdi
jmp    126d <main+0x1d>
cmpl   $0x3,0x14(%rsp)
jg     17c6 <main+0x576>
lea    0xa33(%rip),%rdi
jmp    126d <main+0x1d>
mov    0x8(%rsp),%rbp
mov    0x18(%rbp),%rdi
call   1140 <atoi@plt>
lea    -0x100(%rax),%ecx
cmp    $0xfffffe00,%ecx
ja     17f8 <main+0x5a8>
lea    0xae2(%rip),%rdi
jmp    126d <main+0x1d>
mov    0x8(%rsp),%rbp
mov    0x18(%rbp),%rdi
call   1140 <atoi@plt>
cmp    $0x100,%eax
jae    17db <main+0x58b>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1120 <contrast@plt>
jmp    14df <main+0x28f>
mov    0x8(%rsp),%rax
mov    0x18(%rax),%rdi
lea    0x985(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,%rbp
lea    0x80(%rsp),%rdi
mov    $0x1,%r12d
mov    $0x1,%esi
mov    $0x36,%edx
mov    %rax,%rcx
call   1070 <fread@plt>
cmp    %r13d,0x92(%rsp)
jne    17e7 <main+0x597>
cmp    %ebx,0x96(%rsp)
jne    17e7 <main+0x597>
mov    0x30(%rsp),%rdi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,0x28(%rsp)
test   %ebx,%ebx
jle    1822 <main+0x5d2>
xor    %eax,%eax
mov    0x28(%rsp),%r14
jmp    1727 <main+0x4d7>
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x38(%rsp),%r14
mov    0x18(%rsp),%rbx
cmp    %rbx,%rax
je     1822 <main+0x5d2>
mov    %rax,0x20(%rsp)
test   %r13d,%r13d
jle    170b <main+0x4bb>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   1170 <getc@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1170 <getc@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1170 <getc@plt>
movzbl %r12b,%ecx
movzbl %r13b,%edx
mov    %r15,%r13
add    %ecx,%edx
movzbl %al,%eax
add    %edx,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1740 <main+0x4f0>
jmp    170b <main+0x4bb>
mov    0x8(%rsp),%rax
mov    0x18(%rax),%rdi
call   1140 <atoi@plt>
cmp    $0x100,%eax
jae    17db <main+0x58b>
mov    %eax,%ebp
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1050 <atleast@plt>
lea    0x875(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    15ea <main+0x39a>
mov    0x8(%rsp),%rbp
mov    0x18(%rbp),%rdi
call   1140 <atoi@plt>
cmp    $0x100,%eax
jb     180d <main+0x5bd>
lea    0x910(%rip),%rdi
jmp    126d <main+0x1d>
lea    0x8c2(%rip),%rdi
call   1060 <puts@plt>
jmp    15f6 <main+0x3a6>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   10b0 <brightness@plt>
jmp    14df <main+0x28f>
mov    (%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1160 <clear@plt>
jmp    14df <main+0x28f>
mov    %rbp,%rdi
call   1090 <fclose@plt>
mov    (%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1100 <average@plt>
jmp    14da <main+0x28a>

LLVM IR (-O0):
@.str = [55 x i8] c"usage: ./program op_num input1.bmp [value|input2.bmp]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [37 x i8] c"usage: ./program 1 input1.bmp value\0A\00"
@.str.3 = [48 x i8] c"value must be in [-255,255] for this operation\0A\00"
@.str.4 = [37 x i8] c"usage: ./program 2 input1.bmp value\0A\00"
@.str.5 = [45 x i8] c"value must be in [0,255] for this operation\0A\00"
@.str.6 = [42 x i8] c"usage: ./program 3 input1.bmp input2.bmp\0A\00"
@.str.7 = [26 x i8] c"sizes are not compatible\0A\00"
@.str.8 = [37 x i8] c"usage: ./program 9 input1.bmp value\0A\00"
@.str.9 = [32 x i8] c"%d pixels above or equal to %d\0A\00"
@.str.10 = [38 x i8] c"usage: ./program 10 input1.bmp value\0A\00"
@.str.11 = [26 x i8] c"op_num must be in [1,10]\0A\00"
@.str.12 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [54 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [512 x i8]
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i8
%19 = alloca i8
%20 = alloca i8
%21 = alloca [54 x i8]
%22 = alloca i32
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 3
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %476
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %7
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %16
%37 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%38 = load i32*, i32** %16
%39 = call i32 @fread(i8* %37, i32 1, i32 54, i32* %38)
%40 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%41 = getelementptr inbounds i8, i8* %40, i64 18
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
store i32 %43, i32* %11
%44 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%45 = getelementptr inbounds i8, i8* %44, i64 22
%46 = bitcast i8* %45 to i32*
%47 = load i32, i32* %46
store i32 %47, i32* %12
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = mul nsw i32 %48, %49
%51 = call i64 @calloc(i32 %50, i32 1)
%52 = inttoptr i64 %51 to i8*
store i8* %52, i8** %13
store i32 0, i32* %8
br label %53
53: ; preds = %91, %28
%54 = load i32, i32* %8
%55 = load i32, i32* %12
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %94
57: ; preds = %53
store i32 0, i32* %9
br label %58
58: ; preds = %87, %57
%59 = load i32, i32* %9
%60 = load i32, i32* %11
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %90
62: ; preds = %58
%63 = load i32*, i32** %16
%64 = call zeroext i8 @getc(i32* %63)
store i8 %64, i8* %18
%65 = load i32*, i32** %16
%66 = call zeroext i8 @getc(i32* %65)
store i8 %66, i8* %19
%67 = load i32*, i32** %16
%68 = call zeroext i8 @getc(i32* %67)
store i8 %68, i8* %20
%69 = load i8, i8* %18
%70 = zext i8 %69 to i32
%71 = load i8, i8* %19
%72 = zext i8 %71 to i32
%73 = add nsw i32 %70, %72
%74 = load i8, i8* %20
%75 = zext i8 %74 to i32
%76 = add nsw i32 %73, %75
%77 = sdiv i32 %76, 3
%78 = trunc i32 %77 to i8
%79 = load i8*, i8** %13
%80 = load i32, i32* %8
%81 = load i32, i32* %11
%82 = mul nsw i32 %80, %81
%83 = load i32, i32* %9
%84 = add nsw i32 %82, %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %79, i64 %85
store i8 %78, i8* %86
br label %87
87: ; preds = %62
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
store i32 %89, i32* %9
br label %58
90: ; preds = %58
br label %91
91: ; preds = %90
%92 = load i32, i32* %8
%93 = add nsw i32 %92, 1
store i32 %93, i32* %8
br label %53
94: ; preds = %53
%95 = load i32*, i32** %16
%96 = call i32 @fclose(i32* %95)
%97 = load i32, i32* %7
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %122
99: ; preds = %94
%100 = load i32, i32* %4
%101 = icmp slt i32 %100, 4
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %476
104: ; preds = %99
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 3
%107 = load i8*, i8** %106
%108 = call i32 @atoi(i8* %107)
store i32 %108, i32* %6
%109 = load i32, i32* %6
%110 = icmp slt i32 %109, -255
br i1 %110, label %114, label %111
111: ; preds = %104
%112 = load i32, i32* %6
%113 = icmp sgt i32 %112, 255
br i1 %113, label %114, label %116
114: ; preds = %111, %104
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %476
116: ; preds = %111
%117 = load i8*, i8** %13
%118 = load i32, i32* %11
%119 = load i32, i32* %12
%120 = load i32, i32* %6
%121 = call i32 @brightness(i8* %117, i32 %118, i32 %119, i32 %120)
br label %369
122: ; preds = %94
%123 = load i32, i32* %7
%124 = icmp eq i32 %123, 2
br i1 %124, label %125, label %148
125: ; preds = %122
%126 = load i32, i32* %4
%127 = icmp slt i32 %126, 4
br i1 %127, label %128, label %130
128: ; preds = %125
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %476
130: ; preds = %125
%131 = load i8**, i8*** %5
%132 = getelementptr inbounds i8*, i8** %131, i64 3
%133 = load i8*, i8** %132
%134 = call i32 @atoi(i8* %133)
store i32 %134, i32* %6
%135 = load i32, i32* %6
%136 = icmp slt i32 %135, 0
br i1 %136, label %140, label %137
137: ; preds = %130
%138 = load i32, i32* %6
%139 = icmp sgt i32 %138, 255
br i1 %139, label %140, label %142
140: ; preds = %137, %130
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %476
142: ; preds = %137
%143 = load i8*, i8** %13
%144 = load i32, i32* %11
%145 = load i32, i32* %12
%146 = load i32, i32* %6
%147 = call i32 @contrast(i8* %143, i32 %144, i32 %145, i32 %146)
br label %368
148: ; preds = %122
%149 = load i32, i32* %7
%150 = icmp eq i32 %149, 3
br i1 %150, label %151, label %236
151: ; preds = %148
%152 = load i32, i32* %4
%153 = icmp slt i32 %152, 4
br i1 %153, label %154, label %156
154: ; preds = %151
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %476
156: ; preds = %151
%157 = load i8**, i8*** %5
%158 = getelementptr inbounds i8*, i8** %157, i64 3
%159 = load i8*, i8** %158
%160 = call i32* @fopen(i8* %159, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %160, i32** %16
%161 = getelementptr inbounds [54 x i8], [54 x i8]* %21, i64 0, i64 0
%162 = load i32*, i32** %16
%163 = call i32 @fread(i8* %161, i32 1, i32 54, i32* %162)
%164 = getelementptr inbounds [54 x i8], [54 x i8]* %21, i64 0, i64 0
%165 = getelementptr inbounds i8, i8* %164, i64 18
%166 = bitcast i8* %165 to i32*
%167 = load i32, i32* %166
store i32 %167, i32* %22
%168 = getelementptr inbounds [54 x i8], [54 x i8]* %21, i64 0, i64 0
%169 = getelementptr inbounds i8, i8* %168, i64 22
%170 = bitcast i8* %169 to i32*
%171 = load i32, i32* %170
store i32 %171, i32* %23
%172 = load i32, i32* %22
%173 = load i32, i32* %11
%174 = icmp ne i32 %172, %173
br i1 %174, label %179, label %175
175: ; preds = %156
%176 = load i32, i32* %23
%177 = load i32, i32* %12
%178 = icmp ne i32 %176, %177
br i1 %178, label %179, label %181
179: ; preds = %175, %156
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %476
181: ; preds = %175
%182 = load i32, i32* %11
%183 = load i32, i32* %12
%184 = mul nsw i32 %182, %183
%185 = call i64 @calloc(i32 %184, i32 1)
%186 = inttoptr i64 %185 to i8*
store i8* %186, i8** %14
store i32 0, i32* %8
br label %187
187: ; preds = %225, %181
%188 = load i32, i32* %8
%189 = load i32, i32* %12
%190 = icmp slt i32 %188, %189
br i1 %190, label %191, label %228
191: ; preds = %187
store i32 0, i32* %9
br label %192
192: ; preds = %221, %191
%193 = load i32, i32* %9
%194 = load i32, i32* %11
%195 = icmp slt i32 %193, %194
br i1 %195, label %196, label %224
196: ; preds = %192
%197 = load i32*, i32** %16
%198 = call zeroext i8 @getc(i32* %197)
store i8 %198, i8* %18
%199 = load i32*, i32** %16
%200 = call zeroext i8 @getc(i32* %199)
store i8 %200, i8* %19
%201 = load i32*, i32** %16
%202 = call zeroext i8 @getc(i32* %201)
store i8 %202, i8* %20
%203 = load i8, i8* %18
%204 = zext i8 %203 to i32
%205 = load i8, i8* %19
%206 = zext i8 %205 to i32
%207 = add nsw i32 %204, %206
%208 = load i8, i8* %20
%209 = zext i8 %208 to i32
%210 = add nsw i32 %207, %209
%211 = sdiv i32 %210, 3
%212 = trunc i32 %211 to i8
%213 = load i8*, i8** %14
%214 = load i32, i32* %8
%215 = load i32, i32* %11
%216 = mul nsw i32 %214, %215
%217 = load i32, i32* %9
%218 = add nsw i32 %216, %217
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %213, i64 %219
store i8 %212, i8* %220
br label %221
221: ; preds = %196
%222 = load i32, i32* %9
%223 = add nsw i32 %222, 1
store i32 %223, i32* %9
br label %192
224: ; preds = %192
br label %225
225: ; preds = %224
%226 = load i32, i32* %8
%227 = add nsw i32 %226, 1
store i32 %227, i32* %8
br label %187
228: ; preds = %187
%229 = load i32*, i32** %16
%230 = call i32 @fclose(i32* %229)
%231 = load i8*, i8** %13
%232 = load i8*, i8** %14
%233 = load i32, i32* %11
%234 = load i32, i32* %12
%235 = call i32 @average(i8* %231, i8* %232, i32 %233, i32 %234)
br label %367
236: ; preds = %148
%237 = load i32, i32* %7
%238 = icmp eq i32 %237, 4
br i1 %238, label %239, label %258
239: ; preds = %236
%240 = load i32, i32* %11
%241 = load i32, i32* %12
%242 = mul nsw i32 %240, %241
%243 = mul nsw i32 %242, 4
%244 = call i64 @calloc(i32 %243, i32 1)
%245 = inttoptr i64 %244 to i8*
store i8* %245, i8** %14
%246 = load i8*, i8** %13
%247 = load i8*, i8** %14
%248 = load i32, i32* %11
%249 = load i32, i32* %12
%250 = call i32 @grow(i8* %246, i8* %247, i32 %248, i32 %249)
%251 = load i32, i32* %11
%252 = mul nsw i32 %251, 2
store i32 %252, i32* %11
%253 = load i32, i32* %12
%254 = mul nsw i32 %253, 2
store i32 %254, i32* %12
%255 = load i8*, i8** %13
%256 = call i32 @free(i8* %255)
%257 = load i8*, i8** %14
store i8* %257, i8** %13
br label %366
258: ; preds = %236
%259 = load i32, i32* %7
%260 = icmp eq i32 %259, 5
br i1 %260, label %261, label %280
261: ; preds = %258
%262 = load i32, i32* %11
%263 = load i32, i32* %12
%264 = mul nsw i32 %262, %263
%265 = sdiv i32 %264, 4
%266 = call i64 @calloc(i32 %265, i32 1)
%267 = inttoptr i64 %266 to i8*
store i8* %267, i8** %14
%268 = load i8*, i8** %13
%269 = load i8*, i8** %14
%270 = load i32, i32* %11
%271 = load i32, i32* %12
%272 = call i32 @shrink(i8* %268, i8* %269, i32 %270, i32 %271)
%273 = load i32, i32* %11
%274 = sdiv i32 %273, 2
store i32 %274, i32* %11
%275 = load i32, i32* %12
%276 = sdiv i32 %275, 2
store i32 %276, i32* %12
%277 = load i8*, i8** %13
%278 = call i32 @free(i8* %277)
%279 = load i8*, i8** %14
store i8* %279, i8** %13
br label %365
280: ; preds = %258
%281 = load i32, i32* %7
%282 = icmp eq i32 %281, 6
br i1 %282, label %283, label %288
283: ; preds = %280
%284 = load i8*, i8** %13
%285 = load i32, i32* %11
%286 = load i32, i32* %12
%287 = call i32 @blur(i8* %284, i32 %285, i32 %286)
br label %364
288: ; preds = %280
%289 = load i32, i32* %7
%290 = icmp eq i32 %289, 7
br i1 %290, label %291, label %296
291: ; preds = %288
%292 = load i8*, i8** %13
%293 = load i32, i32* %11
%294 = load i32, i32* %12
%295 = call i32 @invert(i8* %292, i32 %293, i32 %294)
br label %363
296: ; preds = %288
%297 = load i32, i32* %7
%298 = icmp eq i32 %297, 8
br i1 %298, label %299, label %304
299: ; preds = %296
%300 = load i8*, i8** %13
%301 = load i32, i32* %11
%302 = load i32, i32* %12
%303 = call i32 @edge(i8* %300, i32 %301, i32 %302)
br label %362
304: ; preds = %296
%305 = load i32, i32* %7
%306 = icmp eq i32 %305, 9
br i1 %306, label %307, label %332
307: ; preds = %304
%308 = load i32, i32* %4
%309 = icmp slt i32 %308, 4
br i1 %309, label %310, label %312
310: ; preds = %307
%311 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %476
312: ; preds = %307
%313 = load i8**, i8*** %5
%314 = getelementptr inbounds i8*, i8** %313, i64 3
%315 = load i8*, i8** %314
%316 = call i32 @atoi(i8* %315)
store i32 %316, i32* %6
%317 = load i32, i32* %6
%318 = icmp slt i32 %317, 0
br i1 %318, label %322, label %319
319: ; preds = %312
%320 = load i32, i32* %6
%321 = icmp sgt i32 %320, 255
br i1 %321, label %322, label %324
322: ; preds = %319, %312
%323 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %476
324: ; preds = %319
%325 = load i8*, i8** %13
%326 = load i32, i32* %11
%327 = load i32, i32* %12
%328 = load i32, i32* %6
%329 = call i32 @atleast(i8* %325, i32 %326, i32 %327, i32 %328)
%330 = load i32, i32* %6
%331 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i32 %329, i32 %330)
br label %361
332: ; preds = %304
%333 = load i32, i32* %7
%334 = icmp eq i32 %333, 10
br i1 %334, label %335, label %358
335: ; preds = %332
%336 = load i32, i32* %4
%337 = icmp slt i32 %336, 4
br i1 %337, label %338, label %340
338: ; preds = %335
%339 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %476
340: ; preds = %335
%341 = load i8**, i8*** %5
%342 = getelementptr inbounds i8*, i8** %341, i64 3
%343 = load i8*, i8** %342
%344 = call i32 @atoi(i8* %343)
store i32 %344, i32* %6
%345 = load i32, i32* %6
%346 = icmp slt i32 %345, 0
br i1 %346, label %350, label %347
347: ; preds = %340
%348 = load i32, i32* %6
%349 = icmp sgt i32 %348, 255
br i1 %349, label %350, label %352
350: ; preds = %347, %340
%351 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %476
352: ; preds = %347
%353 = load i8*, i8** %13
%354 = load i32, i32* %11
%355 = load i32, i32* %12
%356 = load i32, i32* %6
%357 = call i32 @clear(i8* %353, i32 %354, i32 %355, i32 %356)
br label %360
358: ; preds = %332
%359 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %476
360: ; preds = %352
br label %361
361: ; preds = %360, %324
br label %362
362: ; preds = %361, %299
br label %363
363: ; preds = %362, %291
br label %364
364: ; preds = %363, %283
br label %365
365: ; preds = %364, %261
br label %366
366: ; preds = %365, %239
br label %367
367: ; preds = %366, %228
br label %368
368: ; preds = %367, %142
br label %369
369: ; preds = %368, %116
%370 = load i32, i32* %7
%371 = icmp ne i32 %370, 9
br i1 %371, label %372, label %473
372: ; preds = %369
%373 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 0
store i8 111, i8* %373
%374 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 1
store i8 117, i8* %374
%375 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 2
store i8 116, i8* %375
%376 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 3
store i8 95, i8* %376
store i32 0, i32* %8
br label %377
377: ; preds = %399, %372
%378 = load i8**, i8*** %5
%379 = getelementptr inbounds i8*, i8** %378, i64 2
%380 = load i8*, i8** %379
%381 = load i32, i32* %8
%382 = sext i32 %381 to i64
%383 = getelementptr inbounds i8, i8* %380, i64 %382
%384 = load i8, i8* %383
%385 = sext i8 %384 to i32
%386 = icmp ne i32 %385, 0
br i1 %386, label %387, label %402
387: ; preds = %377
%388 = load i8**, i8*** %5
%389 = getelementptr inbounds i8*, i8** %388, i64 2
%390 = load i8*, i8** %389
%391 = load i32, i32* %8
%392 = sext i32 %391 to i64
%393 = getelementptr inbounds i8, i8* %390, i64 %392
%394 = load i8, i8* %393
%395 = load i32, i32* %8
%396 = add nsw i32 %395, 4
%397 = sext i32 %396 to i64
%398 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 %397
store i8 %394, i8* %398
br label %399
399: ; preds = %387
%400 = load i32, i32* %8
%401 = add nsw i32 %400, 1
store i32 %401, i32* %8
br label %377
402: ; preds = %377
%403 = load i32, i32* %8
%404 = add nsw i32 %403, 4
%405 = sext i32 %404 to i64
%406 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 %405
store i8 0, i8* %406
%407 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 0
%408 = call i32* @fopen(i8* %407, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32* %408, i32** %17
%409 = load i32, i32* %11
%410 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%411 = getelementptr inbounds i8, i8* %410, i64 18
%412 = bitcast i8* %411 to i32*
store i32 %409, i32* %412
%413 = load i32, i32* %12
%414 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%415 = getelementptr inbounds i8, i8* %414, i64 22
%416 = bitcast i8* %415 to i32*
store i32 %413, i32* %416
%417 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%418 = load i32*, i32** %17
%419 = call i32 @fwrite(i8* %417, i32 1, i32 54, i32* %418)
store i32 0, i32* %8
br label %420
420: ; preds = %467, %402
%421 = load i32, i32* %8
%422 = load i32, i32* %12
%423 = icmp slt i32 %421, %422
br i1 %423, label %424, label %470
424: ; preds = %420
store i32 0, i32* %9
br label %425
425: ; preds = %463, %424
%426 = load i32, i32* %9
%427 = load i32, i32* %11
%428 = icmp slt i32 %426, %427
br i1 %428, label %429, label %466
429: ; preds = %425
%430 = load i8*, i8** %13
%431 = load i32, i32* %8
%432 = load i32, i32* %11
%433 = mul nsw i32 %431, %432
%434 = load i32, i32* %9
%435 = add nsw i32 %433, %434
%436 = sext i32 %435 to i64
%437 = getelementptr inbounds i8, i8* %430, i64 %436
%438 = load i8, i8* %437
%439 = load i32*, i32** %17
%440 = call i32 @putc(i8 zeroext %438, i32* %439)
%441 = load i8*, i8** %13
%442 = load i32, i32* %8
%443 = load i32, i32* %11
%444 = mul nsw i32 %442, %443
%445 = load i32, i32* %9
%446 = add nsw i32 %444, %445
%447 = sext i32 %446 to i64
%448 = getelementptr inbounds i8, i8* %441, i64 %447
%449 = load i8, i8* %448
%450 = load i32*, i32** %17
%451 = call i32 @putc(i8 zeroext %449, i32* %450)
%452 = load i8*, i8** %13
%453 = load i32, i32* %8
%454 = load i32, i32* %11
%455 = mul nsw i32 %453, %454
%456 = load i32, i32* %9
%457 = add nsw i32 %455, %456
%458 = sext i32 %457 to i64
%459 = getelementptr inbounds i8, i8* %452, i64 %458
%460 = load i8, i8* %459
%461 = load i32*, i32** %17
%462 = call i32 @putc(i8 zeroext %460, i32* %461)
br label %463
463: ; preds = %429
%464 = load i32, i32* %9
%465 = add nsw i32 %464, 1
store i32 %465, i32* %9
br label %425
466: ; preds = %425
br label %467
467: ; preds = %466
%468 = load i32, i32* %8
%469 = add nsw i32 %468, 1
store i32 %469, i32* %8
br label %420
470: ; preds = %420
%471 = load i32*, i32** %17
%472 = call i32 @fclose(i32* %471)
br label %473
473: ; preds = %470, %369
%474 = load i8*, i8** %13
%475 = call i32 @free(i8* %474)
store i32 0, i32* %3
br label %476
476: ; preds = %473, %358, %350, %338, %322, %310, %179, %154, %140, %128, %114, %102, %26
%477 = load i32, i32* %3
ret i32 %477
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.9 = [32 x i8] c"%d pixels above or equal to %d\0A\00"
@.str.12 = [3 x i8] c"wb\00"
@str = [25 x i8] c"op_num must be in [1,10]\00"
@str.14 = [37 x i8] c"usage: ./program 10 input1.bmp value\00"
@str.16 = [36 x i8] c"usage: ./program 9 input1.bmp value\00"
@str.17 = [25 x i8] c"sizes are not compatible\00"
@str.18 = [41 x i8] c"usage: ./program 3 input1.bmp input2.bmp\00"
@str.19 = [44 x i8] c"value must be in [0,255] for this operation\00"
@str.20 = [36 x i8] c"usage: ./program 2 input1.bmp value\00"
@str.21 = [47 x i8] c"value must be in [-255,255] for this operation\00"
@str.22 = [36 x i8] c"usage: ./program 1 input1.bmp value\00"
@str.23 = [54 x i8] c"usage: ./program op_num input1.bmp [value|input2.bmp]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [54 x i8]
%4 = alloca [512 x i8]
%5 = alloca [54 x i8]
%6 = getelementptr inbounds [54 x i8], [54 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = icmp slt i32 %0, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.23, i64 0, i64 0))
br label %249
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @fread(i8* %6, i32 1, i32 54, i32* %17)
%19 = getelementptr inbounds [54 x i8], [54 x i8]* %3, i64 0, i64 18
%20 = bitcast i8* %19 to i32*
%21 = load i32, i32* %20
%22 = getelementptr inbounds [54 x i8], [54 x i8]* %3, i64 0, i64 22
%23 = bitcast i8* %22 to i32*
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, %21
%26 = tail call i64 @calloc(i32 %25, i32 1)
%27 = inttoptr i64 %26 to i8*
%28 = icmp sgt i32 %24, 0
br i1 %28, label %29, label %57
29: ; preds = %11
%30 = icmp sgt i32 %21, 0
%31 = sext i32 %21 to i64
%32 = zext i32 %24 to i64
%33 = zext i32 %21 to i64
br label %34
34: ; preds = %29, %54
%35 = phi i64 [ 0, %29 ], [ %55, %54 ]
br i1 %30, label %36, label %54
36: ; preds = %34
%37 = mul nsw i64 %35, %31
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ 0, %36 ], [ %52, %38 ]
%40 = tail call zeroext i8 @getc(i32* %17)
%41 = tail call zeroext i8 @getc(i32* %17)
%42 = tail call zeroext i8 @getc(i32* %17)
%43 = zext i8 %40 to i16
%44 = zext i8 %41 to i16
%45 = add nuw nsw i16 %44, %43
%46 = zext i8 %42 to i16
%47 = add nuw nsw i16 %45, %46
%48 = udiv i16 %47, 3
%49 = trunc i16 %48 to i8
%50 = add nsw i64 %39, %37
%51 = getelementptr inbounds i8, i8* %27, i64 %50
store i8 %49, i8* %51
%52 = add nuw nsw i64 %39, 1
%53 = icmp eq i64 %52, %33
br i1 %53, label %54, label %38
54: ; preds = %38, %34
%55 = add nuw nsw i64 %35, 1
%56 = icmp eq i64 %55, %32
br i1 %56, label %57, label %34
57: ; preds = %54, %11
%58 = tail call i32 @fclose(i32* %17)
switch i32 %14, label %187 [
i32 1, label %59
i32 2, label %73
i32 3, label %86
i32 4, label %138
i32 5, label %146
i32 6, label %154
i32 7, label %156
i32 8, label %158
i32 9, label %160
i32 10, label %174
]
59: ; preds = %57
%60 = icmp slt i32 %0, 4
br i1 %60, label %61, label %63
61: ; preds = %59
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.22, i64 0, i64 0))
br label %249
63: ; preds = %59
%64 = getelementptr inbounds i8*, i8** %1, i64 3
%65 = load i8*, i8** %64
%66 = tail call i32 @atoi(i8* %65)
%67 = add i32 %66, -256
%68 = icmp ult i32 %67, -511
br i1 %68, label %69, label %71
69: ; preds = %63
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.21, i64 0, i64 0))
br label %249
71: ; preds = %63
%72 = tail call i32 @brightness(i8* %27, i32 %21, i32 %24, i32 %66)
br label %192
73: ; preds = %57
%74 = icmp slt i32 %0, 4
br i1 %74, label %75, label %77
75: ; preds = %73
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.20, i64 0, i64 0))
br label %249
77: ; preds = %73
%78 = getelementptr inbounds i8*, i8** %1, i64 3
%79 = load i8*, i8** %78
%80 = tail call i32 @atoi(i8* %79)
%81 = icmp ugt i32 %80, 255
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.19, i64 0, i64 0))
br label %249
84: ; preds = %77
%85 = tail call i32 @contrast(i8* %27, i32 %21, i32 %24, i32 %80)
br label %192
86: ; preds = %57
%87 = icmp slt i32 %0, 4
br i1 %87, label %88, label %90
88: ; preds = %86
%89 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.18, i64 0, i64 0))
br label %249
90: ; preds = %86
%91 = getelementptr inbounds i8*, i8** %1, i64 3
%92 = load i8*, i8** %91
%93 = tail call i32* @fopen(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%94 = getelementptr inbounds [54 x i8], [54 x i8]* %5, i64 0, i64 0
%95 = call i32 @fread(i8* %94, i32 1, i32 54, i32* %93)
%96 = getelementptr inbounds [54 x i8], [54 x i8]* %5, i64 0, i64 18
%97 = bitcast i8* %96 to i32*
%98 = load i32, i32* %97
%99 = icmp eq i32 %98, %21
br i1 %99, label %100, label %136
100: ; preds = %90
%101 = getelementptr inbounds [54 x i8], [54 x i8]* %5, i64 0, i64 22
%102 = bitcast i8* %101 to i32*
%103 = load i32, i32* %102
%104 = icmp eq i32 %103, %24
br i1 %104, label %105, label %136
105: ; preds = %100
%106 = tail call i64 @calloc(i32 %25, i32 1)
%107 = inttoptr i64 %106 to i8*
br i1 %28, label %108, label %189
108: ; preds = %105
%109 = icmp sgt i32 %21, 0
%110 = sext i32 %21 to i64
%111 = zext i32 %24 to i64
%112 = zext i32 %21 to i64
br label %113
113: ; preds = %108, %133
%114 = phi i64 [ 0, %108 ], [ %134, %133 ]
br i1 %109, label %115, label %133
115: ; preds = %113
%116 = mul nsw i64 %114, %110
br label %117
117: ; preds = %115, %117
%118 = phi i64 [ 0, %115 ], [ %131, %117 ]
%119 = tail call zeroext i8 @getc(i32* %93)
%120 = tail call zeroext i8 @getc(i32* %93)
%121 = tail call zeroext i8 @getc(i32* %93)
%122 = zext i8 %119 to i16
%123 = zext i8 %120 to i16
%124 = add nuw nsw i16 %123, %122
%125 = zext i8 %121 to i16
%126 = add nuw nsw i16 %124, %125
%127 = udiv i16 %126, 3
%128 = trunc i16 %127 to i8
%129 = add nsw i64 %118, %116
%130 = getelementptr inbounds i8, i8* %107, i64 %129
store i8 %128, i8* %130
%131 = add nuw nsw i64 %118, 1
%132 = icmp eq i64 %131, %112
br i1 %132, label %133, label %117
133: ; preds = %117, %113
%134 = add nuw nsw i64 %114, 1
%135 = icmp eq i64 %134, %111
br i1 %135, label %189, label %113
136: ; preds = %90, %100
%137 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
br label %249
138: ; preds = %57
%139 = shl nsw i32 %25, 2
%140 = tail call i64 @calloc(i32 %139, i32 1)
%141 = inttoptr i64 %140 to i8*
%142 = tail call i32 @grow(i8* %27, i8* %141, i32 %21, i32 %24)
%143 = shl nsw i32 %21, 1
%144 = shl nsw i32 %24, 1
%145 = tail call i32 @free(i8* %27)
br label %192
146: ; preds = %57
%147 = sdiv i32 %25, 4
%148 = tail call i64 @calloc(i32 %147, i32 1)
%149 = inttoptr i64 %148 to i8*
%150 = tail call i32 @shrink(i8* %27, i8* %149, i32 %21, i32 %24)
%151 = sdiv i32 %21, 2
%152 = sdiv i32 %24, 2
%153 = tail call i32 @free(i8* %27)
br label %192
154: ; preds = %57
%155 = tail call i32 @blur(i8* %27, i32 %21, i32 %24)
br label %192
156: ; preds = %57
%157 = tail call i32 @invert(i8* %27, i32 %21, i32 %24)
br label %192
158: ; preds = %57
%159 = tail call i32 @edge(i8* %27, i32 %21, i32 %24)
br label %192
160: ; preds = %57
%161 = icmp slt i32 %0, 4
br i1 %161, label %162, label %164
162: ; preds = %160
%163 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.16, i64 0, i64 0))
br label %249
164: ; preds = %160
%165 = getelementptr inbounds i8*, i8** %1, i64 3
%166 = load i8*, i8** %165
%167 = tail call i32 @atoi(i8* %166)
%168 = icmp ugt i32 %167, 255
br i1 %168, label %169, label %171
169: ; preds = %164
%170 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.19, i64 0, i64 0))
br label %249
171: ; preds = %164
%172 = tail call i32 @atleast(i8* %27, i32 %21, i32 %24, i32 %167)
%173 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i32 %172, i32 %167)
br label %246
174: ; preds = %57
%175 = icmp slt i32 %0, 4
br i1 %175, label %176, label %178
176: ; preds = %174
%177 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
br label %249
178: ; preds = %174
%179 = getelementptr inbounds i8*, i8** %1, i64 3
%180 = load i8*, i8** %179
%181 = tail call i32 @atoi(i8* %180)
%182 = icmp ugt i32 %181, 255
br i1 %182, label %183, label %185
183: ; preds = %178
%184 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.19, i64 0, i64 0))
br label %249
185: ; preds = %178
%186 = tail call i32 @clear(i8* %27, i32 %21, i32 %24, i32 %181)
br label %192
187: ; preds = %57
%188 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %249
189: ; preds = %133, %105
%190 = tail call i32 @fclose(i32* %93)
%191 = tail call i32 @average(i8* %27, i8* %107, i32 %21, i32 %24)
br label %192
192: ; preds = %189, %71, %146, %156, %185, %158, %154, %138, %84
%193 = phi i8* [ %27, %189 ], [ %27, %185 ], [ %27, %158 ], [ %27, %156 ], [ %27, %154 ], [ %149, %146 ], [ %141, %138 ], [ %27, %84 ], [ %27, %71 ]
%194 = phi i32 [ %24, %189 ], [ %24, %185 ], [ %24, %158 ], [ %24, %156 ], [ %24, %154 ], [ %152, %146 ], [ %144, %138 ], [ %24, %84 ], [ %24, %71 ]
%195 = phi i32 [ %21, %189 ], [ %21, %185 ], [ %21, %158 ], [ %21, %156 ], [ %21, %154 ], [ %151, %146 ], [ %143, %138 ], [ %21, %84 ], [ %21, %71 ]
store i8 111, i8* %7
%196 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 1
store i8 117, i8* %196
%197 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 2
store i8 116, i8* %197
%198 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 3
store i8 95, i8* %198
%199 = load i8*, i8** %15
%200 = load i8, i8* %199
%201 = icmp eq i8 %200, 0
br i1 %201, label %214, label %202
202: ; preds = %192, %202
%203 = phi i64 [ %207, %202 ], [ 0, %192 ]
%204 = phi i8 [ %209, %202 ], [ %200, %192 ]
%205 = add nuw nsw i64 %203, 4
%206 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %205
store i8 %204, i8* %206
%207 = add nuw nsw i64 %203, 1
%208 = getelementptr inbounds i8, i8* %199, i64 %207
%209 = load i8, i8* %208
%210 = icmp eq i8 %209, 0
br i1 %210, label %211, label %202
211: ; preds = %202
%212 = add nuw i64 %203, 5
%213 = and i64 %212, 4294967295
br label %214
214: ; preds = %211, %192
%215 = phi i64 [ 4, %192 ], [ %213, %211 ]
%216 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %215
store i8 0, i8* %216
%217 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32 %195, i32* %20
store i32 %194, i32* %23
%218 = call i32 @fwrite(i8* %6, i32 1, i32 54, i32* %217)
%219 = icmp sgt i32 %194, 0
br i1 %219, label %220, label %244
220: ; preds = %214
%221 = icmp sgt i32 %195, 0
%222 = sext i32 %195 to i64
%223 = zext i32 %194 to i64
%224 = zext i32 %195 to i64
br label %225
225: ; preds = %220, %241
%226 = phi i64 [ 0, %220 ], [ %242, %241 ]
br i1 %221, label %227, label %241
227: ; preds = %225
%228 = mul nsw i64 %226, %222
br label %229
229: ; preds = %227, %229
%230 = phi i64 [ 0, %227 ], [ %239, %229 ]
%231 = add nsw i64 %230, %228
%232 = getelementptr inbounds i8, i8* %193, i64 %231
%233 = load i8, i8* %232
%234 = tail call i32 @putc(i8 zeroext %233, i32* %217)
%235 = load i8, i8* %232
%236 = tail call i32 @putc(i8 zeroext %235, i32* %217)
%237 = load i8, i8* %232
%238 = tail call i32 @putc(i8 zeroext %237, i32* %217)
%239 = add nuw nsw i64 %230, 1
%240 = icmp eq i64 %239, %224
br i1 %240, label %241, label %229
241: ; preds = %229, %225
%242 = add nuw nsw i64 %226, 1
%243 = icmp eq i64 %242, %223
br i1 %243, label %244, label %225
244: ; preds = %241, %214
%245 = tail call i32 @fclose(i32* %217)
br label %246
246: ; preds = %171, %244
%247 = phi i8* [ %193, %244 ], [ %27, %171 ]
%248 = tail call i32 @free(i8* %247)
br label %249
249: ; preds = %136, %61, %69, %75, %82, %88, %162, %169, %176, %183, %187, %246, %9
%250 = phi i32 [ 1, %9 ], [ 1, %61 ], [ 1, %69 ], [ 0, %246 ], [ 1, %75 ], [ 1, %82 ], [ 1, %88 ], [ 1, %136 ], [ 1, %162 ], [ 1, %169 ], [ 1, %176 ], [ 1, %183 ], [ 1, %187 ]
ret i32 %250
}