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

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ write(int, unsigned char *, int);
int main(int argc, char **argv) {
  int f_in;
  int f_out;
  int address;
  int run;
  if (argc != 5) {
    printf("Usage: bin2z80 bin_file output_file dump_address run_address\n");
    return -1;
  }
  address = atoi(argv[3]);
  if (address == 0) {
    printf("Invalid address.\n");
    return -1;
  }
  run = atoi(argv[4]);
  if (run == 0) {
    printf("Invalid run address.\n");
    return -1;
  }
  f_in = open(argv[1], O_RDONLY);
  if (-1 == f_in) {
    printf("Can't open file %s. Aborting.\n", argv[1]);
    return -1;
  }
  f_out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
  if (-1 == f_out) {
    printf("Can't open file %s. Aborting.\n", argv[2]);
    return -1;
  }
  unsigned char buffer[49152];
  memset(buffer, 0, 49152);
  unsigned char b2[3];
  buffer[10] = 0x3F;
  buffer[12] = 0x0E;
  buffer[29] = 0x01;
  buffer[30] = 23;
  buffer[31] = 0;
  buffer[32] = run % 256;
  buffer[33] = run / 256;
  buffer[34] = 3;
  buffer[35] = 0x10;
  buffer[37] = 4;
  write(f_out, buffer, 55);
  memset(buffer, 0, 49152);
  memset(buffer + 6144, 56, 768);
  read(f_in, buffer + address - 16384, 49152);
  b2[0] = 0xFF;
  b2[1] = 0xFF;
  b2[2] = 8;
  write(f_out, b2, 3);
  write(f_out, buffer, 16384);
  b2[0] = 0xFF;
  b2[1] = 0xFF;
  b2[2] = 5;
  write(f_out, b2, 3);
  write(f_out, buffer + 16384, 16384);
  b2[0] = 0xFF;
  b2[1] = 0xFF;
  b2[2] = 3;
  write(f_out, b2, 3);
  write(f_out, buffer + 32768, 16384);
  close(f_in);
  close(f_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11ad <main+0x3d>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <main+0x310>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11e1 <main+0x71>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <main+0x310>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1215 <main+0xa5>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <main+0x310>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1260 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <main+0x310>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    0x2d80(%rip),%rax
or     (%rax),%esi
mov    0x2d6f(%rip),%rax
or     (%rax),%esi
mov    0x2d36(%rip),%rax
mov    (%rax),%edx
mov    0x2d3d(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
mov    $0xffffffff,%eax
cmp    -0x18(%rbp),%eax
jne    12cf <main+0x15f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1480 <main+0x310>
lea    -0xc020(%rbp),%rdi
xor    %esi,%esi
mov    $0xc000,%edx
call   1050 <memset@plt>
movb   $0x3f,-0xc016(%rbp)
movb   $0xe,-0xc014(%rbp)
movb   $0x1,-0xc003(%rbp)
movb   $0x17,-0xc002(%rbp)
movb   $0x0,-0xc001(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0xc000(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0xbfff(%rbp)
movb   $0x3,-0xbffe(%rbp)
movb   $0x10,-0xbffd(%rbp)
movb   $0x4,-0xbffb(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xc020(%rbp),%rsi
mov    $0x37,%edx
call   1030 <write@plt>
lea    -0xc020(%rbp),%rdi
xor    %esi,%esi
mov    $0xc000,%edx
call   1050 <memset@plt>
lea    -0xc020(%rbp),%rdi
add    $0x1800,%rdi
mov    $0x38,%esi
mov    $0x300,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0xc020(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
add    $0xffffffffffffc000,%rsi
mov    $0xc000,%edx
call   1070 <read@plt>
movb   $0xff,-0xc023(%rbp)
movb   $0xff,-0xc022(%rbp)
movb   $0x8,-0xc021(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xc023(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0xc020(%rbp),%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
movb   $0xff,-0xc023(%rbp)
movb   $0xff,-0xc022(%rbp)
movb   $0x5,-0xc021(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xc023(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0xc020(%rbp),%rsi
add    $0x4000,%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
movb   $0xff,-0xc023(%rbp)
movb   $0xff,-0xc022(%rbp)
movb   $0x3,-0xc021(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xc023(%rbp),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0xc020(%rbp),%rsi
add    $0x8000,%rsi
mov    $0x4000,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc018,%rsp
cmp    $0x5,%edi
jne    1371 <main+0x1f1>
mov    %rsi,%rbp
mov    0x18(%rsi),%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
je     137a <main+0x1fa>
mov    %eax,%r12d
mov    0x20(%rbp),%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
je     1383 <main+0x203>
mov    %eax,%r13d
mov    0x8(%rbp),%rdi
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     13a8 <main+0x228>
mov    %eax,%r14d
mov    0x10(%rbp),%rdi
mov    0x2dc0(%rip),%rax
mov    0x2e01(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dee(%rip),%rax
or     (%rax),%esi
mov    0x2db5(%rip),%rax
mov    0x2dbe(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     13ae <main+0x22e>
mov    %eax,%r15d
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc000,%edx
call   1060 <memset@plt>
movb   $0x3f,0x1a(%rsp)
movb   $0xe,0x1c(%rsp)
movw   $0x1701,0x2d(%rsp)
movb   $0x0,0x2f(%rsp)
lea    0xff(%r13),%eax
test   %r13d,%r13d
cmovns %r13d,%eax
mov    %r13b,0x30(%rsp)
mov    %ah,0x31(%rsp)
movw   $0x1003,0x32(%rsp)
movb   $0x4,0x35(%rsp)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x37,%edx
call   1040 <write@plt>
mov    %rbp,%rdi
mov    %rbp,%r13
xor    %esi,%esi
mov    $0xc000,%edx
call   1060 <memset@plt>
lea    0x1810(%rsp),%rdi
mov    $0x38,%esi
mov    $0x300,%edx
call   1060 <memset@plt>
movslq %r12d,%rax
lea    (%rsp,%rax,1),%rsi
add    $0xffffffffffffc010,%rsi
mov    %r14d,%edi
mov    $0xc000,%edx
call   1080 <read@plt>
movw   $0xffff,0xd(%rsp)
movb   $0x8,0xf(%rsp)
lea    0xd(%rsp),%rbp
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <write@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x4000,%edx
call   1040 <write@plt>
movw   $0xffff,0xd(%rsp)
movb   $0x5,0xf(%rsp)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <write@plt>
lea    0x4010(%rsp),%rsi
mov    %r15d,%edi
mov    $0x4000,%edx
call   1040 <write@plt>
movw   $0xffff,0xd(%rsp)
movb   $0x3,0xf(%rsp)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <write@plt>
lea    0x8010(%rsp),%rsi
mov    %r15d,%edi
mov    $0x4000,%edx
call   1040 <write@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    %r15d,%edi
call   1070 <close@plt>
jmp    1394 <main+0x214>
lea    0xccd(%rip),%rdi
jmp    138a <main+0x20a>
lea    0xcb3(%rip),%rdi
jmp    138a <main+0x20a>
lea    0xc95(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0xc018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbp),%rsi
jmp    13b2 <main+0x232>
mov    0x10(%rbp),%rsi
lea    0xc47(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    138f <main+0x20f>

LLVM IR (-O0):
@.str = [62 x i8] c"Usage: bin2z80 bin_file output_file dump_address run_address\0A\00"
@.str.1 = [18 x i8] c"Invalid address.\0A\00"
@.str.2 = [22 x i8] c"Invalid run address.\0A\00"
@O_RDONLY = global i32 0
@.str.3 = [31 x i8] c"Can't open file %s. Aborting.\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [49152 x i8]
%11 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
25: ; preds = %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %134
34: ; preds = %25
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDONLY
%39 = call i32 (i8*, i32, ...) @open(i8* %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp eq i32 -1, %40
br i1 %41, label %42, label %47
42: ; preds = %34
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %45)
store i32 -1, i32* %3
br label %134
47: ; preds = %34
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i32, i32* @O_WRONLY
%52 = load i32, i32* @O_CREAT
%53 = or i32 %51, %52
%54 = load i32, i32* @O_TRUNC
%55 = or i32 %53, %54
%56 = load i32, i32* @S_IRUSR
%57 = load i32, i32* @S_IWUSR
%58 = or i32 %56, %57
%59 = call i32 (i8*, i32, ...) @open(i8* %50, i32 %55, i32 %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp eq i32 -1, %60
br i1 %61, label %62, label %67
62: ; preds = %47
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %65)
store i32 -1, i32* %3
br label %134
67: ; preds = %47
%68 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%69 = call i32 @memset(i8* %68, i32 0, i32 49152)
%70 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 10
store i8 63, i8* %70
%71 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 12
store i8 14, i8* %71
%72 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 29
store i8 1, i8* %72
%73 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 30
store i8 23, i8* %73
%74 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 31
store i8 0, i8* %74
%75 = load i32, i32* %9
%76 = srem i32 %75, 256
%77 = trunc i32 %76 to i8
%78 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 32
store i8 %77, i8* %78
%79 = load i32, i32* %9
%80 = sdiv i32 %79, 256
%81 = trunc i32 %80 to i8
%82 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 33
store i8 %81, i8* %82
%83 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 34
store i8 3, i8* %83
%84 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 35
store i8 16, i8* %84
%85 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 37
store i8 4, i8* %85
%86 = load i32, i32* %7
%87 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%88 = call i32 @write(i32 %86, i8* %87, i32 55)
%89 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%90 = call i32 @memset(i8* %89, i32 0, i32 49152)
%91 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%92 = getelementptr inbounds i8, i8* %91, i64 6144
%93 = call i32 @memset(i8* %92, i32 56, i32 768)
%94 = load i32, i32* %6
%95 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%96 = load i32, i32* %8
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = getelementptr inbounds i8, i8* %98, i64 -16384
%100 = call i32 @read(i32 %94, i8* %99, i32 49152)
%101 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
store i8 -1, i8* %101
%102 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 1
store i8 -1, i8* %102
%103 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 2
store i8 8, i8* %103
%104 = load i32, i32* %7
%105 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%106 = call i32 @write(i32 %104, i8* %105, i32 3)
%107 = load i32, i32* %7
%108 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%109 = call i32 @write(i32 %107, i8* %108, i32 16384)
%110 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
store i8 -1, i8* %110
%111 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 1
store i8 -1, i8* %111
%112 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 2
store i8 5, i8* %112
%113 = load i32, i32* %7
%114 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%115 = call i32 @write(i32 %113, i8* %114, i32 3)
%116 = load i32, i32* %7
%117 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%118 = getelementptr inbounds i8, i8* %117, i64 16384
%119 = call i32 @write(i32 %116, i8* %118, i32 16384)
%120 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
store i8 -1, i8* %120
%121 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 1
store i8 -1, i8* %121
%122 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 2
store i8 3, i8* %122
%123 = load i32, i32* %7
%124 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%125 = call i32 @write(i32 %123, i8* %124, i32 3)
%126 = load i32, i32* %7
%127 = getelementptr inbounds [49152 x i8], [49152 x i8]* %10, i64 0, i64 0
%128 = getelementptr inbounds i8, i8* %127, i64 32768
%129 = call i32 @write(i32 %126, i8* %128, i32 16384)
%130 = load i32, i32* %6
%131 = call i32 @close(i32 %130)
%132 = load i32, i32* %7
%133 = call i32 @close(i32 %132)
store i32 0, i32* %3
br label %134
134: ; preds = %67, %62, %42, %32, %23, %14
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str.3 = [31 x i8] c"Can't open file %s. Aborting.\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@str = [21 x i8] c"Invalid run address.\00"
@str.4 = [17 x i8] c"Invalid address.\00"
@str.5 = [61 x i8] c"Usage: bin2z80 bin_file output_file dump_address run_address\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [49152 x i8]
%4 = alloca [3 x i8]
%5 = icmp eq i32 %0, 5
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.5, i64 0, i64 0))
br label %84
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0))
br label %84
15: ; preds = %8
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %84
22: ; preds = %15
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = tail call i32 (i8*, i32, ...) @open(i8* %24, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8*, i8** %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %84
31: ; preds = %22
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_WRONLY
%35 = load i32, i32* @O_CREAT
%36 = or i32 %35, %34
%37 = load i32, i32* @O_TRUNC
%38 = or i32 %36, %37
%39 = load i32, i32* @S_IRUSR
%40 = load i32, i32* @S_IWUSR
%41 = or i32 %40, %39
%42 = tail call i32 (i8*, i32, ...) @open(i8* %33, i32 %38, i32 %41)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %31
%45 = load i8*, i8** %32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %84
47: ; preds = %31
%48 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 0
%49 = call i32 @memset(i8* %48, i32 0, i32 49152)
%50 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%51 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 10
store i8 63, i8* %51
%52 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 12
store i8 14, i8* %52
%53 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 29
store i8 1, i8* %53
%54 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 30
store i8 23, i8* %54
%55 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 31
store i8 0, i8* %55
%56 = trunc i32 %18 to i8
%57 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 32
store i8 %56, i8* %57
%58 = sdiv i32 %18, 256
%59 = trunc i32 %58 to i8
%60 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 33
store i8 %59, i8* %60
%61 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 34
store i8 3, i8* %61
%62 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 35
store i8 16, i8* %62
%63 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 37
store i8 4, i8* %63
%64 = call i32 @write(i32 %42, i8* %48, i32 55)
%65 = call i32 @memset(i8* %48, i32 0, i32 49152)
%66 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 6144
%67 = call i32 @memset(i8* %66, i32 56, i32 768)
%68 = sext i32 %11 to i64
%69 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 %68
%70 = getelementptr inbounds i8, i8* %69, i64 -16384
%71 = call i32 @read(i32 %26, i8* %70, i32 49152)
store i8 -1, i8* %50
%72 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
store i8 -1, i8* %72
%73 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 8, i8* %73
%74 = call i32 @write(i32 %42, i8* %50, i32 3)
%75 = call i32 @write(i32 %42, i8* %48, i32 16384)
store i8 -1, i8* %50
store i8 -1, i8* %72
store i8 5, i8* %73
%76 = call i32 @write(i32 %42, i8* %50, i32 3)
%77 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 16384
%78 = call i32 @write(i32 %42, i8* %77, i32 16384)
store i8 -1, i8* %50
store i8 -1, i8* %72
store i8 3, i8* %73
%79 = call i32 @write(i32 %42, i8* %50, i32 3)
%80 = getelementptr inbounds [49152 x i8], [49152 x i8]* %3, i64 0, i64 32768
%81 = call i32 @write(i32 %42, i8* %80, i32 16384)
%82 = call i32 @close(i32 %26)
%83 = call i32 @close(i32 %42)
br label %84
84: ; preds = %47, %44, %28, %20, %13, %6
%85 = phi i32 [ -1, %6 ], [ -1, %13 ], [ -1, %20 ], [ -1, %28 ], [ -1, %44 ], [ 0, %47 ]
ret i32 %85
}