#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*/ syncbytes;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_uint16_be(unsigned char *);
int get_uint24_be(unsigned char *);
int get_uint32_be(unsigned char *);
int open(char *, int, ...);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int fd, fdout;
  unsigned char buf[1024 * 1024];
  unsigned char syncbytes[4] = {0x00, 0x00, 0x00, 0x01};
  int i, n;
  if (argc != 3) {
    fprintf(stderr, "Usage: flvtoh264 input.flv output.h264\n");
    exit(1);
  }
  if ((fd = open(argv[1], O_RDONLY)) < 0) {
    fprintf(stderr, "Could not open file %s\n", argv[1]);
    exit(1);
  }
  if ((fdout = open(argv[2], O_CREAT | O_TRUNC | O_RDWR, 0666)) < 0) {
    fprintf(stderr, "Could not open file %s\n", argv[2]);
    exit(1);
  }
  read(fd, buf, 9);
  if ((buf[0] != 'F') || (buf[1] != 'L') || (buf[2] != 'V')) {
    fprintf(stderr, "File does not start with FLV, aborting\n");
    exit(1);
  }
  read(fd, buf, 4);
  n = read(fd, buf, 11);
  int videopacket = 0;
  while (n == 11) {
    int type = buf[0];
    int packet_length = get_uint24_be(buf + 1);
    int dts = get_uint24_be(buf + 4);
    int stream_id = get_uint32_be(buf + 7);
    if (packet_length > 0) {
      n = read(fd, buf, packet_length);
      if (type == 9) {
        int flags = buf[0];
        int h264_type = buf[1];
        int cts = get_uint24_be(buf + 2);
        int pts = dts + cts;
        i = 5;
        if (h264_type == 0) {
          int version = buf[i++];
          int profile = buf[i++];
          int compatibility = buf[i++];
          int level = buf[i++];
          int NULA_length_size = (buf[i++] & 0x3) + 1;
          if (NULA_length_size != 4) {
            fprintf(stderr, "Unsupported NULA length - %d\n", NULA_length_size);
            exit(1);
          }
          int SPS_count = buf[i++] & 0x1f;
          while (SPS_count > 0) {
            int SPS_size = get_uint16_be(buf + i);
            i += 2;
            write(fdout, syncbytes, sizeof(syncbytes));
            write(fdout, buf + i, SPS_size);
            i += SPS_size;
            SPS_count--;
          }
          int PPS_count = buf[i++];
          while (PPS_count > 0) {
            int PPS_size = get_uint16_be(buf + i);
            i += 2;
            write(fdout, syncbytes, sizeof(syncbytes));
            write(fdout, buf + i, PPS_size);
            i += PPS_size;
            PPS_count--;
          }
        } else {
          while (i < packet_length) {
            int NAL_length = get_uint32_be(buf + i);
            i += 4;
            write(fdout, syncbytes, sizeof(syncbytes));
            write(fdout, buf + i, NAL_length);
            i += NAL_length;
          }
          if (i != packet_length) {
            fprintf(stderr, "ERROR: incomplete NAL unit in packet\n");
            exit(1);
          }
        }
      }
    }
    n = read(fd, buf, 4);
    n = read(fd, buf, 11);
  }
  close(fd);
  close(fdout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100080,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe51(%rip),%eax
mov    %eax,-0x100024(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11e0 <main+0x50>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    122d <main+0x9d>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
mov    0x2dab(%rip),%rax
or     (%rax),%esi
mov    0x2d8a(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1291 <main+0x101>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    $0x9,%edx
call   1050 <read@plt>
movzbl -0x100020(%rbp),%eax
cmp    $0x46,%eax
jne    12d5 <main+0x145>
movzbl -0x10001f(%rbp),%eax
cmp    $0x4c,%eax
jne    12d5 <main+0x145>
movzbl -0x10001e(%rbp),%eax
cmp    $0x56,%eax
je     12f6 <main+0x166>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    $0xb,%edx
call   1050 <read@plt>
mov    %eax,-0x10002c(%rbp)
movl   $0x0,-0x100030(%rbp)
cmpl   $0xb,-0x10002c(%rbp)
jne    176a <main+0x5da>
movzbl -0x100020(%rbp),%eax
mov    %eax,-0x100034(%rbp)
lea    -0x100020(%rbp),%rdi
add    $0x1,%rdi
call   1070 <get_uint24_be@plt>
mov    %eax,-0x100038(%rbp)
lea    -0x100020(%rbp),%rdi
add    $0x4,%rdi
call   1070 <get_uint24_be@plt>
mov    %eax,-0x10003c(%rbp)
lea    -0x100020(%rbp),%rdi
add    $0x7,%rdi
call   10a0 <get_uint32_be@plt>
mov    %eax,-0x100040(%rbp)
cmpl   $0x0,-0x100038(%rbp)
jle    1731 <main+0x5a1>
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    -0x100038(%rbp),%edx
call   1050 <read@plt>
mov    %eax,-0x10002c(%rbp)
cmpl   $0x9,-0x100034(%rbp)
jne    172c <main+0x59c>
movzbl -0x100020(%rbp),%eax
mov    %eax,-0x100044(%rbp)
movzbl -0x10001f(%rbp),%eax
mov    %eax,-0x100048(%rbp)
lea    -0x100020(%rbp),%rdi
add    $0x2,%rdi
call   1070 <get_uint24_be@plt>
mov    %eax,-0x10004c(%rbp)
mov    -0x10003c(%rbp),%eax
add    -0x10004c(%rbp),%eax
mov    %eax,-0x100050(%rbp)
movl   $0x5,-0x100028(%rbp)
cmpl   $0x0,-0x100048(%rbp)
jne    1663 <main+0x4d3>
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
mov    %eax,-0x100054(%rbp)
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
mov    %eax,-0x100058(%rbp)
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
mov    %eax,-0x10005c(%rbp)
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
mov    %eax,-0x100060(%rbp)
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
and    $0x3,%eax
add    $0x1,%eax
mov    %eax,-0x100064(%rbp)
cmpl   $0x4,-0x100064(%rbp)
je     14f7 <main+0x367>
mov    0x2ae9(%rip),%rax
mov    (%rax),%edi
mov    -0x100064(%rbp),%edx
lea    0xb86(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
and    $0x1f,%eax
mov    %eax,-0x100068(%rbp)
cmpl   $0x0,-0x100068(%rbp)
jle    15ac <main+0x41c>
lea    -0x100020(%rbp),%rdi
movslq -0x100028(%rbp),%rax
add    %rax,%rdi
call   1080 <get_uint16_be@plt>
mov    %eax,-0x10006c(%rbp)
mov    -0x100028(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x100028(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x100024(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x100020(%rbp),%rsi
movslq -0x100028(%rbp),%rax
add    %rax,%rsi
mov    -0x10006c(%rbp),%edx
call   1030 <write@plt>
mov    -0x10006c(%rbp),%eax
add    -0x100028(%rbp),%eax
mov    %eax,-0x100028(%rbp)
mov    -0x100068(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x100068(%rbp)
jmp    151b <main+0x38b>
mov    -0x100028(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x100028(%rbp)
cltq
movzbl -0x100020(%rbp,%rax,1),%eax
ff
mov    %eax,-0x100070(%rbp)
cmpl   $0x0,-0x100070(%rbp)
jle    165e <main+0x4ce>
lea    -0x100020(%rbp),%rdi
movslq -0x100028(%rbp),%rax
add    %rax,%rdi
call   1080 <get_uint16_be@plt>
mov    %eax,-0x100074(%rbp)
mov    -0x100028(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x100028(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x100024(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x100020(%rbp),%rsi
movslq -0x100028(%rbp),%rax
add    %rax,%rsi
mov    -0x100074(%rbp),%edx
call   1030 <write@plt>
mov    -0x100074(%rbp),%eax
add    -0x100028(%rbp),%eax
mov    %eax,-0x100028(%rbp)
mov    -0x100070(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x100070(%rbp)
jmp    15cd <main+0x43d>
jmp    1727 <main+0x597>
jmp    1668 <main+0x4d8>
mov    -0x100028(%rbp),%eax
cmp    -0x100038(%rbp),%eax
jge    16ef <main+0x55f>
lea    -0x100020(%rbp),%rdi
movslq -0x100028(%rbp),%rax
add    %rax,%rdi
call   10a0 <get_uint32_be@plt>
mov    %eax,-0x100078(%rbp)
mov    -0x100028(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x100028(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x100024(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x100020(%rbp),%rsi
movslq -0x100028(%rbp),%rax
add    %rax,%rsi
mov    -0x100078(%rbp),%edx
call   1030 <write@plt>
mov    -0x100078(%rbp),%eax
add    -0x100028(%rbp),%eax
mov    %eax,-0x100028(%rbp)
jmp    1668 <main+0x4d8>
mov    -0x100028(%rbp),%eax
cmp    -0x100038(%rbp),%eax
je     1722 <main+0x592>
mov    0x28b8(%rip),%rax
mov    (%rax),%edi
lea    0x979(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1727 <main+0x597>
jmp    172c <main+0x59c>
jmp    1731 <main+0x5a1>
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    %eax,-0x10002c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x100020(%rbp),%rsi
mov    $0xb,%edx
call   1050 <read@plt>
mov    %eax,-0x10002c(%rbp)
jmp    132e <main+0x19e>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x100080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100018,%rsp
movl   $0x1000000,0xc(%rsp)
01
cmp    $0x3,%edi
jne    14a1 <main+0x311>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
js     14b3 <main+0x323>
mov    %eax,%r13d
mov    0x2e1d(%rip),%rax
mov    0x2e0e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%r14),%rdi
mov    0x2de7(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
js     14c2 <main+0x332>
mov    %eax,%r15d
lea    0x10(%rsp),%rsi
mov    %r13d,%edi
mov    $0x9,%edx
call   1050 <read@plt>
cmpb   $0x46,0x10(%rsp)
jne    14e7 <main+0x357>
cmpb   $0x4c,0x11(%rsp)
jne    14e7 <main+0x357>
cmpb   $0x56,0x12(%rsp)
jne    14e7 <main+0x357>
lea    0x10(%rsp),%r14
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0xb,%edx
call   1050 <read@plt>
cmp    $0xb,%eax
jne    144a <main+0x2ba>
lea    0xc(%rsp),%r14
jmp    12ae <main+0x11e>
cmp    %r12d,%eax
jne    146e <main+0x2de>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0xb,%edx
call   1050 <read@plt>
cmp    $0xb,%eax
jne    144a <main+0x2ba>
mov    0x10(%rsp),%bl
lea    0x11(%rsp),%rdi
call   1070 <get_uint24_be@plt>
mov    %eax,%r12d
lea    0x14(%rsp),%rdi
call   1070 <get_uint24_be@plt>
lea    0x17(%rsp),%rdi
call   10a0 <get_uint32_be@plt>
test   %r12d,%r12d
jle    1280 <main+0xf0>
mov    %r13d,%edi
lea    0x10(%rsp),%rsi
mov    %r12d,%edx
call   1050 <read@plt>
cmp    $0x9,%bl
jne    1280 <main+0xf0>
mov    0x11(%rsp),%bl
lea    0x12(%rsp),%rdi
call   1070 <get_uint24_be@plt>
test   %bl,%bl
je     1364 <main+0x1d4>
mov    $0x5,%eax
cmp    $0x6,%r12d
jb     1272 <main+0xe2>
mov    $0x5,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x10,%rdi
call   10a0 <get_uint32_be@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    (%rsp,%rbp,1),%rsi
add    $0x14,%rsi
mov    %r15d,%edi
mov    %ebx,%edx
call   1030 <write@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x4,%eax
cmp    %r12d,%eax
jl     1320 <main+0x190>
jmp    1272 <main+0xe2>
movzbl 0x19(%rsp),%edx
and    $0x3,%edx
add    $0x1,%edx
cmp    $0x4,%dl
jne    1480 <main+0x2f0>
movzbl 0x1a(%rsp),%ebp
and    $0x1f,%ebp
je     13d7 <main+0x247>
add    $0x1,%ebp
mov    $0xb,%eax
nopw   0x0(%rax,%rax,1)
movslq %eax,%rbx
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
call   1080 <get_uint16_be@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    (%rsp,%rbx,1),%rsi
add    $0x12,%rsi
mov    %r15d,%edi
mov    %r12d,%edx
call   1030 <write@plt>
lea    (%rbx,%r12,1),%eax
add    $0x2,%eax
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1390 <main+0x200>
jmp    13dc <main+0x24c>
mov    $0xb,%eax
movslq %eax,%rcx
movzbl 0x10(%rsp,%rcx,1),%ebp
test   %ebp,%ebp
je     1280 <main+0xf0>
add    $0x1,%eax
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %eax,%rbx
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
call   1080 <get_uint16_be@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
lea    (%rsp,%rbx,1),%rsi
add    $0x12,%rsi
mov    %r15d,%edi
mov    %r12d,%edx
call   1030 <write@plt>
lea    (%rbx,%r12,1),%eax
add    $0x2,%eax
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1400 <main+0x270>
jmp    1280 <main+0xf0>
mov    %r13d,%edi
call   1040 <close@plt>
mov    %r15d,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x100018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b4b(%rip),%rax
mov    (%rax),%edi
lea    0xc08(%rip),%rsi
jmp    14f7 <main+0x367>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
lea    0xbd8(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2b18(%rip),%rax
mov    (%rax),%edi
lea    0xb4f(%rip),%rsi
jmp    14f7 <main+0x367>
mov    0x2b06(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
jmp    14cf <main+0x33f>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r14),%rdx
lea    0xb52(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
lea    0xb49(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.main.syncbytes = [4 x i8] c"\00\00\00\01"
@stderr = global i32 0
@.str = [40 x i8] c"Usage: flvtoh264 input.flv output.h264\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [24 x i8] c"Could not open file %s\0A\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@.str.2 = [40 x i8] c"File does not start with FLV, aborting\0A\00"
@.str.3 = [30 x i8] c"Unsupported NULA length - %d\0A\00"
@.str.4 = [38 x i8] c"ERROR: incomplete NAL unit in packet\0A\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 [1048576 x i8]
%9 = alloca [4 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%31 = bitcast [4 x i8]* %9 to i8*
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 3
br i1 %33, label %34, label %38
34: ; preds = %2
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %2
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = load i32, i32* @O_RDONLY
%43 = call i32 (i8*, i32, ...) @open(i8* %41, i32 %42)
store i32 %43, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %38
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = load i32, i32* @O_CREAT
%57 = load i32, i32* @O_TRUNC
%58 = or i32 %56, %57
%59 = load i32, i32* @O_RDWR
%60 = or i32 %58, %59
%61 = call i32 (i8*, i32, ...) @open(i8* %55, i32 %60, i32 438)
store i32 %61, i32* %7
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %70
63: ; preds = %52
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %52
%71 = load i32, i32* %6
%72 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%73 = call i32 @read(i32 %71, i8* %72, i32 9)
%74 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = icmp ne i32 %76, 70
br i1 %77, label %88, label %78
78: ; preds = %70
%79 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 1
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = icmp ne i32 %81, 76
br i1 %82, label %88, label %83
83: ; preds = %78
%84 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 2
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = icmp ne i32 %86, 86
br i1 %87, label %88, label %92
88: ; preds = %83, %78, %70
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %83
%93 = load i32, i32* %6
%94 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%95 = call i32 @read(i32 %93, i8* %94, i32 4)
%96 = load i32, i32* %6
%97 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%98 = call i32 @read(i32 %96, i8* %97, i32 11)
store i32 %98, i32* %11
store i32 0, i32* %12
br label %99
99: ; preds = %284, %92
%100 = load i32, i32* %11
%101 = icmp eq i32 %100, 11
br i1 %101, label %102, label %291
102: ; preds = %99
%103 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
store i32 %105, i32* %13
%106 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%107 = getelementptr inbounds i8, i8* %106, i64 1
%108 = call i32 @get_uint24_be(i8* %107)
store i32 %108, i32* %14
%109 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%110 = getelementptr inbounds i8, i8* %109, i64 4
%111 = call i32 @get_uint24_be(i8* %110)
store i32 %111, i32* %15
%112 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%113 = getelementptr inbounds i8, i8* %112, i64 7
%114 = call i32 @get_uint32_be(i8* %113)
store i32 %114, i32* %16
%115 = load i32, i32* %14
%116 = icmp sgt i32 %115, 0
br i1 %116, label %117, label %284
117: ; preds = %102
%118 = load i32, i32* %6
%119 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%120 = load i32, i32* %14
%121 = call i32 @read(i32 %118, i8* %119, i32 %120)
store i32 %121, i32* %11
%122 = load i32, i32* %13
%123 = icmp eq i32 %122, 9
br i1 %123, label %124, label %283
124: ; preds = %117
%125 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
store i32 %127, i32* %17
%128 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 1
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
store i32 %130, i32* %18
%131 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%132 = getelementptr inbounds i8, i8* %131, i64 2
%133 = call i32 @get_uint24_be(i8* %132)
store i32 %133, i32* %19
%134 = load i32, i32* %15
%135 = load i32, i32* %19
%136 = add nsw i32 %134, %135
store i32 %136, i32* %20
store i32 5, i32* %10
%137 = load i32, i32* %18
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %247
139: ; preds = %124
%140 = load i32, i32* %10
%141 = add nsw i32 %140, 1
store i32 %141, i32* %10
%142 = sext i32 %140 to i64
%143 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %142
%144 = load i8, i8* %143
%145 = zext i8 %144 to i32
store i32 %145, i32* %21
%146 = load i32, i32* %10
%147 = add nsw i32 %146, 1
store i32 %147, i32* %10
%148 = sext i32 %146 to i64
%149 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %148
%150 = load i8, i8* %149
%151 = zext i8 %150 to i32
store i32 %151, i32* %22
%152 = load i32, i32* %10
%153 = add nsw i32 %152, 1
store i32 %153, i32* %10
%154 = sext i32 %152 to i64
%155 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %154
%156 = load i8, i8* %155
%157 = zext i8 %156 to i32
store i32 %157, i32* %23
%158 = load i32, i32* %10
%159 = add nsw i32 %158, 1
store i32 %159, i32* %10
%160 = sext i32 %158 to i64
%161 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %160
%162 = load i8, i8* %161
%163 = zext i8 %162 to i32
store i32 %163, i32* %24
%164 = load i32, i32* %10
%165 = add nsw i32 %164, 1
store i32 %165, i32* %10
%166 = sext i32 %164 to i64
%167 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %166
%168 = load i8, i8* %167
%169 = zext i8 %168 to i32
%170 = and i32 %169, 3
%171 = add nsw i32 %170, 1
store i32 %171, i32* %25
%172 = load i32, i32* %25
%173 = icmp ne i32 %172, 4
br i1 %173, label %174, label %179
174: ; preds = %139
%175 = load i32, i32* @stderr
%176 = load i32, i32* %25
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %176)
%178 = call i32 @exit(i32 1)
unreachable
179: ; preds = %139
%180 = load i32, i32* %10
%181 = add nsw i32 %180, 1
store i32 %181, i32* %10
%182 = sext i32 %180 to i64
%183 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %182
%184 = load i8, i8* %183
%185 = zext i8 %184 to i32
%186 = and i32 %185, 31
store i32 %186, i32* %26
br label %187
187: ; preds = %190, %179
%188 = load i32, i32* %26
%189 = icmp sgt i32 %188, 0
br i1 %189, label %190, label %213
190: ; preds = %187
%191 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%192 = load i32, i32* %10
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds i8, i8* %191, i64 %193
%195 = call i32 @get_uint16_be(i8* %194)
store i32 %195, i32* %27
%196 = load i32, i32* %10
%197 = add nsw i32 %196, 2
store i32 %197, i32* %10
%198 = load i32, i32* %7
%199 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%200 = call i32 @write(i32 %198, i8* %199, i32 4)
%201 = load i32, i32* %7
%202 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%203 = load i32, i32* %10
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds i8, i8* %202, i64 %204
%206 = load i32, i32* %27
%207 = call i32 @write(i32 %201, i8* %205, i32 %206)
%208 = load i32, i32* %27
%209 = load i32, i32* %10
%210 = add nsw i32 %209, %208
store i32 %210, i32* %10
%211 = load i32, i32* %26
%212 = add nsw i32 %211, -1
store i32 %212, i32* %26
br label %187
213: ; preds = %187
%214 = load i32, i32* %10
%215 = add nsw i32 %214, 1
store i32 %215, i32* %10
%216 = sext i32 %214 to i64
%217 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 %216
%218 = load i8, i8* %217
%219 = zext i8 %218 to i32
store i32 %219, i32* %28
br label %220
220: ; preds = %223, %213
%221 = load i32, i32* %28
%222 = icmp sgt i32 %221, 0
br i1 %222, label %223, label %246
223: ; preds = %220
%224 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%225 = load i32, i32* %10
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds i8, i8* %224, i64 %226
%228 = call i32 @get_uint16_be(i8* %227)
store i32 %228, i32* %29
%229 = load i32, i32* %10
%230 = add nsw i32 %229, 2
store i32 %230, i32* %10
%231 = load i32, i32* %7
%232 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%233 = call i32 @write(i32 %231, i8* %232, i32 4)
%234 = load i32, i32* %7
%235 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%236 = load i32, i32* %10
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds i8, i8* %235, i64 %237
%239 = load i32, i32* %29
%240 = call i32 @write(i32 %234, i8* %238, i32 %239)
%241 = load i32, i32* %29
%242 = load i32, i32* %10
%243 = add nsw i32 %242, %241
store i32 %243, i32* %10
%244 = load i32, i32* %28
%245 = add nsw i32 %244, -1
store i32 %245, i32* %28
br label %220
246: ; preds = %220
br label %282
247: ; preds = %124
br label %248
248: ; preds = %252, %247
%249 = load i32, i32* %10
%250 = load i32, i32* %14
%251 = icmp slt i32 %249, %250
br i1 %251, label %252, label %273
252: ; preds = %248
%253 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%254 = load i32, i32* %10
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds i8, i8* %253, i64 %255
%257 = call i32 @get_uint32_be(i8* %256)
store i32 %257, i32* %30
%258 = load i32, i32* %10
%259 = add nsw i32 %258, 4
store i32 %259, i32* %10
%260 = load i32, i32* %7
%261 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%262 = call i32 @write(i32 %260, i8* %261, i32 4)
%263 = load i32, i32* %7
%264 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%265 = load i32, i32* %10
%266 = sext i32 %265 to i64
%267 = getelementptr inbounds i8, i8* %264, i64 %266
%268 = load i32, i32* %30
%269 = call i32 @write(i32 %263, i8* %267, i32 %268)
%270 = load i32, i32* %30
%271 = load i32, i32* %10
%272 = add nsw i32 %271, %270
store i32 %272, i32* %10
br label %248
273: ; preds = %248
%274 = load i32, i32* %10
%275 = load i32, i32* %14
%276 = icmp ne i32 %274, %275
br i1 %276, label %277, label %281
277: ; preds = %273
%278 = load i32, i32* @stderr
%279 = call i32 (i32, i8*, ...) @fprintf(i32 %278, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%280 = call i32 @exit(i32 1)
unreachable
281: ; preds = %273
br label %282
282: ; preds = %281, %246
br label %283
283: ; preds = %282, %117
br label %284
284: ; preds = %283, %102
%285 = load i32, i32* %6
%286 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%287 = call i32 @read(i32 %285, i8* %286, i32 4)
store i32 %287, i32* %11
%288 = load i32, i32* %6
%289 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %8, i64 0, i64 0
%290 = call i32 @read(i32 %288, i8* %289, i32 11)
store i32 %290, i32* %11
br label %99
291: ; preds = %99
%292 = load i32, i32* %6
%293 = call i32 @close(i32 %292)
%294 = load i32, i32* %7
%295 = call i32 @close(i32 %294)
%296 = load i32, i32* %3
ret i32 %296
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"Usage: flvtoh264 input.flv output.h264\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [24 x i8] c"Could not open file %s\0A\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@.str.2 = [40 x i8] c"File does not start with FLV, aborting\0A\00"
@.str.3 = [30 x i8] c"Unsupported NULA length - %d\0A\00"
@.str.4 = [38 x i8] c"ERROR: incomplete NAL unit in packet\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1048576 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
store i32 16777216, i32* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDONLY
%16 = tail call i32 (i8*, i32, ...) @open(i8* %14, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %13
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %12
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_CREAT
%27 = load i32, i32* @O_TRUNC
%28 = or i32 %27, %26
%29 = load i32, i32* @O_RDWR
%30 = or i32 %28, %29
%31 = tail call i32 (i8*, i32, ...) @open(i8* %25, i32 %30, i32 438)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %24
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %23
%39 = call i32 @read(i32 %16, i8* %5, i32 9)
%40 = load i8, i8* %5
%41 = icmp ne i8 %40, 70
%42 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 1
%43 = load i8, i8* %42
%44 = icmp ne i8 %43, 76
%45 = select i1 %41, i1 true, i1 %44
%46 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 2
%47 = load i8, i8* %46
%48 = icmp ne i8 %47, 86
%49 = select i1 %45, i1 true, i1 %48
br i1 %49, label %50, label %54
50: ; preds = %38
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %38
%55 = call i32 @read(i32 %16, i8* %5, i32 4)
%56 = call i32 @read(i32 %16, i8* %5, i32 11)
%57 = icmp eq i32 %56, 11
br i1 %57, label %58, label %154
58: ; preds = %54
%59 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 4
%60 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 7
%61 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 9
%62 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 10
br label %63
63: ; preds = %58, %150
%64 = load i8, i8* %5
%65 = call i32 @get_uint24_be(i8* %42)
%66 = call i32 @get_uint24_be(i8* %59)
%67 = call i32 @get_uint32_be(i8* %60)
%68 = icmp sgt i32 %65, 0
br i1 %68, label %69, label %150
69: ; preds = %63
%70 = call i32 @read(i32 %16, i8* %5, i32 %65)
%71 = icmp eq i8 %64, 9
br i1 %71, label %72, label %150
72: ; preds = %69
%73 = load i8, i8* %42
%74 = call i32 @get_uint24_be(i8* %46)
%75 = icmp eq i8 %73, 0
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = icmp ugt i32 %65, 5
br i1 %77, label %131, label %143
78: ; preds = %72
%79 = load i8, i8* %61
%80 = and i8 %79, 3
%81 = add nuw nsw i8 %80, 1
%82 = icmp eq i8 %81, 4
br i1 %82, label %88, label %83
83: ; preds = %78
%84 = zext i8 %81 to i32
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %84)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %78
%89 = load i8, i8* %62
%90 = and i8 %89, 31
%91 = icmp eq i8 %90, 0
br i1 %91, label %108, label %92
92: ; preds = %88
%93 = zext i8 %90 to i32
br label %94
94: ; preds = %92, %94
%95 = phi i32 [ %105, %94 ], [ 11, %92 ]
%96 = phi i32 [ %106, %94 ], [ %93, %92 ]
%97 = sext i32 %95 to i64
%98 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %97
%99 = call i32 @get_uint16_be(i8* %98)
%100 = add nsw i32 %95, 2
%101 = call i32 @write(i32 %31, i8* %6, i32 4)
%102 = sext i32 %100 to i64
%103 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %102
%104 = call i32 @write(i32 %31, i8* %103, i32 %99)
%105 = add nsw i32 %99, %100
%106 = add nsw i32 %96, -1
%107 = icmp ugt i32 %96, 1
br i1 %107, label %94, label %108
108: ; preds = %94, %88
%109 = phi i32 [ 11, %88 ], [ %105, %94 ]
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %110
%112 = load i8, i8* %111
%113 = icmp eq i8 %112, 0
br i1 %113, label %150, label %114
114: ; preds = %108
%115 = zext i8 %112 to i32
%116 = add nsw i32 %109, 1
br label %117
117: ; preds = %114, %117
%118 = phi i32 [ %128, %117 ], [ %116, %114 ]
%119 = phi i32 [ %129, %117 ], [ %115, %114 ]
%120 = sext i32 %118 to i64
%121 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %120
%122 = call i32 @get_uint16_be(i8* %121)
%123 = add nsw i32 %118, 2
%124 = call i32 @write(i32 %31, i8* %6, i32 4)
%125 = sext i32 %123 to i64
%126 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %125
%127 = call i32 @write(i32 %31, i8* %126, i32 %122)
%128 = add nsw i32 %122, %123
%129 = add nsw i32 %119, -1
%130 = icmp ugt i32 %119, 1
br i1 %130, label %117, label %150
131: ; preds = %76, %131
%132 = phi i32 [ %141, %131 ], [ 5, %76 ]
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %133
%135 = call i32 @get_uint32_be(i8* %134)
%136 = add nsw i32 %132, 4
%137 = call i32 @write(i32 %31, i8* %6, i32 4)
%138 = sext i32 %136 to i64
%139 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %138
%140 = call i32 @write(i32 %31, i8* %139, i32 %135)
%141 = add nsw i32 %135, %136
%142 = icmp slt i32 %141, %65
br i1 %142, label %131, label %143
143: ; preds = %131, %76
%144 = phi i32 [ 5, %76 ], [ %141, %131 ]
%145 = icmp eq i32 %144, %65
br i1 %145, label %150, label %146
146: ; preds = %143
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%149 = call i32 @exit(i32 1)
unreachable
150: ; preds = %117, %108, %143, %69, %63
%151 = call i32 @read(i32 %16, i8* %5, i32 4)
%152 = call i32 @read(i32 %16, i8* %5, i32 11)
%153 = icmp eq i32 %152, 11
br i1 %153, label %63, label %154
154: ; preds = %150, %54
%155 = call i32 @close(i32 %16)
%156 = call i32 @close(i32 %31)
ret i32 0
}