#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  FILE *dump_me;
  int i;
  int x = 0;
  if (argc < 2) {
    puts("Format: DUMP filename");
    exit(1);
  }
  dump_me = fopen(argv[1], "r");
  if (dump_me == NULL) {
    printf("Error opening \"%s\"\n", argv[1]);
    exit(1);
  }
  while ((i = fgetc(dump_me)) != EOF) {
    printf("%0.2X ", i);
    x++;
    if (!(x % 16))
      putchar('\n');
  }
  fclose(dump_me);
  printf("\n%s: size = %u bytes\n", argv[1], x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ad <main+0x3d>
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11f5 <main+0x85>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
je     124d <main+0xdd>
mov    -0x1c(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1248 <main+0xd8>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f5 <main+0x85>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%edx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1,%edi
jle    121f <main+0xaf>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe87(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1235 <main+0xc5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    0x2e39(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%eax
jne    11de <main+0x6e>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x8(%r14),%rsi
lea    0xe69(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe47(%rip),%r15
xor    %ebp,%ebp
jmp    11fe <main+0x8e>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    (%r12),%eax
je     11b7 <main+0x47>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
test   $0xf,%bpl
jne    11f0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <main+0x80>
lea    0xdda(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x8(%r14),%rsi
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Format: DUMP filename\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening \22%s\22\0A\00"
@EOF = global i32 0
@.str.3 = [7 x i8] c"%0.2X \00"
@.str.4 = [22 x i8] c"\0A%s: size = %u bytes\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %14
br label %28
28: ; preds = %43, %27
%29 = load i32*, i32** %6
%30 = call i32 @fgetc(i32* %29)
store i32 %30, i32* %7
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %28
%34 = load i32, i32* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = srem i32 %38, 16
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %33
%42 = call i32 @putchar(i8 signext 10)
br label %43
43: ; preds = %41, %33
br label %28
44: ; preds = %28
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %49, i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Format: DUMP filename\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening \22%s\22\0A\00"
@EOF = global i32 0
@.str.3 = [7 x i8] c"%0.2X \00"
@.str.4 = [22 x i8] c"\0A%s: size = %u bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = tail call i32 @fgetc(i32* %10)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %33, label %20
16: ; preds = %7
%17 = load i8*, i8** %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %12, %29
%21 = phi i32 [ %30, %29 ], [ %13, %12 ]
%22 = phi i32 [ %24, %29 ], [ 0, %12 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%24 = add nuw nsw i32 %22, 1
%25 = and i32 %24, 15
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = tail call i32 @putchar(i8 signext 10)
br label %29
29: ; preds = %27, %20
%30 = tail call i32 @fgetc(i32* %10)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %20
33: ; preds = %29, %12
%34 = phi i32 [ 0, %12 ], [ %24, %29 ]
%35 = tail call i32 @fclose(i32* %10)
%36 = load i8*, i8** %8
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %36, i32 %34)
ret i32 0
}