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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  unsigned char buffer[8];
  FILE *fd_in, *fd_out;
  size_t len;
  int i;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <input_file> <output_file>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (!(fd_in = fopen(argv[1], "r"))) {
    fprintf(stderr, "Unable to open file \"%s\"\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  if (!(fd_out = fopen(argv[2], "w"))) {
    fprintf(stderr, "Unable to create file \"%s\"\n", argv[2]);
    exit(EXIT_FAILURE);
  }
  while (!feof(fd_in)) {
    len = fread(buffer, 1, sizeof(buffer), fd_in);
    if (len == 0)
      break;
    fprintf(fd_out, "   ");
    for (i = 0; i < len; i++)
      fprintf(fd_out, "0x%2.2x, ", buffer[i]);
    fprintf(fd_out, "\n");
  }
  fclose(fd_in);
  fclose(fd_out);
  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   $0x3,-0x8(%rbp)
je     11ad <main+0x4d>
mov    0x2e59(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11fd <main+0x9d>
mov    0x2e0a(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    124d <main+0xed>
mov    0x2dba(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1252 <main+0xf2>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1270 <main+0x110>
jmp    1302 <main+0x1a2>
lea    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    129b <main+0x13b>
jmp    1302 <main+0x1a2>
mov    -0x28(%rbp),%rdi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    12eb <main+0x18b>
mov    -0x28(%rbp),%rdi
movslq -0x34(%rbp),%rax
movzbl -0x18(%rbp,%rax,1),%edx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12b4 <main+0x154>
mov    -0x28(%rbp),%rdi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1252 <main+0xf2>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%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    %rsi,%r15
cmp    $0x3,%edi
jne    1285 <main+0x105>
mov    0x8(%r15),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     129b <main+0x11b>
mov    %rax,%r14
mov    0x10(%r15),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12b2 <main+0x132>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1264 <main+0xe4>
lea    0xe7a(%rip),%r12
lea    0xe77(%rip),%r13
nopl   (%rax)
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     1264 <main+0xe4>
mov    %rax,%rbp
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rsp,%r15,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1230 <main+0xb0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11f0 <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
mov    0x2d54(%rip),%rax
movslq (%rax),%rdi
mov    (%r15),%rdx
lea    0xd67(%rip),%rsi
jmp    12c7 <main+0x147>
mov    0x2d3e(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%r15),%rdx
lea    0xd78(%rip),%rsi
jmp    12c7 <main+0x147>
mov    0x2d27(%rip),%rax
movslq (%rax),%rdi
mov    0x10(%r15),%rdx
lea    0xd7d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: %s <input_file> <output_file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Unable to open file \22%s\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [28 x i8] c"Unable to create file \22%s\22\0A\00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [10 x i8] c"0x%2.2x, \00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp ne i32* %27, null
br i1 %28, label %39, label %29
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %23
%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.3, i64 0, i64 0))
store i32* %43, i32** %8
%44 = icmp ne i32* %43, null
br i1 %44, label %55, label %45
45: ; preds = %39
%46 = load i32, i32* @stderr
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i32*
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %51)
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %39
br label %56
56: ; preds = %87, %55
%57 = load i32*, i32** %7
%58 = call i32 @feof(i32* %57)
%59 = icmp ne i32 %58, 0
%60 = xor i1 %59, true
br i1 %60, label %61, label %90
61: ; preds = %56
%62 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%63 = load i32*, i32** %7
%64 = call i64 @fread(i8* %62, i32 1, i32 8, i32* %63)
store i64 %64, i64* %9
%65 = load i64, i64* %9
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %61
br label %90
68: ; preds = %61
%69 = load i32*, i32** %8
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %71
71: ; preds = %84, %68
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = load i64, i64* %9
%75 = icmp ult i64 %73, %74
br i1 %75, label %76, label %87
76: ; preds = %71
%77 = load i32*, i32** %8
%78 = load i32, i32* %10
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %76
%85 = load i32, i32* %10
%86 = add nsw i32 %85, 1
store i32 %86, i32* %10
br label %71
87: ; preds = %71
%88 = load i32*, i32** %8
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %56
90: ; preds = %67, %56
%91 = load i32*, i32** %7
%92 = call i32 @fclose(i32* %91)
%93 = load i32*, i32** %8
%94 = call i32 @fclose(i32* %93)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: %s <input_file> <output_file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"Unable to open file \22%s\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [28 x i8] c"Unable to create file \22%s\22\0A\00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [10 x i8] c"0x%2.2x, \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = load i8*, i8** %1
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = load i8*, i8** %15
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @exit(i32 %25)
unreachable
27: ; preds = %14
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = tail call i32 @feof(i32* %17)
%34 = icmp eq i32 %33, 0
br i1 %34, label %43, label %60
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = load i8*, i8** %28
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = tail call i32 @exit(i32 %41)
unreachable
43: ; preds = %32, %56
%44 = call i64 @fread(i8* %4, i32 1, i32 8, i32* %17)
%45 = icmp eq i64 %44, 0
br i1 %45, label %60, label %46
46: ; preds = %43
%47 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %30)
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ 0, %46 ], [ %54, %48 ]
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = add nuw i64 %49, 1
%55 = icmp eq i64 %54, %44
br i1 %55, label %56, label %48
56: ; preds = %48
%57 = tail call i32 @fputc(i32 10, i32* %30)
%58 = tail call i32 @feof(i32* %17)
%59 = icmp eq i32 %58, 0
br i1 %59, label %43, label %60
60: ; preds = %56, %43, %32
%61 = tail call i32 @fclose(i32* %17)
%62 = tail call i32 @fclose(i32* %30)
ret i32 0
}