#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*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char *buf, outbuf[20] = {0}, s[100] = {0}, def[100] = {0};
  int in1, in2, i = 0, r = 0, j = 0, count = 0, len1 = 0, len2 = 0;
  FILE *out1, *out2, *fd;
  if (argc < 3) {
    printf("usage: dump [file1] [file2]\n");
    return -1;
  }
  if ((in1 = open(argv[1], O_RDWR)) < 0 ||
      (in2 = open(argv[2], O_RDONLY)) < 0) {
    perror("open1");
    return errno;
  }
  len1 = lseek(in1, 0, SEEK_END);
  len2 = lseek(in2, 0, SEEK_END);
  sprintf(def, "#define CHARS %04d\n#define CHARS2 %03d\n\n", len2, len1 + 39);
  lseek(in2, 0, SEEK_SET);
  write(in1, def, strlen(def));
  close(in1);
  in1 = open(argv[1], O_RDONLY);
  if ((out1 = fopen("B", "a+")) == NULL || (out2 = fopen("C", "a+")) == NULL) {
    perror("fopen");
    return errno;
  }
  if ((buf = (char *)malloc(5000)) == NULL) {
    perror("malloc");
    return errno;
  }
  j = 1;
  fprintf(out1, "char B[] = \n\"");
  while ((r = read(in1, buf, 1000)) > 0) {
    for (i = 0; i < r; i++) {
      if ((j % 15) == 0) {
        fprintf(out1, "\"\n\"");
        j = 0;
      }
      j++;
      fprintf(out1, "\\x%02x", buf[i]);
    }
  }
  fprintf(out1, "\";\n\n");
  fprintf(out2, "char C[] = \n\"");
  j = 1;
  while ((r = read(in2, buf, 5000)) > 0) {
    printf("%d\n", r);
    for (i = 0; i < r; i++) {
      if ((j % 15) == 0) {
        fprintf(out2, "\"\n\"");
        j = 0;
      }
      j++;
      fprintf(out2, "\\x%02x", buf[i]);
    }
  }
  fprintf(out2, "\";\n\n");
  close(in1);
  close(in2);
  fclose(out2);
  fclose(out1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1080 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1080 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1080 <memset@plt>
movl   $0x0,-0x11c(%rbp)
movl   $0x0,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
movl   $0x0,-0x12c(%rbp)
movl   $0x0,-0x130(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    128f <main+0xaf>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1694 <main+0x4b4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x114(%rbp)
cmp    $0x0,%eax
jl     12d9 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x118(%rbp)
cmp    $0x0,%eax
jge    12f6 <main+0x116>
lea    0xd3d(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1694 <main+0x4b4>
mov    -0x114(%rbp),%edi
mov    0x2cdd(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x118(%rbp),%edi
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    %eax,-0x130(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x130(%rbp),%edx
mov    -0x12c(%rbp),%ecx
add    $0x27,%ecx
lea    0xcd8(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x118(%rbp),%edi
mov    0x2c63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    -0x114(%rbp),%eax
mov    %eax,-0x154(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x154(%rbp),%edi
mov    -0x150(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x114(%rbp),%edi
call   1090 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c1e(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x114(%rbp)
lea    0xc7e(%rip),%rdi
lea    0xc79(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
je     140f <main+0x22f>
lea    0xc5f(%rip),%rdi
lea    0xc55(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x140(%rbp)
cmp    $0x0,%rax
jne    142c <main+0x24c>
lea    0xc3d(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1694 <main+0x4b4>
mov    $0x1388,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1461 <main+0x281>
lea    0xc0e(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1694 <main+0x4b4>
movl   $0x1,-0x124(%rbp)
mov    -0x138(%rbp),%rdi
lea    0xbe7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x114(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x3e8,%edx
call   10a0 <read@plt>
mov    %eax,-0x120(%rbp)
cmp    $0x0,%eax
jle    1541 <main+0x361>
movl   $0x0,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x120(%rbp),%eax
jge    153c <main+0x35c>
mov    -0x124(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    14f5 <main+0x315>
mov    -0x138(%rbp),%rdi
lea    0xb8a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x11c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xb51(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    14ad <main+0x2cd>
jmp    1480 <main+0x2a0>
mov    -0x138(%rbp),%rdi
lea    0xb2a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x140(%rbp),%rdi
lea    0xb1a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x124(%rbp)
mov    -0x118(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x1388,%edx
call   10a0 <read@plt>
mov    %eax,-0x120(%rbp)
cmp    $0x0,%eax
jle    164a <main+0x46a>
mov    -0x120(%rbp),%esi
lea    0xae7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x120(%rbp),%eax
jge    1645 <main+0x465>
mov    -0x124(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    15fe <main+0x41e>
mov    -0x140(%rbp),%rdi
lea    0xa81(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
mov    -0x140(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x11c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xa48(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    15b6 <main+0x3d6>
jmp    1575 <main+0x395>
mov    -0x140(%rbp),%rdi
lea    0xa21(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x114(%rbp),%edi
call   1090 <close@plt>
mov    -0x118(%rbp),%edi
call   1090 <close@plt>
mov    -0x140(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x138(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x80(%rsp)
cmp    $0x2,%edi
jg     1248 <main+0x58>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    1571 <main+0x381>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
test   %eax,%eax
js     154a <main+0x35a>
mov    %eax,%r13d
mov    0x10(%r14),%rdi
mov    0x2d65(%rip),%r12
mov    (%r12),%esi
call   10d0 <open@plt>
test   %eax,%eax
js     154a <main+0x35a>
mov    %eax,%ebp
mov    0x2d53(%rip),%r15
mov    (%r15),%edx
mov    %r13d,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %eax,%ebx
mov    (%r15),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
add    $0x27,%ebx
lea    0xd54(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %eax,%edx
mov    %ebx,%ecx
call   1100 <sprintf@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%ebx
mov    %ebp,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %r13d,%edi
call   1090 <close@plt>
mov    0x8(%r14),%rdi
mov    (%r12),%esi
call   10d0 <open@plt>
mov    %eax,0xc(%rsp)
lea    0xd23(%rip),%rdi
lea    0xd1e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1553 <main+0x363>
lea    0xd07(%rip),%rdi
lea    0xcfd(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     1553 <main+0x363>
mov    $0x1388,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     155c <main+0x36c>
mov    %rax,%r13
lea    0xcdf(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1110 <fwrite@plt>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0x3e8,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1412 <main+0x222>
mov    $0x1,%ebp
lea    0xcb8(%rip),%r15
jmp    13b5 <main+0x1c5>
nop
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    $0x3e8,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1412 <main+0x222>
mov    %eax,%r14d
xor    %r12d,%r12d
jmp    13e1 <main+0x1f1>
nopl   (%rax)
add    $0x1,%ebp
movsbl 0x0(%r13,%r12,1),%edx
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     13a0 <main+0x1b0>
imul   $0xeeeeeeef,%ebp,%eax
add    $0x8888888,%eax
cmp    $0x11111110,%eax
ja     13c0 <main+0x1d0>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xc4d(%rip),%rdi
mov    0x10(%rsp),%rcx
call   1110 <fwrite@plt>
xor    %ebp,%ebp
jmp    13c0 <main+0x1d0>
lea    0xc43(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1110 <fwrite@plt>
lea    0xc2d(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   1110 <fwrite@plt>
mov    %ebx,%r12d
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x1388,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1505 <main+0x315>
mov    %eax,%ebp
mov    $0x1,%r14d
lea    0xbe4(%rip),%r15
jmp    1496 <main+0x2a6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x1388,%edx
call   10a0 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1505 <main+0x315>
lea    0xbd2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%ebp
xor    %ebx,%ebx
jmp    14d2 <main+0x2e2>
nopl   0x0(%rax)
add    $0x1,%r14d
movsbl 0x0(%r13,%rbx,1),%edx
mov    0x18(%rsp),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1480 <main+0x290>
imul   $0xeeeeeeef,%r14d,%eax
add    $0x8888888,%eax
cmp    $0x11111110,%eax
ja     14b0 <main+0x2c0>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xb5b(%rip),%rdi
mov    0x18(%rsp),%rcx
call   1110 <fwrite@plt>
xor    %r14d,%r14d
jmp    14b0 <main+0x2c0>
lea    0xb50(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rbx
mov    %rbx,%rcx
call   1110 <fwrite@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1571 <main+0x381>
lea    0xaaf(%rip),%rdi
jmp    1563 <main+0x373>
lea    0xadc(%rip),%rdi
jmp    1563 <main+0x373>
lea    0xad9(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2a59(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"usage: dump [file1] [file2]\0A\00"
@O_RDWR = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"open1\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.2 = [41 x i8] c"#define CHARS %04d\0A#define CHARS2 %03d\0A\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [3 x i8] c"a+\00"
@.str.5 = [2 x i8] c"C\00"
@.str.6 = [6 x i8] c"fopen\00"
@.str.7 = [7 x i8] c"malloc\00"
@.str.8 = [14 x i8] c"char B[] = \0A\22\00"
@.str.9 = [4 x i8] c"\22\0A\22\00"
@.str.10 = [7 x i8] c"\\x%02x\00"
@.str.11 = [5 x i8] c"\22;\0A\0A\00"
@.str.12 = [14 x i8] c"char C[] = \0A\22\00"
@.str.13 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [20 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = bitcast [20 x i8]* %7 to i8*
%22 = bitcast [100 x i8]* %8 to i8*
%23 = bitcast [100 x i8]* %9 to i8*
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
%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 ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %172
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i32, i32* @O_RDWR
%33 = call i32 @open(i8* %31, i32 %32)
store i32 %33, i32* %10
%34 = icmp slt i32 %33, 0
br i1 %34, label %42, label %35
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = load i32, i32* @O_RDONLY
%40 = call i32 @open(i8* %38, i32 %39)
store i32 %40, i32* %11
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %35, %28
%43 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32, i32* @errno
store i32 %44, i32* %3
br label %172
45: ; preds = %35
%46 = load i32, i32* %10
%47 = load i32, i32* @SEEK_END
%48 = call i32 @lseek(i32 %46, i32 0, i32 %47)
store i32 %48, i32* %16
%49 = load i32, i32* %11
%50 = load i32, i32* @SEEK_END
%51 = call i32 @lseek(i32 %49, i32 0, i32 %50)
store i32 %51, i32* %17
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%53 = load i32, i32* %17
%54 = load i32, i32* %16
%55 = add nsw i32 %54, 39
%56 = call i32 @sprintf(i8* %52, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %55)
%57 = load i32, i32* %11
%58 = load i32, i32* @SEEK_SET
%59 = call i32 @lseek(i32 %57, i32 0, i32 %58)
%60 = load i32, i32* %10
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @write(i32 %60, i8* %61, i32 %63)
%65 = load i32, i32* %10
%66 = call i32 @close(i32 %65)
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = load i32, i32* @O_RDONLY
%71 = call i32 @open(i8* %69, i32 %70)
store i32 %71, i32* %10
%72 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %72, i32** %18
%73 = icmp eq i32* %72, null
br i1 %73, label %77, label %74
74: ; preds = %45
%75 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %75, i32** %19
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %74, %45
%78 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%79 = load i32, i32* @errno
store i32 %79, i32* %3
br label %172
80: ; preds = %74
%81 = call i64 @malloc(i32 5000)
%82 = inttoptr i64 %81 to i8*
store i8* %82, i8** %6
%83 = icmp eq i8* %82, null
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%86 = load i32, i32* @errno
store i32 %86, i32* %3
br label %172
87: ; preds = %80
store i32 1, i32* %14
%88 = load i32*, i32** %18
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %90
90: ; preds = %121, %87
%91 = load i32, i32* %10
%92 = load i8*, i8** %6
%93 = call i32 @read(i32 %91, i8* %92, i32 1000)
store i32 %93, i32* %13
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %122
95: ; preds = %90
store i32 0, i32* %12
br label %96
96: ; preds = %118, %95
%97 = load i32, i32* %12
%98 = load i32, i32* %13
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %121
100: ; preds = %96
%101 = load i32, i32* %14
%102 = srem i32 %101, 15
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i32*, i32** %18
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %14
br label %107
107: ; preds = %104, %100
%108 = load i32, i32* %14
%109 = add nsw i32 %108, 1
store i32 %109, i32* %14
%110 = load i32*, i32** %18
%111 = load i8*, i8** %6
%112 = load i32, i32* %12
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %107
%119 = load i32, i32* %12
%120 = add nsw i32 %119, 1
store i32 %120, i32* %12
br label %96
121: ; preds = %96
br label %90
122: ; preds = %90
%123 = load i32*, i32** %18
%124 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%125 = load i32*, i32** %19
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %14
br label %127
127: ; preds = %160, %122
%128 = load i32, i32* %11
%129 = load i8*, i8** %6
%130 = call i32 @read(i32 %128, i8* %129, i32 5000)
store i32 %130, i32* %13
%131 = icmp sgt i32 %130, 0
br i1 %131, label %132, label %161
132: ; preds = %127
%133 = load i32, i32* %13
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %133)
store i32 0, i32* %12
br label %135
135: ; preds = %157, %132
%136 = load i32, i32* %12
%137 = load i32, i32* %13
%138 = icmp slt i32 %136, %137
br i1 %138, label %139, label %160
139: ; preds = %135
%140 = load i32, i32* %14
%141 = srem i32 %140, 15
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %139
%144 = load i32*, i32** %19
%145 = call i32 (i32*, i8*, ...) @fprintf(i32* %144, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %14
br label %146
146: ; preds = %143, %139
%147 = load i32, i32* %14
%148 = add nsw i32 %147, 1
store i32 %148, i32* %14
%149 = load i32*, i32** %19
%150 = load i8*, i8** %6
%151 = load i32, i32* %12
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8, i8* %150, i64 %152
%154 = load i8, i8* %153
%155 = sext i8 %154 to i32
%156 = call i32 (i32*, i8*, ...) @fprintf(i32* %149, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %155)
br label %157
157: ; preds = %146
%158 = load i32, i32* %12
%159 = add nsw i32 %158, 1
store i32 %159, i32* %12
br label %135
160: ; preds = %135
br label %127
161: ; preds = %127
%162 = load i32*, i32** %19
%163 = call i32 (i32*, i8*, ...) @fprintf(i32* %162, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%164 = load i32, i32* %10
%165 = call i32 @close(i32 %164)
%166 = load i32, i32* %11
%167 = call i32 @close(i32 %166)
%168 = load i32*, i32** %19
%169 = call i32 @fclose(i32* %168)
%170 = load i32*, i32** %18
%171 = call i32 @fclose(i32* %170)
store i32 0, i32* %3
br label %172
172: ; preds = %161, %84, %77, %42, %26
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"open1\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.2 = [41 x i8] c"#define CHARS %04d\0A#define CHARS2 %03d\0A\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [3 x i8] c"a+\00"
@.str.5 = [2 x i8] c"C\00"
@.str.6 = [6 x i8] c"fopen\00"
@.str.7 = [7 x i8] c"malloc\00"
@.str.8 = [14 x i8] c"char B[] = \0A\22\00"
@.str.9 = [4 x i8] c"\22\0A\22\00"
@.str.10 = [7 x i8] c"\\x%02x\00"
@.str.11 = [5 x i8] c"\22;\0A\0A\00"
@.str.12 = [14 x i8] c"char C[] = \0A\22\00"
@.str.13 = [4 x i8] c"%d\0A\00"
@str = [28 x i8] c"usage: dump [file1] [file2]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %115
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_RDWR
%12 = tail call i32 @open(i8* %10, i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %8
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 @open(i8* %16, i32 %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14, %8
%21 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @errno
br label %115
23: ; preds = %14
%24 = load i32, i32* @SEEK_END
%25 = tail call i32 @lseek(i32 %12, i32 0, i32 %24)
%26 = load i32, i32* @SEEK_END
%27 = tail call i32 @lseek(i32 %18, i32 0, i32 %26)
%28 = add nsw i32 %25, 39
%29 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @lseek(i32 %18, i32 0, i32 %30)
%32 = call i32 @strlen(i8* %4)
%33 = call i32 @write(i32 %12, i8* %4, i32 %32)
%34 = call i32 @close(i32 %12)
%35 = load i8*, i8** %9
%36 = load i32, i32* @O_RDONLY
%37 = call i32 @open(i8* %35, i32 %36)
%38 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %23
%41 = call i32* @fopen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %46
43: ; preds = %40, %23
%44 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%45 = load i32, i32* @errno
br label %115
46: ; preds = %40
%47 = call i64 @malloc(i32 5000)
%48 = inttoptr i64 %47 to i8*
%49 = icmp eq i64 %47, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%52 = load i32, i32* @errno
br label %115
53: ; preds = %46
%54 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i64 13, i64 1, i32* %38)
%55 = call i32 @read(i32 %37, i8* %48, i32 1000)
%56 = icmp sgt i32 %55, 0
br i1 %56, label %60, label %80
57: ; preds = %71
%58 = call i32 @read(i32 %37, i8* %48, i32 1000)
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %80
60: ; preds = %53, %57
%61 = phi i32 [ %58, %57 ], [ %55, %53 ]
%62 = phi i32 [ %73, %57 ], [ 1, %53 ]
%63 = zext i32 %61 to i64
br label %64
64: ; preds = %60, %71
%65 = phi i64 [ 0, %60 ], [ %78, %71 ]
%66 = phi i32 [ %62, %60 ], [ %73, %71 ]
%67 = srem i32 %66, 15
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64 3, i64 1, i32* %38)
br label %71
71: ; preds = %69, %64
%72 = phi i32 [ 0, %69 ], [ %66, %64 ]
%73 = add nsw i32 %72, 1
%74 = getelementptr inbounds i8, i8* %48, i64 %65
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %76)
%78 = add nuw nsw i64 %65, 1
%79 = icmp eq i64 %78, %63
br i1 %79, label %57, label %64
80: ; preds = %57, %53
%81 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64 4, i64 1, i32* %38)
%82 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i64 13, i64 1, i32* %41)
%83 = call i32 @read(i32 %18, i8* %48, i32 5000)
%84 = icmp sgt i32 %83, 0
br i1 %84, label %88, label %109
85: ; preds = %100
%86 = call i32 @read(i32 %18, i8* %48, i32 5000)
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %109
88: ; preds = %80, %85
%89 = phi i32 [ %86, %85 ], [ %83, %80 ]
%90 = phi i32 [ %102, %85 ], [ 1, %80 ]
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %89)
%92 = zext i32 %89 to i64
br label %93
93: ; preds = %88, %100
%94 = phi i64 [ 0, %88 ], [ %107, %100 ]
%95 = phi i32 [ %90, %88 ], [ %102, %100 ]
%96 = srem i32 %95, 15
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64 3, i64 1, i32* %41)
br label %100
100: ; preds = %98, %93
%101 = phi i32 [ 0, %98 ], [ %95, %93 ]
%102 = add nsw i32 %101, 1
%103 = getelementptr inbounds i8, i8* %48, i64 %94
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %105)
%107 = add nuw nsw i64 %94, 1
%108 = icmp eq i64 %107, %92
br i1 %108, label %85, label %93
109: ; preds = %85, %80
%110 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64 4, i64 1, i32* %41)
%111 = call i32 @close(i32 %37)
%112 = call i32 @close(i32 %18)
%113 = call i32 @fclose(i32* %41)
%114 = call i32 @fclose(i32* %38)
br label %115
115: ; preds = %109, %50, %43, %20, %6
%116 = phi i32 [ -1, %6 ], [ %22, %20 ], [ %45, %43 ], [ %52, %50 ], [ 0, %109 ]
ret i32 %116
}