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

/* Variables and functions */
int /*<<< orphan*/ ShowUsage();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *wrap_fopen(char *, char *);
int main(int argc, char *argv[]) {
  FILE *in_file;
  FILE *out_file;
  unsigned char ch;
  int count;
  if (argc != 3) {
    ShowUsage();
    exit(-1);
  }
  in_file = wrap_fopen(argv[1], "rb");
  out_file = wrap_fopen(argv[2], "w");
  count = 0;
  while (fread(&ch, sizeof(ch), 1, in_file) != 0) {
    count++;
    fprintf(out_file, "%02X", ch);
    if (count < 16) {
      fprintf(out_file, " ");
    } else {
      fprintf(out_file, "\n");
      count = 0;
    }
  }
  fclose(in_file);
  fclose(out_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1191 <main+0x31>
mov    $0x0,%al
call   1070 <ShowUsage@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1050 <wrap_fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <wrap_fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x21(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
je     1244 <main+0xe4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
movzbl -0x21(%rbp),%edx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x10,-0x28(%rbp)
jge    1226 <main+0xc6>
mov    -0x20(%rbp),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    123f <main+0xdf>
mov    -0x20(%rbp),%rdi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
jmp    11c8 <main+0x68>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1255 <main+0xe5>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe6e(%rip),%rsi
call   1050 <wrap_fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe5e(%rip),%rsi
call   1050 <wrap_fopen@plt>
mov    %rax,%rbx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     1234 <main+0xc4>
mov    $0x20,%ebp
lea    0x7(%rsp),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
movzbl 0x7(%rsp),%edx
mov    %rbx,%rdi
lea    0xe16(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x1(%r13),%r15d
cmp    $0xf,%r13d
mov    $0xa,%edi
cmovl  %ebp,%edi
mov    $0x0,%eax
cmovge %eax,%r15d
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %r15d,%r13d
test   %rax,%rax
jne    11e0 <main+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1080 <ShowUsage@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\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 i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (...) @ShowUsage()
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @wrap_fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @wrap_fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
store i32 0, i32* %9
br label %24
24: ; preds = %43, %15
%25 = load i32*, i32** %6
%26 = call i64 @fread(i8* %8, i32 1, i32 1, i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
%31 = load i32*, i32** %7
%32 = load i8, i8* %8
%33 = zext i8 %32 to i32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %9
%36 = icmp slt i32 %35, 16
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = load i32*, i32** %7
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
40: ; preds = %28
%41 = load i32*, i32** %7
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %9
br label %43
43: ; preds = %40, %37
br label %24
44: ; preds = %24
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
%47 = load i32*, i32** %7
%48 = call i32 @fclose(i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%02X\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp eq i32 %0, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 (...) @ShowUsage()
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @wrap_fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @wrap_fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %11)
%16 = icmp eq i64 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %8, %17
%18 = phi i32 [ %25, %17 ], [ 0, %8 ]
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = icmp slt i32 %18, 15
%23 = add nsw i32 %18, 1
%24 = select i1 %22, i32 32, i32 10
%25 = select i1 %22, i32 %23, i32 0
%26 = tail call i32 @fputc(i32 %24, i32* %14)
%27 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %11)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %17
29: ; preds = %17, %8
%30 = tail call i32 @fclose(i32* %11)
%31 = tail call i32 @fclose(i32* %14)
ret i32 0
}