#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*/ unified_boot_magic;
struct stat {
  unsigned int st_size;
};
typedef int /*<<< orphan*/ non_unified_boot_magic;

/* Variables and functions */
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ unlink(char *);
unsigned int write(int, unsigned int *, unsigned int);
int main(int argc, char *argv[]) {
  struct stat s;
  unsigned size, base;
  int unified_boot = 0;
  unsigned unified_boot_magic[20];
  unsigned non_unified_boot_magic[10];
  unsigned magic_len = 0;
  unsigned *magic;
  int fd;
  if (argc < 3) {
    fprintf(stderr, "usage: mkheader <bin> <hdr>\n");
    return -1;
  }
  if (argc == 4) {
    if (!strcmp("unified-boot", argv[3])) {
      unified_boot = 1;
    }
  }
  if (stat(argv[1], &s)) {
    perror("cannot stat binary");
    return -1;
  }
  if (unified_boot) {
    magic = unified_boot_magic;
    magic_len = sizeof(unified_boot_magic);
  } else {
    magic = non_unified_boot_magic;
    magic_len = sizeof(non_unified_boot_magic);
  }
  size = s.st_size;
  base = 0;
  magic[0] = 0x00000005;
  magic[1] = 0x00000002;
  magic[2] = 0x00000000;
  magic[3] = base;
  magic[4] = size;
  magic[5] = size;
  magic[6] = size + base;
  magic[7] = 0x00000000;
  magic[8] = size + base;
  magic[9] = 0x00000000;
  if (unified_boot == 1) {
    magic[10] = 0x33836685;
    magic[11] = 0x00000001;
    magic[12] = 0x00000002;
    magic[13] = 0x00000000;
    magic[14] = 0x00500000;
    magic[15] = 0x00000000;
    magic[16] = 0x00000000;
    magic[17] = 0x00000000;
    magic[18] = 0x00000000;
    magic[19] = 0x00000000;
  }
  fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
  if (fd < 0) {
    perror("cannot open header for writing");
    return -1;
  }
  if (write(fd, magic, magic_len) != magic_len) {
    perror("cannot write header");
    close(fd);
    unlink(argv[2]);
    return -1;
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d5 <main+0x55>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1464 <main+0x2e4>
cmpl   $0x4,-0x8(%rbp)
jne    1208 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe2f(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1203 <main+0x83>
movl   $0x1,-0x24(%rbp)
jmp    1208 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
je     123b <main+0xbb>
lea    0xe00(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1464 <main+0x2e4>
cmpl   $0x0,-0x24(%rbp)
je     125f <main+0xdf>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x50,-0xb4(%rbp)
jmp    1277 <main+0xf7>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x28,-0xb4(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0xc0(%rbp),%rax
movl   $0x5,(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x20(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x1c(%rax)
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x24(%rax)
cmpl   $0x1,-0x24(%rbp)
jne    13a6 <main+0x226>
mov    -0xc0(%rbp),%rax
movl   $0x33836685,0x28(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x1,0x2c(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x2,0x30(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x34(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x500000,0x38(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x3c(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x40(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x44(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x48(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x4c(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c0b(%rip),%rax
mov    (%rax),%esi
mov    0x2c3a(%rip),%rax
or     (%rax),%esi
mov    0x2c29(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,-0xc4(%rbp)
cmpl   $0x0,-0xc4(%rbp)
jge    13fe <main+0x27e>
lea    0xc50(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0xc4(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1040 <write@plt>
cmp    -0xb4(%rbp),%eax
je     1452 <main+0x2d2>
lea    0xc33(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc4(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1464 <main+0x2e4>
mov    -0xc4(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
cmp    $0x2,%edi
jg     11b3 <main+0x33>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13de <main+0x25e>
mov    %rsi,%r14
cmp    $0x4,%edi
jne    11d7 <main+0x57>
mov    0x18(%r14),%rsi
lea    0xe57(%rip),%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
sete   %r12b
setne  %bpl
jmp    11dd <main+0x5d>
mov    $0x1,%bpl
xor    %r12d,%r12d
mov    0x8(%r14),%rdi
lea    0x28(%rsp),%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    13ee <main+0x26e>
test   %bpl,%bpl
mov    $0x28,%eax
mov    $0x50,%r15d
cmovne %eax,%r15d
mov    %rsp,%rax
lea    0x30(%rsp),%rbx
cmovne %rax,%rbx
mov    0x28(%rsp),%eax
movl   $0x5,(%rbx)
lea    0x4(%rsp),%rcx
lea    0x34(%rsp),%rdx
cmovne %rcx,%rdx
movl   $0x2,(%rdx)
lea    0x8(%rsp),%rcx
lea    0x38(%rsp),%rdx
cmovne %rcx,%rdx
movl   $0x0,(%rdx)
lea    0xc(%rsp),%rcx
lea    0x3c(%rsp),%rdx
cmovne %rcx,%rdx
lea    0x10(%rsp),%rcx
lea    0x40(%rsp),%rsi
cmovne %rcx,%rsi
movl   $0x0,(%rdx)
mov    %eax,(%rsi)
lea    0x14(%rsp),%rcx
lea    0x44(%rsp),%rdx
cmovne %rcx,%rdx
mov    %eax,(%rdx)
lea    0x18(%rsp),%rcx
lea    0x48(%rsp),%rdx
cmovne %rcx,%rdx
mov    %eax,(%rdx)
lea    0x1c(%rsp),%rcx
lea    0x4c(%rsp),%rdx
cmovne %rcx,%rdx
lea    0x20(%rsp),%rcx
lea    0x50(%rsp),%rsi
cmovne %rcx,%rsi
movl   $0x0,(%rdx)
mov    %eax,(%rsi)
lea    0x24(%rsp),%rax
lea    0x54(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
test   %r12b,%r12b
je     1394 <main+0x214>
lea    0x28(%rsp),%rax
lea    0x58(%rsp),%rcx
test   %bpl,%bpl
cmovne %rax,%rcx
movl   $0x33836685,(%rcx)
lea    0x2c(%rsp),%rax
lea    0x5c(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x1,(%rcx)
lea    0x30(%rsp),%rax
lea    0x60(%rsp),%rcx
cmovne %rax,%rcx
lea    0x34(%rsp),%rax
lea    0x64(%rsp),%rdx
cmovne %rax,%rdx
movl   $0x2,(%rcx)
movl   $0x0,(%rdx)
lea    0x38(%rsp),%rax
lea    0x68(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x500000,(%rcx)
lea    0x3c(%rsp),%rax
lea    0x6c(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    0x40(%rsp),%rax
lea    0x70(%rsp),%rcx
cmovne %rax,%rcx
lea    0x44(%rsp),%rax
lea    0x74(%rsp),%rdx
cmovne %rax,%rdx
movl   $0x0,(%rcx)
movl   $0x0,(%rdx)
lea    0x48(%rsp),%rax
lea    0x78(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    0x4c(%rsp),%rax
lea    0x7c(%rsp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
mov    0x2c25(%rip),%rax
mov    0x2c56(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%r14),%rdi
mov    0x2c3f(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1090 <open@plt>
test   %eax,%eax
js     13f7 <main+0x277>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <write@plt>
cmp    %r15d,%eax
jne    140a <main+0x28a>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc35(%rip),%rdi
jmp    13fe <main+0x27e>
lea    0xc3f(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%eax
jmp    13de <main+0x25e>
lea    0xc4b(%rip),%rdi
call   10a0 <perror@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x10(%r14),%rdi
call   1030 <unlink@plt>
mov    $0xffffffff,%eax
jmp    13de <main+0x25e>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: mkheader <bin> <hdr>\0A\00"
@.str.1 = [13 x i8] c"unified-boot\00"
@.str.2 = [19 x i8] c"cannot stat binary\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [31 x i8] c"cannot open header for writing\00"
@.str.4 = [20 x i8] c"cannot write header\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [20 x i32]
%11 = alloca [10 x i32]
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %12
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %133
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call i32 @strcmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %23
store i32 1, i32* %9
br label %30
30: ; preds = %29, %23
br label %31
31: ; preds = %30, %20
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @stat(i8* %34, %struct.stat* %6)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %133
39: ; preds = %31
%40 = load i32, i32* %9
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = getelementptr inbounds [20 x i32], [20 x i32]* %10, i64 0, i64 0
store i32* %43, i32** %13
store i32 80, i32* %12
br label %46
44: ; preds = %39
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
store i32* %45, i32** %13
store i32 40, i32* %12
br label %46
46: ; preds = %44, %42
%47 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%48 = load i32, i32* %47
store i32 %48, i32* %7
store i32 0, i32* %8
%49 = load i32*, i32** %13
%50 = getelementptr inbounds i32, i32* %49, i64 0
store i32 5, i32* %50
%51 = load i32*, i32** %13
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32 2, i32* %52
%53 = load i32*, i32** %13
%54 = getelementptr inbounds i32, i32* %53, i64 2
store i32 0, i32* %54
%55 = load i32, i32* %8
%56 = load i32*, i32** %13
%57 = getelementptr inbounds i32, i32* %56, i64 3
store i32 %55, i32* %57
%58 = load i32, i32* %7
%59 = load i32*, i32** %13
%60 = getelementptr inbounds i32, i32* %59, i64 4
store i32 %58, i32* %60
%61 = load i32, i32* %7
%62 = load i32*, i32** %13
%63 = getelementptr inbounds i32, i32* %62, i64 5
store i32 %61, i32* %63
%64 = load i32, i32* %7
%65 = load i32, i32* %8
%66 = add i32 %64, %65
%67 = load i32*, i32** %13
%68 = getelementptr inbounds i32, i32* %67, i64 6
store i32 %66, i32* %68
%69 = load i32*, i32** %13
%70 = getelementptr inbounds i32, i32* %69, i64 7
store i32 0, i32* %70
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = add i32 %71, %72
%74 = load i32*, i32** %13
%75 = getelementptr inbounds i32, i32* %74, i64 8
store i32 %73, i32* %75
%76 = load i32*, i32** %13
%77 = getelementptr inbounds i32, i32* %76, i64 9
store i32 0, i32* %77
%78 = load i32, i32* %9
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %101
80: ; preds = %46
%81 = load i32*, i32** %13
%82 = getelementptr inbounds i32, i32* %81, i64 10
store i32 864249477, i32* %82
%83 = load i32*, i32** %13
%84 = getelementptr inbounds i32, i32* %83, i64 11
store i32 1, i32* %84
%85 = load i32*, i32** %13
%86 = getelementptr inbounds i32, i32* %85, i64 12
store i32 2, i32* %86
%87 = load i32*, i32** %13
%88 = getelementptr inbounds i32, i32* %87, i64 13
store i32 0, i32* %88
%89 = load i32*, i32** %13
%90 = getelementptr inbounds i32, i32* %89, i64 14
store i32 5242880, i32* %90
%91 = load i32*, i32** %13
%92 = getelementptr inbounds i32, i32* %91, i64 15
store i32 0, i32* %92
%93 = load i32*, i32** %13
%94 = getelementptr inbounds i32, i32* %93, i64 16
store i32 0, i32* %94
%95 = load i32*, i32** %13
%96 = getelementptr inbounds i32, i32* %95, i64 17
store i32 0, i32* %96
%97 = load i32*, i32** %13
%98 = getelementptr inbounds i32, i32* %97, i64 18
store i32 0, i32* %98
%99 = load i32*, i32** %13
%100 = getelementptr inbounds i32, i32* %99, i64 19
store i32 0, i32* %100
br label %101
101: ; preds = %80, %46
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 2
%104 = load i8*, i8** %103
%105 = load i32, i32* @O_WRONLY
%106 = load i32, i32* @O_CREAT
%107 = or i32 %105, %106
%108 = load i32, i32* @O_TRUNC
%109 = or i32 %107, %108
%110 = call i32 @open(i8* %104, i32 %109, i32 420)
store i32 %110, i32* %14
%111 = load i32, i32* %14
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %101
%114 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %133
115: ; preds = %101
%116 = load i32, i32* %14
%117 = load i32*, i32** %13
%118 = load i32, i32* %12
%119 = call i32 @write(i32 %116, i32* %117, i32 %118)
%120 = load i32, i32* %12
%121 = icmp ne i32 %119, %120
br i1 %121, label %122, label %130
122: ; preds = %115
%123 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%124 = load i32, i32* %14
%125 = call i32 @close(i32 %124)
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 2
%128 = load i8*, i8** %127
%129 = call i32 @unlink(i8* %128)
store i32 -1, i32* %3
br label %133
130: ; preds = %115
%131 = load i32, i32* %14
%132 = call i32 @close(i32 %131)
store i32 0, i32* %3
br label %133
133: ; preds = %130, %122, %113, %37, %17
%134 = load i32, i32* %3
ret i32 %134
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: mkheader <bin> <hdr>\0A\00"
@.str.1 = [13 x i8] c"unified-boot\00"
@.str.2 = [19 x i8] c"cannot stat binary\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [31 x i8] c"cannot open header for writing\00"
@.str.4 = [20 x i8] c"cannot write header\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [20 x i32]
%5 = alloca [10 x i32]
%6 = bitcast %struct.stat* %3 to i8*
%7 = bitcast [20 x i32]* %4 to i8*
%8 = bitcast [10 x i32]* %5 to i8*
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %117
13: ; preds = %2
%14 = icmp eq i32 %0, 4
br i1 %14, label %15, label %21
15: ; preds = %13
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %17)
%19 = icmp eq i32 %18, 0
%20 = xor i1 %19, true
br label %21
21: ; preds = %15, %13
%22 = phi i1 [ true, %13 ], [ %20, %15 ]
%23 = phi i1 [ false, %13 ], [ %19, %15 ]
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @stat(i8* %25, %struct.stat* %3)
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %21
%29 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %117
30: ; preds = %21
%31 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%33 = select i1 %22, i32 40, i32 80
%34 = select i1 %22, i32* %32, i32* %31
%35 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%36 = load i32, i32* %35
store i32 5, i32* %34
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 1
%38 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 1
%39 = select i1 %22, i32* %37, i32* %38
store i32 2, i32* %39
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 2
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 2
%42 = select i1 %22, i32* %40, i32* %41
store i32 0, i32* %42
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 3
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 3
%45 = select i1 %22, i32* %43, i32* %44
store i32 0, i32* %45
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 4
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 4
%48 = select i1 %22, i32* %46, i32* %47
store i32 %36, i32* %48
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 5
%50 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 5
%51 = select i1 %22, i32* %49, i32* %50
store i32 %36, i32* %51
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 6
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 6
%54 = select i1 %22, i32* %52, i32* %53
store i32 %36, i32* %54
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 7
%56 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 7
%57 = select i1 %22, i32* %55, i32* %56
store i32 0, i32* %57
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 8
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 8
%60 = select i1 %22, i32* %58, i32* %59
store i32 %36, i32* %60
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 9
%62 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 9
%63 = select i1 %22, i32* %61, i32* %62
store i32 0, i32* %63
br i1 %23, label %64, label %95
64: ; preds = %30
%65 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 10
%66 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 10
%67 = select i1 %22, i32* %65, i32* %66
store i32 864249477, i32* %67
%68 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 11
%69 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 11
%70 = select i1 %22, i32* %68, i32* %69
store i32 1, i32* %70
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 12
%72 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 12
%73 = select i1 %22, i32* %71, i32* %72
store i32 2, i32* %73
%74 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 13
%75 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 13
%76 = select i1 %22, i32* %74, i32* %75
store i32 0, i32* %76
%77 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 14
%78 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 14
%79 = select i1 %22, i32* %77, i32* %78
store i32 5242880, i32* %79
%80 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 15
%81 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 15
%82 = select i1 %22, i32* %80, i32* %81
store i32 0, i32* %82
%83 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 16
%84 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 16
%85 = select i1 %22, i32* %83, i32* %84
store i32 0, i32* %85
%86 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 17
%87 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 17
%88 = select i1 %22, i32* %86, i32* %87
store i32 0, i32* %88
%89 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 18
%90 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 18
%91 = select i1 %22, i32* %89, i32* %90
store i32 0, i32* %91
%92 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 19
%93 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 19
%94 = select i1 %22, i32* %92, i32* %93
store i32 0, i32* %94
br label %95
95: ; preds = %64, %30
%96 = getelementptr inbounds i8*, i8** %1, i64 2
%97 = load i8*, i8** %96
%98 = load i32, i32* @O_WRONLY
%99 = load i32, i32* @O_CREAT
%100 = or i32 %99, %98
%101 = load i32, i32* @O_TRUNC
%102 = or i32 %100, %101
%103 = call i32 @open(i8* %97, i32 %102, i32 420)
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %95
%106 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %117
107: ; preds = %95
%108 = call i32 @write(i32 %103, i32* %34, i32 %33)
%109 = icmp eq i32 %108, %33
br i1 %109, label %115, label %110
110: ; preds = %107
%111 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%112 = call i32 @close(i32 %103)
%113 = load i8*, i8** %96
%114 = call i32 @unlink(i8* %113)
br label %117
115: ; preds = %107
%116 = call i32 @close(i32 %103)
br label %117
117: ; preds = %115, %110, %105, %28, %10
%118 = phi i32 [ -1, %10 ], [ -1, %28 ], [ -1, %105 ], [ -1, %110 ], [ 0, %115 ]
ret i32 %118
}