#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 char int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ chmod(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
char ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int);
int pack(char *runtime, char *exefile, char *datafile, char *outfile) {
  char buf[1024];
  int n = 0;
  char DX[2] = "DX";
  int32_t exesize = 0;
  int32_t datsize = 0;
  FILE *f = NULL;
  FILE *out = NULL;
  out = fopen(outfile, "wb");
  if (!out) {
    return 0;
  }
  f = fopen(runtime, "rb");
  if (!f) {
    printf("Could not open runtime\n");
    fclose(out);
    return 0;
  }
  while (!feof(f)) {
    n = fread(buf, 1, 1024, f);
    fwrite(buf, 1, n, out);
  }
  fclose(f);
  f = fopen(exefile, "rb");
  if (!f) {
    printf("Could not open div bytecode\n");
    fclose(out);
    return 0;
  }
  fseek(f, 0, SEEK_END);
  exesize = ftell(f);
  fseek(f, 0, SEEK_SET);
  while (!feof(f)) {
    n = fread(buf, 1, 1024, f);
    fwrite(buf, 1, n, out);
  }
  f = fopen(datafile, "rb");
  if (!f) {
    printf("Could not open div data %s\n", datafile);
    fclose(out);
    return 0;
  } else {
    fseek(f, 0, SEEK_END);
    datsize = ftell(f);
    fseek(f, 0, SEEK_SET);
    while (!feof(f)) {
      n = fread(buf, 1, 1024, f);
      fwrite(buf, 1, n, out);
    }
    fclose(f);
  }
  fwrite(&exesize, 4, 1, out);
  fwrite(&datsize, 4, 1, out);
  fwrite(DX, 2, 1, out);
  fclose(out);
  chmod(outfile, strtol("0777", NULL, 8));
}


x86 assembly (clang, -O0):
<pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x434(%rbp)
mov    0xe34(%rip),%ax
mov    %ax,-0x436(%rbp)
movb   $0x0,-0x437(%rbp)
movb   $0x0,-0x438(%rbp)
movq   $0x0,-0x440(%rbp)
movq   $0x0,-0x448(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
jne    1228 <pack+0x88>
movl   $0x0,-0x4(%rbp)
jmp    1570 <pack+0x3d0>
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    1273 <pack+0xd3>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x448(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1570 <pack+0x3d0>
jmp    1278 <pack+0xd8>
mov    -0x440(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1299 <pack+0xf9>
jmp    12df <pack+0x13f>
lea    -0x430(%rbp),%rdi
mov    -0x440(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x434(%rbp),%edx
mov    -0x448(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
jmp    1278 <pack+0xd8>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
lea    0xd0f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    1336 <pack+0x196>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x448(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1570 <pack+0x3d0>
mov    -0x440(%rbp),%rdi
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x440(%rbp),%rdi
call   1060 <ftell@plt>
mov    %al,-0x437(%rbp)
mov    -0x440(%rbp),%rdi
mov    0x2c6b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x440(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1397 <pack+0x1f7>
jmp    13dd <pack+0x23d>
lea    -0x430(%rbp),%rdi
mov    -0x440(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x434(%rbp),%edx
mov    -0x448(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
jmp    1376 <pack+0x1d6>
mov    -0x20(%rbp),%rdi
lea    0xc1d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    142c <pack+0x28c>
mov    -0x20(%rbp),%rsi
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x448(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1570 <pack+0x3d0>
mov    -0x440(%rbp),%rdi
mov    0x2bae(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x440(%rbp),%rdi
call   1060 <ftell@plt>
mov    %al,-0x438(%rbp)
mov    -0x440(%rbp),%rdi
mov    0x2b75(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x440(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    148d <pack+0x2ed>
jmp    14d3 <pack+0x333>
lea    -0x430(%rbp),%rdi
mov    -0x440(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x434(%rbp),%edx
mov    -0x448(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
jmp    146c <pack+0x2cc>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x448(%rbp),%rcx
lea    -0x437(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
mov    -0x448(%rbp),%rcx
lea    -0x438(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
lea    -0x436(%rbp),%rdi
mov    -0x448(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
mov    -0x448(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    0xb05(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1080 <strtol@plt>
mov    -0x450(%rbp),%rdi
mov    %eax,%esi
call   10a0 <chmod@plt>
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movw   $0x5844,0xe(%rsp)
lea    0xe35(%rip),%rsi
mov    %rcx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f4 <pack+0x254>
mov    %rax,%r13
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13d7 <pack+0x237>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1243 <pack+0xa3>
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1210 <pack+0x70>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xdb1(%rip),%rsi
mov    %r12,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13e0 <pack+0x240>
mov    %rax,%rbx
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %al,0xd(%rsp)
mov    0x2d4c(%rip),%r12
mov    (%r12),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    12e3 <pack+0x143>
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     12b0 <pack+0x110>
lea    0xd19(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1408 <pack+0x268>
mov    %rax,%rbx
mov    0x2ce3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %al,0xc(%rsp)
mov    (%r12),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1373 <pack+0x1d3>
lea    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1340 <pack+0x1a0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xd(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
mov    $0x1ff,%esi
call   10a0 <chmod@plt>
jmp    13f4 <pack+0x254>
lea    0xc44(%rip),%rdi
jmp    13e7 <pack+0x247>
lea    0xc52(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf7(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13ec <pack+0x24c>

LLVM IR (-O0):
@__const.pack.DX = [2 x i8] c"DX"
@.str = [3 x i8] c"wb\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"Could not open runtime\0A\00"
@.str.3 = [29 x i8] c"Could not open div bytecode\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [28 x i8] c"Could not open div data %s\0A\00"
@.str.5 = [5 x i8] c"0777\00"
define i32 @pack(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca [2 x i8]
%13 = alloca i8
%14 = alloca i8
%15 = alloca i32*
%16 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %11
%17 = bitcast [2 x i8]* %12 to i8*
store i8 0, i8* %13
store i8 0, i8* %14
store i32* null, i32** %15
store i32* null, i32** %16
%18 = load i8*, i8** %9
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %16
%20 = load i32*, i32** %16
%21 = icmp ne i32* %20, null
br i1 %21, label %23, label %22
22: ; preds = %4
store i32 0, i32* %5
br label %127
23: ; preds = %4
%24 = load i8*, i8** %6
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %15
%26 = load i32*, i32** %15
%27 = icmp ne i32* %26, null
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32*, i32** %16
%31 = call i32 @fclose(i32* %30)
store i32 0, i32* %5
br label %127
32: ; preds = %23
br label %33
33: ; preds = %38, %32
%34 = load i32*, i32** %15
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%40 = load i32*, i32** %15
%41 = call i32 @fread(i8* %39, i32 1, i32 1024, i32* %40)
store i32 %41, i32* %11
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%43 = load i32, i32* %11
%44 = load i32*, i32** %16
%45 = call i32 @fwrite(i8* %42, i32 1, i32 %43, i32* %44)
br label %33
46: ; preds = %33
%47 = load i32*, i32** %15
%48 = call i32 @fclose(i32* %47)
%49 = load i8*, i8** %7
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %50, i32** %15
%51 = load i32*, i32** %15
%52 = icmp ne i32* %51, null
br i1 %52, label %57, label %53
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32*, i32** %16
%56 = call i32 @fclose(i32* %55)
store i32 0, i32* %5
br label %127
57: ; preds = %46
%58 = load i32*, i32** %15
%59 = load i32, i32* @SEEK_END
%60 = call i32 @fseek(i32* %58, i32 0, i32 %59)
%61 = load i32*, i32** %15
%62 = call signext i8 @ftell(i32* %61)
store i8 %62, i8* %13
%63 = load i32*, i32** %15
%64 = load i32, i32* @SEEK_SET
%65 = call i32 @fseek(i32* %63, i32 0, i32 %64)
br label %66
66: ; preds = %71, %57
%67 = load i32*, i32** %15
%68 = call i32 @feof(i32* %67)
%69 = icmp ne i32 %68, 0
%70 = xor i1 %69, true
br i1 %70, label %71, label %79
71: ; preds = %66
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%73 = load i32*, i32** %15
%74 = call i32 @fread(i8* %72, i32 1, i32 1024, i32* %73)
store i32 %74, i32* %11
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%76 = load i32, i32* %11
%77 = load i32*, i32** %16
%78 = call i32 @fwrite(i8* %75, i32 1, i32 %76, i32* %77)
br label %66
79: ; preds = %66
%80 = load i8*, i8** %8
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %81, i32** %15
%82 = load i32*, i32** %15
%83 = icmp ne i32* %82, null
br i1 %83, label %89, label %84
84: ; preds = %79
%85 = load i8*, i8** %8
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %85)
%87 = load i32*, i32** %16
%88 = call i32 @fclose(i32* %87)
store i32 0, i32* %5
br label %127
89: ; preds = %79
%90 = load i32*, i32** %15
%91 = load i32, i32* @SEEK_END
%92 = call i32 @fseek(i32* %90, i32 0, i32 %91)
%93 = load i32*, i32** %15
%94 = call signext i8 @ftell(i32* %93)
store i8 %94, i8* %14
%95 = load i32*, i32** %15
%96 = load i32, i32* @SEEK_SET
%97 = call i32 @fseek(i32* %95, i32 0, i32 %96)
br label %98
98: ; preds = %103, %89
%99 = load i32*, i32** %15
%100 = call i32 @feof(i32* %99)
%101 = icmp ne i32 %100, 0
%102 = xor i1 %101, true
br i1 %102, label %103, label %111
103: ; preds = %98
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%105 = load i32*, i32** %15
%106 = call i32 @fread(i8* %104, i32 1, i32 1024, i32* %105)
store i32 %106, i32* %11
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%108 = load i32, i32* %11
%109 = load i32*, i32** %16
%110 = call i32 @fwrite(i8* %107, i32 1, i32 %108, i32* %109)
br label %98
111: ; preds = %98
%112 = load i32*, i32** %15
%113 = call i32 @fclose(i32* %112)
br label %114
114: ; preds = %111
%115 = load i32*, i32** %16
%116 = call i32 @fwrite(i8* %13, i32 4, i32 1, i32* %115)
%117 = load i32*, i32** %16
%118 = call i32 @fwrite(i8* %14, i32 4, i32 1, i32* %117)
%119 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%120 = load i32*, i32** %16
%121 = call i32 @fwrite(i8* %119, i32 2, i32 1, i32* %120)
%122 = load i32*, i32** %16
%123 = call i32 @fclose(i32* %122)
%124 = load i8*, i8** %9
%125 = call i32 @strtol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* null, i32 8)
%126 = call i32 @chmod(i8* %124, i32 %125)
br label %127
127: ; preds = %114, %84, %53, %28, %22
%128 = load i32, i32* %5
ret i32 %128
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [28 x i8] c"Could not open div data %s\0A\00"
@str = [23 x i8] c"Could not open runtime\00"
@str.6 = [28 x i8] c"Could not open div bytecode\00"
define i32 @pack(i8* nocapture %0, i8* nocapture %1, i8* %2, i8* nocapture %3) {
%5 = alloca [1024 x i8]
%6 = alloca i16
%7 = alloca i8
%8 = alloca i8
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = bitcast i16* %6 to i8*
store i16 22596, i16* %6
%11 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %73, label %13
13: ; preds = %4
%14 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 @feof(i32* %14)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %27
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%21 = tail call i32 @fclose(i32* %11)
br label %73
22: ; preds = %16, %22
%23 = call i32 @fread(i8* %9, i32 1, i32 1024, i32* %14)
%24 = call i32 @fwrite(i8* %9, i32 1, i32 %23, i32* %11)
%25 = tail call i32 @feof(i32* %14)
%26 = icmp eq i32 %25, 0
br i1 %26, label %22, label %27
27: ; preds = %22, %16
%28 = tail call i32 @fclose(i32* %14)
%29 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%33 = tail call i32 @fclose(i32* %11)
br label %73
34: ; preds = %27
%35 = load i32, i32* @SEEK_END
%36 = tail call i32 @fseek(i32* %29, i32 0, i32 %35)
%37 = tail call signext i8 @ftell(i32* %29)
store i8 %37, i8* %7
%38 = load i32, i32* @SEEK_SET
%39 = tail call i32 @fseek(i32* %29, i32 0, i32 %38)
%40 = tail call i32 @feof(i32* %29)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %34, %42
%43 = call i32 @fread(i8* %9, i32 1, i32 1024, i32* %29)
%44 = call i32 @fwrite(i8* %9, i32 1, i32 %43, i32* %11)
%45 = tail call i32 @feof(i32* %29)
%46 = icmp eq i32 %45, 0
br i1 %46, label %42, label %47
47: ; preds = %42, %34
%48 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%52 = tail call i32 @fclose(i32* %11)
br label %73
53: ; preds = %47
%54 = load i32, i32* @SEEK_END
%55 = tail call i32 @fseek(i32* %48, i32 0, i32 %54)
%56 = tail call signext i8 @ftell(i32* %48)
store i8 %56, i8* %8
%57 = load i32, i32* @SEEK_SET
%58 = tail call i32 @fseek(i32* %48, i32 0, i32 %57)
%59 = tail call i32 @feof(i32* %48)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %53, %61
%62 = call i32 @fread(i8* %9, i32 1, i32 1024, i32* %48)
%63 = call i32 @fwrite(i8* %9, i32 1, i32 %62, i32* %11)
%64 = tail call i32 @feof(i32* %48)
%65 = icmp eq i32 %64, 0
br i1 %65, label %61, label %66
66: ; preds = %61, %53
%67 = tail call i32 @fclose(i32* %48)
%68 = call i32 @fwrite(i8* %7, i32 4, i32 1, i32* %11)
%69 = call i32 @fwrite(i8* %8, i32 4, i32 1, i32* %11)
%70 = call i32 @fwrite(i8* %10, i32 2, i32 1, i32* %11)
%71 = tail call i32 @fclose(i32* %11)
%72 = tail call i32 @chmod(i8* %3, i32 511)
br label %73
73: ; preds = %4, %66, %50, %31, %19
ret i32 0
}