#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 EXIT_SUCCESS;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    usage(argv[0]);
  FILE *f = fopen(argv[1], "r");
  if (!f)
    die(argv[1]);
  unsigned char buf[1];
  int d = fread(buf, 1, 1, f);
  while (d) {
    printf("%x", *buf >> 4);
    printf("%x", (*buf & 0x0F));
    d = fread(buf, 1, 1, f);
  }
  puts("");
  fclose(f);
  return EXIT_SUCCESS;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    119c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <die@plt>
lea    -0x19(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1235 <main+0xc5>
movzbl -0x19(%rbp),%eax
sar    $0x4,%eax
lea    0xe07(%rip),%rdi
movzbl %al,%esi
call   1060 <printf@plt>
movzbl -0x19(%rbp),%eax
and    $0xf,%eax
lea    0xdf1(%rip),%rdi
movzbl %al,%esi
call   1060 <printf@plt>
lea    -0x19(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0x73>
lea    0xdc5(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1187 <main+0x17>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a8 <main+0x38>
mov    0x8(%rbx),%rdi
call   1090 <die@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     120b <main+0x9b>
lea    0xe38(%rip),%rbx
lea    0x7(%rsp),%r15
nop
movzbl 0x7(%rsp),%ebp
mov    %ebp,%eax
shr    $0x4,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
and    $0xf,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11d0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
br label %16
16: ; preds = %11, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @die(i8* %26)
br label %28
28: ; preds = %23, %16
%29 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i32 @fread(i8* %29, i32 1, i32 1, i32* %30)
store i32 %31, i32* %8
br label %32
32: ; preds = %35, %28
%33 = load i32, i32* %8
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = ashr i32 %38, 4
%40 = trunc i32 %39 to i8
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %40)
%42 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = and i32 %44, 15
%46 = trunc i32 %45 to i8
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %46)
%48 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%49 = load i32*, i32** %6
%50 = call i32 @fread(i8* %48, i32 1, i32 1, i32* %49)
store i32 %50, i32* %8
br label %32
51: ; preds = %32
%52 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%x\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @usage(i8* %6)
br label %8
8: ; preds = %5, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 @die(i8* %14)
br label %16
16: ; preds = %13, %8
%17 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%18 = call i32 @fread(i8* %17, i32 1, i32 1, i32* %11)
%19 = icmp eq i32 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %16, %20
%21 = load i8, i8* %17
%22 = lshr i8 %21, 4
%23 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %22)
%24 = and i8 %21, 15
%25 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %24)
%26 = call i32 @fread(i8* %17, i32 1, i32 1, i32* %11)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %20
28: ; preds = %20, %16
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @fclose(i32* %11)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}