#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 /*<<< orphan*/ SEEK_SET;
int atoi(char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
size_t fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *search_get(char *, char *, char *, char *, int);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int conv_file(FILE *input, FILE *output) {
  void *inbuf;
  void *outbuf;
  int i;
  char header[100];
  size_t readsize = fread(header, 1, 100, input);
  if (readsize != 100) {
    printf("read size header err %d\n", (int)readsize);
    return -1;
  }
  int len = strlen("YUV4MPEG2");
  if (strncmp(header, "YUV4MPEG2", len) != 0) {
    printf("file not y4m");
    return -1;
  }
  char buf[1024];
  char *ptr = search_get(&header[len], "W", " ", buf, 1024);
  int width = atoi(buf + 1);
  printf("width %d\n", width);
  ptr = search_get(ptr + strlen(buf), "H", " ", buf, 1024);
  int height = atoi(buf + 1);
  printf("height %d\n", height);
  ptr = search_get(ptr + strlen(buf), "C420p10", "\n", buf, 1024);
  if (ptr == NULL) {
    printf("err %d \n", 70);
    return -1;
  }
  int frame_size = (width * height * 2) + ((width / 2) * (height / 2) * 4);
  int y_frame_size = width * height * 2;
  int c_frame_size = (width / 2) * (height / 2) * 2;
  int c_422_frame_size = (width / 2) * height * 2;
  int header_size = strlen("FRAME ");
  char *video_buffer = (char *)malloc(frame_size + header_size);
  if (video_buffer == NULL) {
    printf("err %d\n", 82);
    return -1;
  }
  char *video_c_buffer = (char *)malloc(c_422_frame_size);
  if (video_c_buffer == NULL) {
    printf("err %d\n", 87);
    return -1;
  }
  ptr = search_get(ptr + strlen(buf), "FRAME", "\n", buf, 1024);
  if (ptr == NULL) {
    printf("err %d\n", 93);
    return -1;
  }
  printf("%p %d\n", ptr, (int)(ptr - header));
  printf("%d %x\n", frame_size, frame_size);
  int ret = fseek(input, ptr - header, SEEK_SET);
  int frame_num = 0;
  for (;;) {
    readsize = fread(video_buffer, 1, frame_size + header_size, input);
    if (readsize != frame_size + header_size) {
      printf("read size header err %d\n", (int)readsize);
      break;
    }
    if (strncmp(video_buffer, "FRAME", strlen("FRAME"))) {
      printf("header err %x  %d\n", video_buffer[0], frame_num);
      return -1;
    }
    size_t writesize =
        fwrite(video_buffer + header_size, 1, y_frame_size, output);
    if (writesize != y_frame_size) {
      printf("writesize size header err %d %d\n", (int)writesize, 130);
      break;
    }
    for (int i = 0; i < height; i++) {
      writesize = fwrite(video_buffer + header_size + y_frame_size +
                             (i * (width / 2) * 2),
                         1, (width), output);
      if (writesize != (width)) {
        printf("writesize size header err %d %d %d\n", (int)writesize, 137, i);
        break;
      }
      writesize = fwrite(video_buffer + header_size + y_frame_size +
                             (i * (width / 2) * 2),
                         1, (width), output);
      if (writesize != (width)) {
        printf("writesize size header err %d %d %d\n", (int)writesize, 142, i);
        break;
      }
    }
    break;
    frame_num++;
  }
  printf("%d\n", frame_num);
  return 0;
}


x86 assembly (clang, -O0):
<conv_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x64,%edx
call   1040 <fread@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x64,-0x98(%rbp)
64
je     11f5 <conv_file+0x65>
mov    -0x98(%rbp),%rax
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
lea    0xe1d(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x9c(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x9c(%rbp),%edx
lea    0xdfe(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1244 <conv_file+0xb4>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
movslq -0x9c(%rbp),%rax
lea    -0x90(%rbp),%rdi
add    %rax,%rdi
lea    -0x4a0(%rbp),%rcx
lea    0xdcd(%rip),%rsi
lea    0xdf5(%rip),%rdx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,-0x4a8(%rbp)
lea    -0x4a0(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x4ac(%rbp)
mov    -0x4ac(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4a8(%rbp),%rax
mov    %rax,-0x500(%rbp)
lea    -0x4a0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x500(%rbp),%rdi
cltq
add    %rax,%rdi
lea    -0x4a0(%rbp),%rcx
lea    0xd62(%rip),%rsi
lea    0xd7e(%rip),%rdx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,-0x4a8(%rbp)
lea    -0x4a0(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x4b0(%rbp)
mov    -0x4b0(%rbp),%esi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4a8(%rbp),%rax
mov    %rax,-0x4f8(%rbp)
lea    -0x4a0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x4f8(%rbp),%rdi
cltq
add    %rax,%rdi
lea    -0x4a0(%rbp),%rcx
lea    0xcf8(%rip),%rsi
lea    0xd00(%rip),%rdx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,-0x4a8(%rbp)
cmpq   $0x0,-0x4a8(%rbp)
jne    1397 <conv_file+0x207>
lea    0xcd2(%rip),%rdi
mov    $0x46,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
mov    -0x4ac(%rbp),%eax
imul   -0x4b0(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x508(%rbp)
mov    -0x4ac(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4b0(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x508(%rbp),%eax
imul   %edx,%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x4b4(%rbp)
mov    -0x4ac(%rbp),%eax
imul   -0x4b0(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4b8(%rbp)
mov    -0x4ac(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x504(%rbp)
mov    -0x4b0(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x504(%rbp),%eax
imul   %ecx,%eax
shl    $0x1,%eax
mov    %eax,-0x4bc(%rbp)
mov    -0x4ac(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   -0x4b0(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4c0(%rbp)
lea    0xc08(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4c4(%rbp)
mov    -0x4b4(%rbp),%edi
add    -0x4c4(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x4d0(%rbp)
cmpq   $0x0,-0x4d0(%rbp)
jne    14a2 <conv_file+0x312>
lea    0xb87(%rip),%rdi
mov    $0x52,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
mov    -0x4c0(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x4d8(%rbp)
cmpq   $0x0,-0x4d8(%rbp)
jne    14e1 <conv_file+0x351>
lea    0xb48(%rip),%rdi
mov    $0x57,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
mov    -0x4a8(%rbp),%rax
mov    %rax,-0x510(%rbp)
lea    -0x4a0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x510(%rbp),%rdi
cltq
add    %rax,%rdi
lea    -0x4a0(%rbp),%rcx
lea    0xb4c(%rip),%rsi
lea    0xb3c(%rip),%rdx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,-0x4a8(%rbp)
cmpq   $0x0,-0x4a8(%rbp)
jne    155b <conv_file+0x3cb>
lea    0xace(%rip),%rdi
mov    $0x5d,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
mov    -0x4a8(%rbp),%rsi
mov    -0x4a8(%rbp),%rax
lea    -0x90(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0xaeb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4b4(%rbp),%esi
mov    -0x4b4(%rbp),%edx
lea    0xad8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4a8(%rbp),%rax
lea    -0x90(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    0x2a25(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
mov    %eax,-0x4dc(%rbp)
movl   $0x0,-0x4e0(%rbp)
mov    -0x4d0(%rbp),%rdi
mov    -0x4b4(%rbp),%edx
add    -0x4c4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
mov    -0x4b4(%rbp),%ecx
add    -0x4c4(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
je     1635 <conv_file+0x4a5>
mov    -0x98(%rbp),%rax
mov    %eax,%esi
lea    0x9d7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1878 <conv_file+0x6e8>
mov    -0x4d0(%rbp),%rax
mov    %rax,-0x518(%rbp)
lea    0xa17(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x518(%rbp),%rdi
mov    %eax,%edx
lea    0xa02(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1698 <conv_file+0x508>
mov    -0x4d0(%rbp),%rax
movsbl (%rax),%esi
mov    -0x4e0(%rbp),%edx
lea    0x9f0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1893 <conv_file+0x703>
mov    -0x4d0(%rbp),%rdi
movslq -0x4c4(%rbp),%rax
add    %rax,%rdi
mov    -0x4b8(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    %rax,-0x4e8(%rbp)
mov    -0x4e8(%rbp),%rax
movslq -0x4b8(%rbp),%rcx
cmp    %rcx,%rax
je     16fc <conv_file+0x56c>
mov    -0x4e8(%rbp),%rax
mov    %eax,%esi
lea    0x99d(%rip),%rdi
mov    $0x82,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1878 <conv_file+0x6e8>
movl   $0x0,-0x4ec(%rbp)
mov    -0x4ec(%rbp),%eax
cmp    -0x4b0(%rbp),%eax
jge    1873 <conv_file+0x6e3>
mov    -0x4d0(%rbp),%rdi
movslq -0x4c4(%rbp),%rax
add    %rax,%rdi
movslq -0x4b8(%rbp),%rax
add    %rax,%rdi
mov    -0x4ec(%rbp),%eax
mov    %eax,-0x51c(%rbp)
mov    -0x4ac(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x51c(%rbp),%eax
imul   %ecx,%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x4ac(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    %rax,-0x4e8(%rbp)
mov    -0x4e8(%rbp),%rax
movslq -0x4ac(%rbp),%rcx
cmp    %rcx,%rax
je     17b9 <conv_file+0x629>
mov    -0x4e8(%rbp),%rax
mov    %eax,%esi
mov    -0x4ec(%rbp),%ecx
lea    0x901(%rip),%rdi
mov    $0x89,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1873 <conv_file+0x6e3>
mov    -0x4d0(%rbp),%rdi
movslq -0x4c4(%rbp),%rax
add    %rax,%rdi
movslq -0x4b8(%rbp),%rax
add    %rax,%rdi
mov    -0x4ec(%rbp),%eax
mov    %eax,-0x520(%rbp)
mov    -0x4ac(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x520(%rbp),%eax
imul   %ecx,%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x4ac(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    %rax,-0x4e8(%rbp)
mov    -0x4e8(%rbp),%rax
movslq -0x4ac(%rbp),%rcx
cmp    %rcx,%rax
je     185a <conv_file+0x6ca>
mov    -0x4e8(%rbp),%rax
mov    %eax,%esi
mov    -0x4ec(%rbp),%ecx
lea    0x860(%rip),%rdi
mov    $0x8e,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1873 <conv_file+0x6e3>
jmp    185f <conv_file+0x6cf>
mov    -0x4ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4ec(%rbp)
jmp    1706 <conv_file+0x576>
jmp    1878 <conv_file+0x6e8>
mov    -0x4e0(%rbp),%esi
lea    0x7ff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4b8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x64,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x64,%rax
jne    11f9 <conv_file+0x69>
lea    0xe4e(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0x40(%rsp),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1222 <conv_file+0x92>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1209 <conv_file+0x79>
lea    0xe00(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x4b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,0x28(%rsp)
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x40,%rdi
lea    0xdf7(%rip),%rsi
lea    0xe1f(%rip),%r14
lea    0xb0(%rsp),%rbx
mov    %r14,%rdx
mov    %rbx,%rcx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,%rbp
lea    0xb1(%rsp),%r13
mov    %r13,%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
lea    0xdbc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdi
add    %rbp,%rdi
lea    0xda8(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    $0x400,%r8d
call   1070 <search_get@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   10a0 <atoi@plt>
mov    %eax,%r13d
lea    0xd84(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdi
add    %rbp,%rdi
lea    0xd71(%rip),%rsi
lea    0xd79(%rip),%rdx
mov    %rbx,%rcx
mov    $0x400,%r8d
call   1070 <search_get@plt>
test   %rax,%rax
je     145b <conv_file+0x2cb>
mov    %rax,%r14
mov    %r12d,%ecx
imul   %r13d,%ecx
add    %ecx,%ecx
mov    %r12d,%ebx
shr    $0x1f,%ebx
add    %r12d,%ebx
sar    %ebx
mov    %r13d,%eax
shr    $0x1f,%eax
add    %r13d,%eax
shr    %eax
imul   %ebx,%eax
mov    %rcx,0x30(%rsp)
lea    (%rcx,%rax,4),%ebp
lea    0xd30(%rip),%rdi
call   1050 <strlen@plt>
mov    %rax,0x38(%rsp)
mov    %rbp,0x20(%rsp)
lea    (%rax,%rbp,1),%edi
mov    %edi,0x8(%rsp)
call   1080 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     146c <conv_file+0x2dc>
add    %ebx,%ebx
mov    %ebx,%edi
imul   %r13d,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     147d <conv_file+0x2ed>
mov    %r12d,0x14(%rsp)
lea    0xb0(%rsp),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%r14
lea    0xcd7(%rip),%rsi
lea    0xcc7(%rip),%rdx
mov    %r14,%rdi
mov    %r12,%rcx
mov    $0x400,%r8d
call   1070 <search_get@plt>
test   %rax,%rax
je     148e <conv_file+0x2fe>
lea    0x40(%rsp),%rcx
mov    %eax,%r14d
sub    %ecx,%r14d
lea    0xcaa(%rip),%rdi
mov    %rax,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc9d(%rip),%rdi
mov    0x20(%rsp),%rdx
mov    %edx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14d,%esi
call   1090 <fseek@plt>
mov    0x18(%rsp),%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    0x8(%rsp),%r14d
mov    %r14d,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movslq %r14d,%rcx
cmp    %rcx,%rax
jne    149f <conv_file+0x30f>
lea    0xc3e(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14c6 <conv_file+0x336>
movsbl (%r12),%esi
lea    0xc28(%rip),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1209 <conv_file+0x79>
lea    0xbef(%rip),%rdi
mov    $0x46,%esi
jmp    1202 <conv_file+0x72>
lea    0xb9e(%rip),%rdi
mov    $0x52,%esi
jmp    1202 <conv_file+0x72>
lea    0xb8d(%rip),%rdi
mov    $0x57,%esi
jmp    1202 <conv_file+0x72>
lea    0xb7c(%rip),%rdi
mov    $0x5d,%esi
jmp    1202 <conv_file+0x72>
lea    0xb5a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xbce(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    120e <conv_file+0x7e>
movslq 0x38(%rsp),%rax
add    %rax,%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    0x30(%rsp),%rbp
mov    %ebp,%edx
mov    0x28(%rsp),%rcx
call   10b0 <fwrite@plt>
movslq %ebp,%rcx
cmp    %rcx,%rax
jne    1576 <conv_file+0x3e6>
mov    %r12,0x18(%rsp)
test   %r13d,%r13d
jle    14af <conv_file+0x31f>
add    %rax,0x18(%rsp)
movslq 0x14(%rsp),%r12
mov    %r13d,%eax
mov    %rax,0x20(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
mov    0x14(%rsp),%r13d
mov    0x28(%rsp),%r15
mov    %rax,0x8(%rsp)
movslq %r14d,%rbp
add    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %r12,%rcx
cmp    %r12,%rax
jne    1590 <conv_file+0x400>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
cmp    %r12,%rax
jne    15a0 <conv_file+0x410>
mov    0x8(%rsp),%rax
add    $0x1,%rax
add    %ebx,%r14d
cmp    %rax,0x20(%rsp)
jne    151e <conv_file+0x38e>
jmp    14af <conv_file+0x31f>
lea    0xb0b(%rip),%rdi
mov    %eax,%esi
mov    $0x82,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    14af <conv_file+0x31f>
lea    0xb12(%rip),%rdi
mov    %eax,%esi
mov    $0x89,%edx
jmp    15ae <conv_file+0x41e>
lea    0xb02(%rip),%rdi
mov    %eax,%esi
mov    $0x8e,%edx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    14af <conv_file+0x31f>

LLVM IR (-O0):
@.str = [25 x i8] c"read size header err %d\0A\00"
@.str.1 = [10 x i8] c"YUV4MPEG2\00"
@.str.2 = [13 x i8] c"file not y4m\00"
@.str.3 = [2 x i8] c"W\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [10 x i8] c"width %d\0A\00"
@.str.6 = [2 x i8] c"H\00"
@.str.7 = [11 x i8] c"height %d\0A\00"
@.str.8 = [8 x i8] c"C420p10\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [9 x i8] c"err %d \0A\00"
@.str.11 = [7 x i8] c"FRAME \00"
@.str.12 = [8 x i8] c"err %d\0A\00"
@.str.13 = [6 x i8] c"FRAME\00"
@.str.14 = [7 x i8] c"%p %d\0A\00"
@.str.15 = [7 x i8] c"%d %x\0A\00"
@SEEK_SET = global i32 0
@.str.16 = [19 x i8] c"header err %x %d\0A\00"
@.str.17 = [33 x i8] c"writesize size header err %d %d\0A\00"
@.str.18 = [36 x i8] c"writesize size header err %d %d %d\0A\00"
@.str.19 = [4 x i8] c"%d\0A\00"
define i32 @conv_file(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = alloca i64
%11 = alloca i32
%12 = alloca [1024 x i8]
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i32
%24 = alloca i32
%25 = alloca i64
%26 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%28 = load i32*, i32** %4
%29 = call i64 @fread(i8* %27, i32 1, i32 100, i32* %28)
store i64 %29, i64* %10
%30 = load i64, i64* %10
%31 = icmp ne i64 %30, 100
br i1 %31, label %32, label %36
32: ; preds = %2
%33 = load i64, i64* %10
%34 = trunc i64 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 -1, i32* %3
br label %268
36: ; preds = %2
%37 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %37, i32* %11
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%39 = load i32, i32* %11
%40 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %268
44: ; preds = %36
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %46
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%49 = call i8* @search_get(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %48, i32 1024)
store i8* %49, i8** %13
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = call i32 @atoi(i8* %51)
store i32 %52, i32* %14
%53 = load i32, i32* %14
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i8*, i8** %13
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%61 = call i8* @search_get(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %60, i32 1024)
store i8* %61, i8** %13
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = call i32 @atoi(i8* %63)
store i32 %64, i32* %15
%65 = load i32, i32* %15
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %65)
%67 = load i8*, i8** %13
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%69 = call i32 @strlen(i8* %68)
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%73 = call i8* @search_get(i8* %71, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %72, i32 1024)
store i8* %73, i8** %13
%74 = load i8*, i8** %13
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %78
76: ; preds = %44
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 70)
store i32 -1, i32* %3
br label %268
78: ; preds = %44
%79 = load i32, i32* %14
%80 = load i32, i32* %15
%81 = mul nsw i32 %79, %80
%82 = mul nsw i32 %81, 2
%83 = load i32, i32* %14
%84 = sdiv i32 %83, 2
%85 = load i32, i32* %15
%86 = sdiv i32 %85, 2
%87 = mul nsw i32 %84, %86
%88 = mul nsw i32 %87, 4
%89 = add nsw i32 %82, %88
store i32 %89, i32* %16
%90 = load i32, i32* %14
%91 = load i32, i32* %15
%92 = mul nsw i32 %90, %91
%93 = mul nsw i32 %92, 2
store i32 %93, i32* %17
%94 = load i32, i32* %14
%95 = sdiv i32 %94, 2
%96 = load i32, i32* %15
%97 = sdiv i32 %96, 2
%98 = mul nsw i32 %95, %97
%99 = mul nsw i32 %98, 2
store i32 %99, i32* %18
%100 = load i32, i32* %14
%101 = sdiv i32 %100, 2
%102 = load i32, i32* %15
%103 = mul nsw i32 %101, %102
%104 = mul nsw i32 %103, 2
store i32 %104, i32* %19
%105 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i32 %105, i32* %20
%106 = load i32, i32* %16
%107 = load i32, i32* %20
%108 = add nsw i32 %106, %107
%109 = call i64 @malloc(i32 %108)
%110 = inttoptr i64 %109 to i8*
store i8* %110, i8** %21
%111 = load i8*, i8** %21
%112 = icmp eq i8* %111, null
br i1 %112, label %113, label %115
113: ; preds = %78
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 82)
store i32 -1, i32* %3
br label %268
115: ; preds = %78
%116 = load i32, i32* %19
%117 = call i64 @malloc(i32 %116)
%118 = inttoptr i64 %117 to i8*
store i8* %118, i8** %22
%119 = load i8*, i8** %22
%120 = icmp eq i8* %119, null
br i1 %120, label %121, label %123
121: ; preds = %115
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 87)
store i32 -1, i32* %3
br label %268
123: ; preds = %115
%124 = load i8*, i8** %13
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%126 = call i32 @strlen(i8* %125)
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8, i8* %124, i64 %127
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%130 = call i8* @search_get(i8* %128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %129, i32 1024)
store i8* %130, i8** %13
%131 = load i8*, i8** %13
%132 = icmp eq i8* %131, null
br i1 %132, label %133, label %135
133: ; preds = %123
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 93)
store i32 -1, i32* %3
br label %268
135: ; preds = %123
%136 = load i8*, i8** %13
%137 = load i8*, i8** %13
%138 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%139 = ptrtoint i8* %137 to i64
%140 = ptrtoint i8* %138 to i64
%141 = sub i64 %139, %140
%142 = trunc i64 %141 to i32
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i8* %136, i32 %142)
%144 = load i32, i32* %16
%145 = load i32, i32* %16
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 %144, i32 %145)
%147 = load i32*, i32** %4
%148 = load i8*, i8** %13
%149 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%150 = ptrtoint i8* %148 to i64
%151 = ptrtoint i8* %149 to i64
%152 = sub i64 %150, %151
%153 = trunc i64 %152 to i32
%154 = load i32, i32* @SEEK_SET
%155 = call i32 @fseek(i32* %147, i32 %153, i32 %154)
store i32 %155, i32* %23
store i32 0, i32* %24
br label %156
156: ; preds = %135
%157 = load i8*, i8** %21
%158 = load i32, i32* %16
%159 = load i32, i32* %20
%160 = add nsw i32 %158, %159
%161 = load i32*, i32** %4
%162 = call i64 @fread(i8* %157, i32 1, i32 %160, i32* %161)
store i64 %162, i64* %10
%163 = load i64, i64* %10
%164 = load i32, i32* %16
%165 = load i32, i32* %20
%166 = add nsw i32 %164, %165
%167 = sext i32 %166 to i64
%168 = icmp ne i64 %163, %167
br i1 %168, label %169, label %173
169: ; preds = %156
%170 = load i64, i64* %10
%171 = trunc i64 %170 to i32
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %171)
br label %265
173: ; preds = %156
%174 = load i8*, i8** %21
%175 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%176 = call i64 @strncmp(i8* %174, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %175)
%177 = icmp ne i64 %176, 0
br i1 %177, label %178, label %185
178: ; preds = %173
%179 = load i8*, i8** %21
%180 = getelementptr inbounds i8, i8* %179, i64 0
%181 = load i8, i8* %180
%182 = sext i8 %181 to i32
%183 = load i32, i32* %24
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i32 %182, i32 %183)
store i32 -1, i32* %3
br label %268
185: ; preds = %173
%186 = load i8*, i8** %21
%187 = load i32, i32* %20
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds i8, i8* %186, i64 %188
%190 = load i32, i32* %17
%191 = load i32*, i32** %5
%192 = call i64 @fwrite(i8* %189, i32 1, i32 %190, i32* %191)
store i64 %192, i64* %25
%193 = load i64, i64* %25
%194 = load i32, i32* %17
%195 = sext i32 %194 to i64
%196 = icmp ne i64 %193, %195
br i1 %196, label %197, label %201
197: ; preds = %185
%198 = load i64, i64* %25
%199 = trunc i64 %198 to i32
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i32 %199, i32 130)
br label %265
201: ; preds = %185
store i32 0, i32* %26
br label %202
202: ; preds = %261, %201
%203 = load i32, i32* %26
%204 = load i32, i32* %15
%205 = icmp slt i32 %203, %204
br i1 %205, label %206, label %264
206: ; preds = %202
%207 = load i8*, i8** %21
%208 = load i32, i32* %20
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds i8, i8* %207, i64 %209
%211 = load i32, i32* %17
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds i8, i8* %210, i64 %212
%214 = load i32, i32* %26
%215 = load i32, i32* %14
%216 = sdiv i32 %215, 2
%217 = mul nsw i32 %214, %216
%218 = mul nsw i32 %217, 2
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %213, i64 %219
%221 = load i32, i32* %14
%222 = load i32*, i32** %5
%223 = call i64 @fwrite(i8* %220, i32 1, i32 %221, i32* %222)
store i64 %223, i64* %25
%224 = load i64, i64* %25
%225 = load i32, i32* %14
%226 = sext i32 %225 to i64
%227 = icmp ne i64 %224, %226
br i1 %227, label %228, label %233
228: ; preds = %206
%229 = load i64, i64* %25
%230 = trunc i64 %229 to i32
%231 = load i32, i32* %26
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %230, i32 137, i32 %231)
br label %264
233: ; preds = %206
%234 = load i8*, i8** %21
%235 = load i32, i32* %20
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds i8, i8* %234, i64 %236
%238 = load i32, i32* %17
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds i8, i8* %237, i64 %239
%241 = load i32, i32* %26
%242 = load i32, i32* %14
%243 = sdiv i32 %242, 2
%244 = mul nsw i32 %241, %243
%245 = mul nsw i32 %244, 2
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds i8, i8* %240, i64 %246
%248 = load i32, i32* %14
%249 = load i32*, i32** %5
%250 = call i64 @fwrite(i8* %247, i32 1, i32 %248, i32* %249)
store i64 %250, i64* %25
%251 = load i64, i64* %25
%252 = load i32, i32* %14
%253 = sext i32 %252 to i64
%254 = icmp ne i64 %251, %253
br i1 %254, label %255, label %260
255: ; preds = %233
%256 = load i64, i64* %25
%257 = trunc i64 %256 to i32
%258 = load i32, i32* %26
%259 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %257, i32 142, i32 %258)
br label %264
260: ; preds = %233
br label %261
261: ; preds = %260
%262 = load i32, i32* %26
%263 = add nsw i32 %262, 1
store i32 %263, i32* %26
br label %202
264: ; preds = %255, %228, %202
br label %265
265: ; preds = %264, %197, %169
%266 = load i32, i32* %24
%267 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i32 %266)
store i32 0, i32* %3
br label %268
268: ; preds = %265, %178, %133, %121, %113, %76, %42, %32
%269 = load i32, i32* %3
ret i32 %269
}

LLVM IR (-O2):
@.str = [25 x i8] c"read size header err %d\0A\00"
@.str.1 = [10 x i8] c"YUV4MPEG2\00"
@.str.2 = [13 x i8] c"file not y4m\00"
@.str.3 = [2 x i8] c"W\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [10 x i8] c"width %d\0A\00"
@.str.6 = [2 x i8] c"H\00"
@.str.7 = [11 x i8] c"height %d\0A\00"
@.str.8 = [8 x i8] c"C420p10\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [9 x i8] c"err %d \0A\00"
@.str.11 = [7 x i8] c"FRAME \00"
@.str.12 = [8 x i8] c"err %d\0A\00"
@.str.13 = [6 x i8] c"FRAME\00"
@.str.14 = [7 x i8] c"%p %d\0A\00"
@.str.15 = [7 x i8] c"%d %x\0A\00"
@SEEK_SET = global i32 0
@.str.16 = [19 x i8] c"header err %x %d\0A\00"
@.str.17 = [33 x i8] c"writesize size header err %d %d\0A\00"
@.str.18 = [36 x i8] c"writesize size header err %d %d %d\0A\00"
@.str.19 = [4 x i8] c"%d\0A\00"
define i32 @conv_file(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i64 @fread(i8* %5, i32 1, i32 100, i32* %0)
%7 = icmp eq i64 %6, 100
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = trunc i64 %6 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %132
11: ; preds = %2
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %132
17: ; preds = %11
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%19 = sext i32 %12 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %19
%21 = call i8* @search_get(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %18, i32 1024)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 1
%23 = call i32 @atoi(i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = call i32 @strlen(i8* %18)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %21, i64 %26
%28 = call i8* @search_get(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %18, i32 1024)
%29 = call i32 @atoi(i8* %22)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %29)
%31 = call i32 @strlen(i8* %18)
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %28, i64 %32
%34 = call i8* @search_get(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %18, i32 1024)
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %38
36: ; preds = %17
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 70)
br label %130
38: ; preds = %17
%39 = shl i32 %23, 1
%40 = mul i32 %39, %29
%41 = sdiv i32 %23, 2
%42 = sdiv i32 %29, 2
%43 = shl i32 %41, 2
%44 = mul i32 %43, %42
%45 = add nsw i32 %44, %40
%46 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%47 = add nsw i32 %46, %45
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to i8*
%50 = icmp eq i64 %48, 0
br i1 %50, label %51, label %53
51: ; preds = %38
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 82)
br label %130
53: ; preds = %38
%54 = shl nsw i32 %41, 1
%55 = mul i32 %54, %29
%56 = call i64 @malloc(i32 %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 87)
br label %130
60: ; preds = %53
%61 = call i32 @strlen(i8* %18)
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %34, i64 %62
%64 = call i8* @search_get(i8* %63, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %18, i32 1024)
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %60
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 93)
br label %130
68: ; preds = %60
%69 = ptrtoint i8* %64 to i64
%70 = ptrtoint [100 x i8]* %3 to i64
%71 = sub i64 %69, %70
%72 = trunc i64 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), i8* %64, i32 %72)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0), i32 %45, i32 %45)
%75 = load i32, i32* @SEEK_SET
%76 = call i32 @fseek(i32* %0, i32 %72, i32 %75)
%77 = call i64 @fread(i8* %49, i32 1, i32 %47, i32* %0)
%78 = sext i32 %47 to i64
%79 = icmp eq i64 %77, %78
br i1 %79, label %83, label %80
80: ; preds = %68
%81 = trunc i64 %77 to i32
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %81)
br label %128
83: ; preds = %68
%84 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%85 = call i64 @strncmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %84)
%86 = icmp eq i64 %85, 0
br i1 %86, label %91, label %87
87: ; preds = %83
%88 = load i8, i8* %49
%89 = sext i8 %88 to i32
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i32 %89, i32 0)
br label %130
91: ; preds = %83
%92 = sext i32 %46 to i64
%93 = getelementptr inbounds i8, i8* %49, i64 %92
%94 = call i64 @fwrite(i8* %93, i32 1, i32 %40, i32* %1)
%95 = sext i32 %40 to i64
%96 = icmp eq i64 %94, %95
br i1 %96, label %97, label %103
97: ; preds = %91
%98 = icmp sgt i32 %29, 0
br i1 %98, label %99, label %128
99: ; preds = %97
%100 = getelementptr inbounds i8, i8* %93, i64 %94
%101 = sext i32 %23 to i64
%102 = zext i32 %29 to i64
br label %106
103: ; preds = %91
%104 = trunc i64 %94 to i32
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i64 0, i64 0), i32 %104, i32 130)
br label %128
106: ; preds = %99, %125
%107 = phi i64 [ 0, %99 ], [ %126, %125 ]
%108 = trunc i64 %107 to i32
%109 = mul i32 %54, %108
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %100, i64 %110
%112 = call i64 @fwrite(i8* %111, i32 1, i32 %23, i32* %1)
%113 = icmp eq i64 %112, %101
br i1 %113, label %118, label %114
114: ; preds = %106
%115 = trunc i64 %107 to i32
%116 = trunc i64 %112 to i32
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %116, i32 137, i32 %115)
br label %128
118: ; preds = %106
%119 = call i64 @fwrite(i8* %111, i32 1, i32 %23, i32* %1)
%120 = icmp eq i64 %119, %101
br i1 %120, label %125, label %121
121: ; preds = %118
%122 = trunc i64 %107 to i32
%123 = trunc i64 %119 to i32
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.18, i64 0, i64 0), i32 %123, i32 142, i32 %122)
br label %128
125: ; preds = %118
%126 = add nuw nsw i64 %107, 1
%127 = icmp eq i64 %126, %102
br i1 %127, label %128, label %106
128: ; preds = %125, %97, %103, %121, %114, %80
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i32 0)
br label %130
130: ; preds = %51, %87, %128, %66, %58, %36
%131 = phi i32 [ -1, %36 ], [ -1, %51 ], [ -1, %58 ], [ -1, %66 ], [ 0, %128 ], [ -1, %87 ]
br label %132
132: ; preds = %15, %130, %8
%133 = phi i32 [ -1, %8 ], [ -1, %15 ], [ %131, %130 ]
ret i32 %133
}