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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i, l;
  int first = 1;
  FILE *stream;
  unsigned char buf[16];
  if (argc < 2) {
    printf("Need parater for file with data\n");
    return 1;
  }
  if ((stream = fopen(argv[1], "rb")) == NULL) {
    printf("Error open file %s", argv[1]);
    return 1;
  }
  do {
    l = fread(buf, 1, sizeof(buf), stream);
    for (i = 0; i < l; i++) {
      if (!first) {
        printf(",");
        if (i == 0)
          printf("\n");
      }
      printf("0x%02X", buf[i]);
      first = 0;
    }
  } while (l != 0);
  printf("\n");
  fclose(stream);
  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)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1181 <main+0x41>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <main+0x145>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11c5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <main+0x145>
jmp    11ca <main+0x8a>
lea    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1258 <main+0x118>
cmpl   $0x0,-0x1c(%rbp)
jne    122c <main+0xec>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1227 <main+0xe7>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    122c <main+0xec>
movslq -0x14(%rbp),%rax
movzbl -0x40(%rbp,%rax,1),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11eb <main+0xab>
jmp    125d <main+0x11d>
cmpl   $0x0,-0x18(%rbp)
jne    11ca <main+0x8a>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
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
sub    $0x18,%rsp
cmp    $0x1,%edi
jg     1184 <main+0x24>
lea    0xea3(%rip),%rdi
call   1040 <puts@plt>
jmp    1271 <main+0x111>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125f <main+0xff>
mov    %rax,%r15
mov    $0x1,%ebp
lea    0xe67(%rip),%r13
jmp    11c9 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     1249 <main+0xe9>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    11c0 <main+0x60>
test   %ebp,%ebp
jne    11fd <main+0x9d>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl (%rsp),%esi
xor    %ebp,%ebp
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x1,%r12d
je     11c0 <main+0x60>
mov    %r12d,%ebx
mov    $0x1,%r14d
nopl   0x0(%rax)
mov    $0x2c,%edi
call   1030 <putchar@plt>
movzbl (%rsp,%r14,1),%esi
xor    %ebp,%ebp
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1220 <main+0xc0>
jmp    11c0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1276 <main+0x116>
mov    0x8(%rbx),%rsi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Need parater for file with data\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [19 x i8] c"Error open file %s\00"
@.str.3 = [2 x i8] c",\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [7 x i8] c"0x%02X\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 [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %63
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %26
21: ; preds = %15
%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 ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %63
26: ; preds = %15
br label %27
27: ; preds = %56, %26
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%29 = load i32*, i32** %9
%30 = call i32 @fread(i8* %28, i32 1, i32 16, i32* %29)
store i32 %30, i32* %7
store i32 0, i32* %6
br label %31
31: ; preds = %52, %27
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %55
35: ; preds = %31
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %45, label %38
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
br label %45
45: ; preds = %44, %35
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %50)
store i32 0, i32* %8
br label %52
52: ; preds = %45
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %31
55: ; preds = %31
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = icmp ne i32 %57, 0
br i1 %58, label %27, label %59
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32*, i32** %9
%62 = call i32 @fclose(i32* %61)
store i32 0, i32* %3
br label %63
63: ; preds = %59, %21, %13
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [19 x i8] c"Error open file %s\00"
@.str.5 = [7 x i8] c"0x%02X\00"
@str = [32 x i8] c"Need parater for file with data\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %46
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %46
16: ; preds = %8, %40
%17 = phi i32 [ %41, %40 ], [ 1, %8 ]
%18 = call i32 @fread(i8* %4, i32 1, i32 16, i32* %11)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = zext i32 %18 to i64
%22 = icmp eq i32 %17, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = tail call i32 @putchar(i32 44)
%25 = tail call i32 @putchar(i32 10)
br label %26
26: ; preds = %23, %20
%27 = load i8, i8* %4
%28 = zext i8 %27 to i32
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = icmp eq i32 %18, 1
br i1 %30, label %40, label %31
31: ; preds = %26, %31
%32 = phi i64 [ %38, %31 ], [ 1, %26 ]
%33 = tail call i32 @putchar(i32 44)
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %32
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %32, 1
%39 = icmp eq i64 %38, %21
br i1 %39, label %40, label %31
40: ; preds = %31, %26, %16
%41 = phi i32 [ %17, %16 ], [ 0, %26 ], [ 0, %31 ]
%42 = icmp eq i32 %18, 0
br i1 %42, label %43, label %16
43: ; preds = %40
%44 = tail call i32 @putchar(i32 10)
%45 = tail call i32 @fclose(i32* %11)
br label %46
46: ; preds = %43, %13, %6
%47 = phi i32 [ 1, %6 ], [ 1, %13 ], [ 0, %43 ]
ret i32 %47
}