#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 atoi(char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  int pad;
  FILE *fdi, *fdo;
  unsigned char w[4];
  int mode16;
  if ((argc != 4) && (argc != 5)) {
    fprintf(stderr, "Usage: bin2hex <infile> <outfile> <size> [16]\n");
    return 1;
  }
  pad = atoi(argv[3]);
  if (pad <= 0) {
    fprintf(stderr, "Incorrect size\n");
    return 1;
  }
  fdi = fopen(argv[1], "rb");
  if (!fdi) {
    perror("Unable to open input file");
    return 1;
  }
  fdo = fopen(argv[2], "w");
  if (!fdo) {
    perror("Unable to open output file");
    fclose(fdi);
    return 1;
  }
  mode16 = (argc == 5) && (strcmp(argv[4], "16") == 0);
  if (mode16) {
    while (1) {
      if (fread(w, 2, 1, fdi) <= 0)
        break;
      fprintf(fdo, "%02hhx%02hhx\n", w[1], w[0]);
      pad--;
    }
  } else {
    while (1) {
      if (fread(w, 4, 1, fdi) <= 0)
        break;
      fprintf(fdo, "%02hhx%02hhx%02hhx%02hhx\n", w[0], w[1], w[2], w[3]);
      pad--;
    }
  }
  fclose(fdi);
  if (pad < 0)
    fprintf(stderr, "Warning: Input binary is larger than specified size\n");
  if (mode16) {
    for (i = 0; i < pad; i++)
      fprintf(fdo, "0000\n");
  } else {
    for (i = 0; i < pad; i++)
      fprintf(fdo, "00000000\n");
  }
  if (fclose(fdo) != 0) {
    perror("Unable to close output file");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11be <main+0x4e>
cmpl   $0x5,-0x8(%rbp)
je     11be <main+0x4e>
mov    0x2e3f(%rip),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <main+0x2de>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     11fc <main+0x8c>
mov    0x2e01(%rip),%rax
mov    (%rax),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <main+0x2de>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe34(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1237 <main+0xc7>
lea    0xe1c(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <main+0x2de>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe16(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    127b <main+0x10b>
lea    0xdfd(%rip),%rdi
call   1080 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <main+0x2de>
xor    %eax,%eax
cmpl   $0x5,-0x8(%rbp)
mov    %al,-0x31(%rbp)
jne    12a8 <main+0x138>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xde0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1315 <main+0x1a5>
jmp    12c2 <main+0x152>
lea    -0x2c(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     12e8 <main+0x178>
jmp    1310 <main+0x1a0>
mov    -0x28(%rbp),%rdi
movzbl -0x2b(%rbp),%edx
movzbl -0x2c(%rbp),%ecx
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    12c2 <main+0x152>
jmp    1377 <main+0x207>
jmp    131a <main+0x1aa>
lea    -0x2c(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     1340 <main+0x1d0>
jmp    1372 <main+0x202>
mov    -0x28(%rbp),%rdi
movzbl -0x2c(%rbp),%edx
movzbl -0x2b(%rbp),%ecx
movzbl -0x2a(%rbp),%r8d
movzbl -0x29(%rbp),%r9d
lea    0xd1f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    131a <main+0x1aa>
jmp    1377 <main+0x207>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x18(%rbp)
jge    13a2 <main+0x232>
mov    0x2c4f(%rip),%rax
mov    (%rax),%rdi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x0,-0x30(%rbp)
je     13e4 <main+0x274>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13df <main+0x26f>
mov    -0x28(%rbp),%rdi
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13b3 <main+0x243>
jmp    141c <main+0x2ac>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1417 <main+0x2a7>
mov    -0x28(%rbp),%rdi
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13eb <main+0x27b>
jmp    141c <main+0x2ac>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1447 <main+0x2d7>
lea    0xc9f(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <main+0x2de>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x4,%eax
jne    129e <main+0x11e>
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x18(%rsi),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    12b6 <main+0x136>
mov    %eax,%ebx
mov    0x8(%r12),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     13ac <main+0x22c>
mov    %rax,%r15
mov    0x10(%r12),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     140b <main+0x28b>
mov    %rax,%r14
cmp    $0x5,%ebp
jne    120a <main+0x8a>
mov    0x20(%r12),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     133f <main+0x1bf>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jle    12e0 <main+0x160>
lea    0xe4b(%rip),%r12
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl 0x4(%rsp),%edx
movzbl 0x5(%rsp),%ecx
movzbl 0x6(%rsp),%r8d
movzbl 0x7(%rsp),%r9d
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebx
mov    %r13,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jg     1240 <main+0xc0>
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %ebx,%ebx
js     12ea <main+0x16a>
test   %bpl,%bpl
je     130f <main+0x18f>
test   %ebx,%ebx
jne    13bd <main+0x23d>
jmp    13ea <main+0x26a>
mov    0x2d3b(%rip),%rax
mov    (%rax),%rcx
lea    0xd51(%rip),%rdi
mov    $0x2e,%esi
jmp    12cc <main+0x14c>
mov    0x2d23(%rip),%rax
mov    (%rax),%rcx
lea    0xd68(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%eax
jmp    13fc <main+0x27c>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1317 <main+0x197>
mov    0x2cef(%rip),%rax
mov    (%rax),%rcx
lea    0xd9b(%rip),%rdi
mov    $0x34,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
jmp    13ea <main+0x26a>
test   %ebx,%ebx
je     13ea <main+0x26a>
lea    0xdad(%rip),%rbp
xchg   %ax,%ax
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
add    $0xffffffff,%ebx
jne    1320 <main+0x1a0>
jmp    13ea <main+0x26a>
lea    0x4(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jle    13b5 <main+0x235>
lea    0xd26(%rip),%r12
lea    0x4(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
movzbl 0x5(%rsp),%edx
movzbl 0x4(%rsp),%ecx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0xffffffff,%ebx
mov    %rbp,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jg     1370 <main+0x1f0>
mov    $0x1,%bpl
jmp    1280 <main+0x100>
lea    0xc8f(%rip),%rdi
jmp    142b <main+0x2ab>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xd0b(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
add    $0xffffffff,%ebx
jne    13d0 <main+0x250>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1424 <main+0x2a4>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4c(%rip),%rdi
call   1080 <perror@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    12d6 <main+0x156>
lea    0xcaa(%rip),%rdi
call   1080 <perror@plt>
jmp    12d6 <main+0x156>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [47 x i8] c"Usage: bin2hex <infile> <outfile> <size> [16]\0A\00"
@.str.1 = [16 x i8] c"Incorrect size\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [26 x i8] c"Unable to open input file\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [27 x i8] c"Unable to open output file\00"
@.str.6 = [3 x i8] c"16\00"
@.str.7 = [14 x i8] c"%02hhx%02hhx\0A\00"
@.str.8 = [26 x i8] c"%02hhx%02hhx%02hhx%02hhx\0A\00"
@.str.9 = [53 x i8] c"Warning: Input binary is larger than specified size\0A\00"
@.str.10 = [6 x i8] c"0000\0A\00"
@.str.11 = [10 x i8] c"00000000\0A\00"
@.str.12 = [28 x i8] c"Unable to close output file\00"
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 [4 x i8]
%11 = alloca i32
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, 4
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32*, i32** @stderr
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %150
20: ; preds = %14, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32*, i32** @stderr
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %150
30: ; preds = %20
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %8
%35 = load i32*, i32** %8
%36 = icmp ne i32* %35, null
br i1 %36, label %39, label %37
37: ; preds = %30
%38 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %150
39: ; preds = %30
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %43, i32** %9
%44 = load i32*, i32** %9
%45 = icmp ne i32* %44, null
br i1 %45, label %50, label %46
46: ; preds = %39
%47 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32*, i32** %8
%49 = call i64 @fclose(i32* %48)
store i32 1, i32* %3
br label %150
50: ; preds = %39
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 5
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 4
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br label %59
59: ; preds = %53, %50
%60 = phi i1 [ false, %50 ], [ %58, %53 ]
%61 = zext i1 %60 to i32
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %83
64: ; preds = %59
br label %65
65: ; preds = %64, %71
%66 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%67 = load i32*, i32** %8
%68 = call i64 @fread(i8* %66, i32 2, i32 1, i32* %67)
%69 = icmp sle i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %65
br label %82
71: ; preds = %65
%72 = load i32*, i32** %9
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %75, i32 %78)
%80 = load i32, i32* %7
%81 = add nsw i32 %80, -1
store i32 %81, i32* %7
br label %65
82: ; preds = %70
br label %108
83: ; preds = %59
br label %84
84: ; preds = %83, %90
%85 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%86 = load i32*, i32** %8
%87 = call i64 @fread(i8* %85, i32 4, i32 1, i32* %86)
%88 = icmp sle i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %84
br label %107
90: ; preds = %84
%91 = load i32*, i32** %9
%92 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%93 = load i8, i8* %92
%94 = zext i8 %93 to i32
%95 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
%96 = load i8, i8* %95
%97 = zext i8 %96 to i32
%98 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 2
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 3
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %94, i32 %97, i32 %100, i32 %103)
%105 = load i32, i32* %7
%106 = add nsw i32 %105, -1
store i32 %106, i32* %7
br label %84
107: ; preds = %89
br label %108
108: ; preds = %107, %82
%109 = load i32*, i32** %8
%110 = call i64 @fclose(i32* %109)
%111 = load i32, i32* %7
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %108
%114 = load i32*, i32** @stderr
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
br label %116
116: ; preds = %113, %108
%117 = load i32, i32* %11
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %131
119: ; preds = %116
store i32 0, i32* %6
br label %120
120: ; preds = %127, %119
%121 = load i32, i32* %6
%122 = load i32, i32* %7
%123 = icmp slt i32 %121, %122
br i1 %123, label %124, label %130
124: ; preds = %120
%125 = load i32*, i32** %9
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %127
127: ; preds = %124
%128 = load i32, i32* %6
%129 = add nsw i32 %128, 1
store i32 %129, i32* %6
br label %120
130: ; preds = %120
br label %143
131: ; preds = %116
store i32 0, i32* %6
br label %132
132: ; preds = %139, %131
%133 = load i32, i32* %6
%134 = load i32, i32* %7
%135 = icmp slt i32 %133, %134
br i1 %135, label %136, label %142
136: ; preds = %132
%137 = load i32*, i32** %9
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
br label %139
139: ; preds = %136
%140 = load i32, i32* %6
%141 = add nsw i32 %140, 1
store i32 %141, i32* %6
br label %132
142: ; preds = %132
br label %143
143: ; preds = %142, %130
%144 = load i32*, i32** %9
%145 = call i64 @fclose(i32* %144)
%146 = icmp ne i64 %145, 0
br i1 %146, label %147, label %149
147: ; preds = %143
%148 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %3
br label %150
149: ; preds = %143
store i32 0, i32* %3
br label %150
150: ; preds = %149, %147, %46, %37, %27, %17
%151 = load i32, i32* %3
ret i32 %151
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [47 x i8] c"Usage: bin2hex <infile> <outfile> <size> [16]\0A\00"
@.str.1 = [16 x i8] c"Incorrect size\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [26 x i8] c"Unable to open input file\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [27 x i8] c"Unable to open output file\00"
@.str.6 = [3 x i8] c"16\00"
@.str.7 = [14 x i8] c"%02hhx%02hhx\0A\00"
@.str.8 = [26 x i8] c"%02hhx%02hhx%02hhx%02hhx\0A\00"
@.str.9 = [53 x i8] c"Warning: Input binary is larger than specified size\0A\00"
@.str.10 = [6 x i8] c"0000\0A\00"
@.str.11 = [10 x i8] c"00000000\0A\00"
@.str.12 = [28 x i8] c"Unable to close output file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = and i32 %0, -2
%6 = icmp eq i32 %5, 4
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32*, i32** @stderr
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i64 46, i64 1, i32* %8)
br label %111
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32*, i32** @stderr
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 15, i64 1, i32* %16)
br label %111
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %111
25: ; preds = %18
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%32 = tail call i64 @fclose(i32* %21)
br label %111
33: ; preds = %25
%34 = icmp eq i32 %0, 5
br i1 %34, label %42, label %35
35: ; preds = %42, %33
%36 = call i64 @fread(i8* %4, i32 4, i32 1, i32* %21)
%37 = icmp slt i64 %36, 1
br i1 %37, label %78, label %38
38: ; preds = %35
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
br label %62
42: ; preds = %33
%43 = getelementptr inbounds i8*, i8** %1, i64 4
%44 = load i8*, i8** %43
%45 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %35
47: ; preds = %42
%48 = call i64 @fread(i8* %4, i32 2, i32 1, i32* %21)
%49 = icmp slt i64 %48, 1
br i1 %49, label %76, label %50
50: ; preds = %47
%51 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
br label %52
52: ; preds = %50, %52
%53 = phi i32 [ %13, %50 ], [ %59, %52 ]
%54 = load i8, i8* %51
%55 = zext i8 %54 to i32
%56 = load i8, i8* %4
%57 = zext i8 %56 to i32
%58 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %55, i32 %57)
%59 = add nsw i32 %53, -1
%60 = call i64 @fread(i8* %4, i32 2, i32 1, i32* %21)
%61 = icmp slt i64 %60, 1
br i1 %61, label %80, label %52
62: ; preds = %38, %62
%63 = phi i32 [ %13, %38 ], [ %73, %62 ]
%64 = load i8, i8* %4
%65 = zext i8 %64 to i32
%66 = load i8, i8* %39
%67 = zext i8 %66 to i32
%68 = load i8, i8* %40
%69 = zext i8 %68 to i32
%70 = load i8, i8* %41
%71 = zext i8 %70 to i32
%72 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %65, i32 %67, i32 %69, i32 %71)
%73 = add nsw i32 %63, -1
%74 = call i64 @fread(i8* %4, i32 4, i32 1, i32* %21)
%75 = icmp slt i64 %74, 1
br i1 %75, label %80, label %62
76: ; preds = %47
%77 = tail call i64 @fclose(i32* %21)
br label %94
78: ; preds = %35
%79 = tail call i64 @fclose(i32* %21)
br label %91
80: ; preds = %62, %52
%81 = phi i1 [ true, %52 ], [ false, %62 ]
%82 = phi i32 [ %59, %52 ], [ %73, %62 ]
%83 = tail call i64 @fclose(i32* %21)
%84 = icmp slt i32 %82, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = load i32*, i32** @stderr
%87 = tail call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i64 52, i64 1, i32* %86)
br label %106
88: ; preds = %80
%89 = icmp eq i32 %82, 0
br i1 %81, label %93, label %90
90: ; preds = %88
br i1 %89, label %106, label %91
91: ; preds = %78, %90
%92 = phi i32 [ %13, %78 ], [ %82, %90 ]
br label %101
93: ; preds = %88
br i1 %89, label %106, label %94
94: ; preds = %76, %93
%95 = phi i32 [ %13, %76 ], [ %82, %93 ]
br label %96
96: ; preds = %94, %96
%97 = phi i32 [ %99, %96 ], [ 0, %94 ]
%98 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i64 5, i64 1, i32* %28)
%99 = add nuw nsw i32 %97, 1
%100 = icmp eq i32 %99, %95
br i1 %100, label %106, label %96
101: ; preds = %91, %101
%102 = phi i32 [ %104, %101 ], [ 0, %91 ]
%103 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i64 9, i64 1, i32* %28)
%104 = add nuw nsw i32 %102, 1
%105 = icmp eq i32 %104, %92
br i1 %105, label %106, label %101
106: ; preds = %101, %96, %85, %90, %93
%107 = tail call i64 @fclose(i32* %28)
%108 = icmp eq i64 %107, 0
br i1 %108, label %111, label %109
109: ; preds = %106
%110 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
br label %111
111: ; preds = %106, %109, %30, %23, %15, %7
%112 = phi i32 [ 1, %7 ], [ 1, %15 ], [ 1, %109 ], [ 1, %30 ], [ 1, %23 ], [ 0, %106 ]
ret i32 %112
}