#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(char *, int, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int, unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char *, char *, int);
void *strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  FILE *out, *in;
  int size;
  char buffer[65536];
  int a;
  size_t readed;
  int ret = 0;
  unsigned int bs = 0x10000;
  while (argv[1][0] == '-') {
    if (!strncmp(&argv[1][1], "bs", 2)) {
      bs = strtoul(&argv[1][4], NULL, 0);
      argv++;
      argc--;
    } else
      break;
  }
  if (argc < 4) {
    fprintf(stderr, "#> appendbin [-bs=block_size] appendto binfile size\n");
    fprintf(stderr, "   size must be multiple of 65536...\n");
    return -1;
  }
  out = fopen(*(argv + 1), "ab");
  if (out == NULL) {
    fprintf(stderr, "cannot open output file...(%s)\n", *(argv + 1));
    return -1;
  }
  in = fopen(*(argv + 2), "rb");
  if (in == NULL) {
    fprintf(stderr, "cannot open input file...(%s)\n", *(argv + 2));
    fclose(out);
    return -1;
  }
  size = strtoul(*(argv + 3), NULL, 0);
  fseek(in, 0, SEEK_END);
  if (ftell(in) > size * bs) {
    fprintf(stderr, "Oops. file is too big.\n");
    ret = -1;
    goto terminate;
  }
  fseek(in, 0, SEEK_SET);
  for (a = 0; a < size; a++) {
    readed = fread(buffer, 1, bs, in);
    if (readed)
      fwrite(buffer, 1, readed, out);
    if (readed < bs) {
      memset(buffer, 0xff, bs - readed);
      fwrite(buffer, 1, bs - readed, out);
    }
  }
terminate:
  fclose(in);
  fclose(out);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x10044(%rbp)
movl   $0x10000,-0x10048(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1248 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x1,%rdi
lea    0xe0c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    123e <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x4,%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %eax,-0x10048(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1243 <main+0xa3>
jmp    1248 <main+0xa8>
jmp    11cd <main+0x2d>
cmpl   $0x4,-0x8(%rbp)
jge    128c <main+0xec>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14aa <main+0x30a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc3(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12da <main+0x13a>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14aa <main+0x30a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd98(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1331 <main+0x191>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14aa <main+0x30a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2c96(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    -0x24(%rbp),%ecx
imul   -0x10048(%rbp),%ecx
cmp    %ecx,%eax
jbe    139c <main+0x1fc>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x10044(%rbp)
ff ff ff
jmp    148f <main+0x2ef>
mov    -0x20(%rbp),%rdi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
movl   $0x0,-0x10034(%rbp)
mov    -0x10034(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    148a <main+0x2ea>
lea    -0x10030(%rbp),%rdi
mov    -0x10048(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x10040(%rbp)
cmpq   $0x0,-0x10040(%rbp)
je     1417 <main+0x277>
lea    -0x10030(%rbp),%rdi
mov    -0x10040(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    -0x10040(%rbp),%rax
mov    -0x10048(%rbp),%ecx
cmp    %rcx,%rax
jae    1471 <main+0x2d1>
lea    -0x10030(%rbp),%rdi
mov    -0x10048(%rbp),%eax
sub    -0x10040(%rbp),%rax
mov    %eax,%edx
mov    $0xff,%esi
call   1060 <memset@plt>
lea    -0x10030(%rbp),%rdi
mov    -0x10048(%rbp),%eax
sub    -0x10040(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
jmp    1476 <main+0x2d6>
mov    -0x10034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10034(%rbp)
jmp    13ba <main+0x21a>
jmp    148f <main+0x2ef>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10044(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10028,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
lea    0x8(%rsi),%rbx
mov    0x8(%rsi),%rdi
mov    $0x10000,%r13d
cmpb   $0x2d,(%rdi)
jne    11e3 <main+0x43>
add    $0x1,%rdi
lea    0xe2b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121e <main+0x7e>
cmp    $0x3,%r14d
jg     127e <main+0xde>
mov    0x2de4(%rip),%rbx
mov    (%rbx),%edi
lea    0xe06(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe2b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1427 <main+0x287>
add    $0xffffffff,%r14d
add    $0x10,%rbp
lea    0xdd3(%rip),%r15
mov    %r14d,%ecx
mov    %ecx,%r14d
mov    %rbp,%rbx
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,%r13
mov    0x0(%rbp),%rdi
cmpb   $0x2d,(%rdi)
jne    1270 <main+0xd0>
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
lea    -0x1(%r14),%ecx
lea    0x8(%rbx),%rbp
test   %eax,%eax
je     1230 <main+0x90>
lea    -0x8(%rbx),%rbp
cmp    $0x3,%r14d
jle    11ed <main+0x4d>
mov    (%rbx),%rdi
lea    0xdd6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1312 <main+0x172>
mov    0x10(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1336 <main+0x196>
mov    0x18(%rbp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,%rbx
mov    0x2d1a(%rip),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %r13d,%ecx
imul   %ebx,%ecx
cmp    %ecx,%eax
jbe    1365 <main+0x1c5>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xda2(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1413 <main+0x273>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd3c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1427 <main+0x287>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xd3a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x10(%rsp),%rdi
call   1050 <fclose@plt>
mov    $0xffffffff,%ebp
jmp    1427 <main+0x287>
mov    0x2c64(%rip),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
test   %ebx,%ebx
jle    1413 <main+0x273>
mov    %r13d,%r15d
lea    0x20(%rsp),%rbp
mov    %r15,0x18(%rsp)
jmp    13a5 <main+0x205>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
je     1411 <main+0x271>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    0x8(%rsp),%rcx
call   1040 <fread@plt>
mov    %rax,%r12
test   %rax,%rax
je     13d7 <main+0x237>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    0x10(%rsp),%rcx
call   10c0 <fwrite@plt>
cmp    %r15,%r12
jae    13a0 <main+0x200>
mov    %r13d,%r14d
sub    %r12d,%r14d
mov    %rbp,%r12
mov    %rbp,%rdi
mov    $0xff,%esi
mov    %r14d,%edx
call   1060 <memset@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r15
call   10c0 <fwrite@plt>
jmp    13a0 <main+0x200>
xor    %ebp,%ebp
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x10028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"bs\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"#> appendbin [-bs=block_size] appendto binfile size\0A\00"
@.str.2 = [38 x i8] c" size must be multiple of 65536...\0A\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [32 x i8] c"cannot open output file...(%s)\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [31 x i8] c"cannot open input file...(%s)\0A\00"
@SEEK_END = global i32 0
@.str.7 = [24 x i8] c"Oops. file is too big.\0A\00"
@SEEK_SET = 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 [65536 x i8]
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i32 65536, i32* %13
br label %14
14: ; preds = %41, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %42
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @strncmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%28 = icmp ne i32 %27, 0
br i1 %28, label %40, label %29
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 4
%34 = call i8* @strtoul(i8* %33, i32* null, i32 0)
%35 = ptrtoint i8* %34 to i32
store i32 %35, i32* %13
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i32 1
store i8** %37, i8*** %5
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
br label %41
40: ; preds = %22
br label %42
41: ; preds = %29
br label %14
42: ; preds = %40, %14
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 4
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %149
50: ; preds = %42
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %54, i32** %6
%55 = load i32*, i32** %6
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %63
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %61)
store i32 -1, i32* %3
br label %149
63: ; preds = %50
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 2
%66 = load i8*, i8** %65
%67 = call i32* @fopen(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %67, i32** %7
%68 = load i32*, i32** %7
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %78
70: ; preds = %63
%71 = load i32, i32* @stderr
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %74)
%76 = load i32*, i32** %6
%77 = call i32 @fclose(i32* %76)
store i32 -1, i32* %3
br label %149
78: ; preds = %63
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 3
%81 = load i8*, i8** %80
%82 = call i8* @strtoul(i8* %81, i32* null, i32 0)
%83 = ptrtoint i8* %82 to i32
store i32 %83, i32* %8
%84 = load i32*, i32** %7
%85 = load i32, i32* @SEEK_END
%86 = call i32 @fseek(i32* %84, i32 0, i32 %85)
%87 = load i32*, i32** %7
%88 = call i32 @ftell(i32* %87)
%89 = load i32, i32* %8
%90 = load i32, i32* %13
%91 = mul i32 %89, %90
%92 = icmp ugt i32 %88, %91
br i1 %92, label %93, label %96
93: ; preds = %78
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %12
br label %143
96: ; preds = %78
%97 = load i32*, i32** %7
%98 = load i32, i32* @SEEK_SET
%99 = call i32 @fseek(i32* %97, i32 0, i32 %98)
store i32 0, i32* %10
br label %100
100: ; preds = %139, %96
%101 = load i32, i32* %10
%102 = load i32, i32* %8
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %142
104: ; preds = %100
%105 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%106 = load i32, i32* %13
%107 = load i32*, i32** %7
%108 = call i64 @fread(i8* %105, i32 1, i32 %106, i32* %107)
store i64 %108, i64* %11
%109 = load i64, i64* %11
%110 = icmp ne i64 %109, 0
br i1 %110, label %111, label %117
111: ; preds = %104
%112 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%113 = load i64, i64* %11
%114 = trunc i64 %113 to i32
%115 = load i32*, i32** %6
%116 = call i32 @fwrite(i8* %112, i32 1, i32 %114, i32* %115)
br label %117
117: ; preds = %111, %104
%118 = load i64, i64* %11
%119 = load i32, i32* %13
%120 = zext i32 %119 to i64
%121 = icmp ult i64 %118, %120
br i1 %121, label %122, label %138
122: ; preds = %117
%123 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%124 = load i32, i32* %13
%125 = zext i32 %124 to i64
%126 = load i64, i64* %11
%127 = sub i64 %125, %126
%128 = trunc i64 %127 to i32
%129 = call i32 @memset(i8* %123, i32 255, i32 %128)
%130 = getelementptr inbounds [65536 x i8], [65536 x i8]* %9, i64 0, i64 0
%131 = load i32, i32* %13
%132 = zext i32 %131 to i64
%133 = load i64, i64* %11
%134 = sub i64 %132, %133
%135 = trunc i64 %134 to i32
%136 = load i32*, i32** %6
%137 = call i32 @fwrite(i8* %130, i32 1, i32 %135, i32* %136)
br label %138
138: ; preds = %122, %117
br label %139
139: ; preds = %138
%140 = load i32, i32* %10
%141 = add nsw i32 %140, 1
store i32 %141, i32* %10
br label %100
142: ; preds = %100
br label %143
143: ; preds = %142, %93
%144 = load i32*, i32** %7
%145 = call i32 @fclose(i32* %144)
%146 = load i32*, i32** %6
%147 = call i32 @fclose(i32* %146)
%148 = load i32, i32* %12
store i32 %148, i32* %3
br label %149
149: ; preds = %143, %70, %57, %45
%150 = load i32, i32* %3
ret i32 %150
}

LLVM IR (-O2):
@.str = [3 x i8] c"bs\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"#> appendbin [-bs=block_size] appendto binfile size\0A\00"
@.str.2 = [38 x i8] c" size must be multiple of 65536...\0A\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [32 x i8] c"cannot open output file...(%s)\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [31 x i8] c"cannot open input file...(%s)\0A\00"
@SEEK_END = global i32 0
@.str.7 = [24 x i8] c"Oops. file is too big.\0A\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %9, label %34
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = tail call i32 @strncmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %34
13: ; preds = %17
%14 = getelementptr inbounds i8, i8* %25, i64 1
%15 = tail call i32 @strncmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %9, %13
%18 = phi i32 [ %23, %13 ], [ %0, %9 ]
%19 = phi i8** [ %24, %13 ], [ %5, %9 ]
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 4
%22 = tail call i8* @strtoul(i8* nocapture %21, i32* null, i32 0)
%23 = add nsw i32 %18, -1
%24 = getelementptr inbounds i8*, i8** %19, i64 1
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 45
br i1 %27, label %13, label %28
28: ; preds = %17
%29 = ptrtoint i8* %22 to i64
%30 = trunc i64 %29 to i32
br label %34
31: ; preds = %13
%32 = ptrtoint i8* %22 to i64
%33 = trunc i64 %32 to i32
br label %34
34: ; preds = %9, %31, %28, %2
%35 = phi i8** [ %1, %2 ], [ %19, %28 ], [ %19, %31 ], [ %1, %9 ]
%36 = phi i32 [ %0, %2 ], [ %23, %28 ], [ %23, %31 ], [ %0, %9 ]
%37 = phi i32 [ 65536, %2 ], [ %30, %28 ], [ %33, %31 ], [ 65536, %9 ]
%38 = phi i8** [ %5, %2 ], [ %24, %28 ], [ %24, %31 ], [ %5, %9 ]
%39 = icmp slt i32 %36, 4
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %104
45: ; preds = %34
%46 = load i8*, i8** %38
%47 = tail call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %38
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %51)
br label %104
53: ; preds = %45
%54 = getelementptr inbounds i8*, i8** %35, i64 2
%55 = load i8*, i8** %54
%56 = tail call i32* @fopen(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %63
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %54
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %60)
%62 = tail call i32 @fclose(i32* %47)
br label %104
63: ; preds = %53
%64 = getelementptr inbounds i8*, i8** %35, i64 3
%65 = load i8*, i8** %64
%66 = tail call i8* @strtoul(i8* nocapture %65, i32* null, i32 0)
%67 = ptrtoint i8* %66 to i64
%68 = trunc i64 %67 to i32
%69 = load i32, i32* @SEEK_END
%70 = tail call i32 @fseek(i32* %56, i32 0, i32 %69)
%71 = tail call i32 @ftell(i32* %56)
%72 = mul i32 %37, %68
%73 = icmp ugt i32 %71, %72
br i1 %73, label %74, label %77
74: ; preds = %63
%75 = load i32, i32* @stderr
%76 = tail call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %100
77: ; preds = %63
%78 = load i32, i32* @SEEK_SET
%79 = tail call i32 @fseek(i32* %56, i32 0, i32 %78)
%80 = icmp sgt i32 %68, 0
br i1 %80, label %81, label %100
81: ; preds = %77
%82 = zext i32 %37 to i64
br label %83
83: ; preds = %81, %97
%84 = phi i32 [ 0, %81 ], [ %98, %97 ]
%85 = call i64 @fread(i8* %4, i32 1, i32 %37, i32* %56)
%86 = icmp eq i64 %85, 0
br i1 %86, label %90, label %87
87: ; preds = %83
%88 = trunc i64 %85 to i32
%89 = call i32 @fwrite(i8* %4, i32 1, i32 %88, i32* %47)
br label %90
90: ; preds = %87, %83
%91 = icmp ult i64 %85, %82
br i1 %91, label %92, label %97
92: ; preds = %90
%93 = trunc i64 %85 to i32
%94 = sub i32 %37, %93
%95 = call i32 @memset(i8* %4, i32 255, i32 %94)
%96 = call i32 @fwrite(i8* %4, i32 1, i32 %94, i32* %47)
br label %97
97: ; preds = %90, %92
%98 = add nuw nsw i32 %84, 1
%99 = icmp eq i32 %98, %68
br i1 %99, label %100, label %83
100: ; preds = %97, %77, %74
%101 = phi i32 [ -1, %74 ], [ 0, %77 ], [ 0, %97 ]
%102 = call i32 @fclose(i32* %56)
%103 = call i32 @fclose(i32* %47)
br label %104
104: ; preds = %100, %58, %49, %40
%105 = phi i32 [ -1, %40 ], [ -1, %49 ], [ -1, %58 ], [ %101, %100 ]
ret i32 %105
}