#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;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  unsigned char buffer[16];
  unsigned k, len;
  while (len = fread(&buffer[0], 1, sizeof(buffer), stdin)) {
    for (k = 0; k < len; k++)
      fprintf(stdout, "0x%02x , ", buffer[k]);
    fprintf(stdout, "\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2eae(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
je     11b3 <main+0x93>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    1197 <main+0x77>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%eax
movzbl -0x20(%rbp,%rax,1),%edx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <main+0x3e>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2eb3(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     11c5 <main+0xa5>
mov    0x2e84(%rip),%rbx
lea    0xea5(%rip),%r13
lea    0xea8(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ebp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%edi
movzbl (%rsp,%r12,1),%edx
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <main+0x60>
mov    (%rbx),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
test   %eax,%eax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [10 x i8] c"0x%02x , \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %26, %0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fread(i8* %6, i32 1, i32 16, i32 %7)
store i32 %8, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %5
store i32 0, i32* %3
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* @stdout
%17 = load i32, i32* %3
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %3
%25 = add i32 %24, 1
store i32 %25, i32* %3
br label %11
26: ; preds = %11
%27 = load i32, i32* @stdout
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %5
29: ; preds = %5
%30 = load i32, i32* %1
ret i32 %30
}

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