#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char **argv) {
  FILE *f = fopen(argv[1], "r");
  unsigned char buffer[32];
  size_t s = 0;
  do {
    size_t a = 0;
    s = fread(buffer, sizeof(unsigned char), 32, f);
    for (a = 0; a < s; ++a) {
      printf("%3u, ", buffer[a]);
    }
    printf("\n");
  } while (s > 0);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x20,%edx
call   1030 <fread@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    11d7 <main+0x97>
mov    -0x50(%rbp),%rax
movzbl -0x40(%rbp,%rax,1),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11a1 <main+0x61>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x48(%rbp)
ja     1176 <main+0x36>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    0x8(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%r14
lea    0xe88(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x20,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     11c8 <main+0x78>
mov    %rax,%r13
xor    %ebx,%ebx
nop
movzbl (%rsp,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11a0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r13,%r13
jne    1180 <main+0x30>
jmp    11d2 <main+0x82>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"%3u, \00"
@.str.2 = [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 [32 x i8]
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
store i64 0, i64* %8
br label %14
14: ; preds = %33, %2
store i64 0, i64* %9
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%16 = load i32*, i32** %6
%17 = call i64 @fread(i8* %15, i32 1, i32 32, i32* %16)
store i64 %17, i64* %8
store i64 0, i64* %9
br label %18
18: ; preds = %28, %14
%19 = load i64, i64* %9
%20 = load i64, i64* %8
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i64, i64* %9
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22
%29 = load i64, i64* %9
%30 = add i64 %29, 1
store i64 %30, i64* %9
br label %18
31: ; preds = %18
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i64, i64* %8
%35 = icmp ugt i64 %34, 0
br i1 %35, label %14, label %36
36: ; preds = %33
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"%3u, \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %21, %2
%9 = call i64 @fread(i8* %7, i32 1, i32 32, i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @putchar(i32 10)
br label %23
13: ; preds = %8, %13
%14 = phi i64 [ %19, %13 ], [ 0, %8 ]
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = add nuw i64 %14, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %13
21: ; preds = %13
%22 = tail call i32 @putchar(i32 10)
br i1 %10, label %23, label %8
23: ; preds = %21, %11
%24 = tail call i32 @fclose(i32* %6)
ret i32 0
}