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

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  FILE *infp = stdin;
  char c;
  int column = 0;
  while (!feof(infp)) {
    int err;
    err = fread(&c, sizeof(c), 1, infp);
    if (err != 1)
      break;
    printf("0x%02x,", ((int)c) & 0xff);
    if ((++column % 16) == 0) {
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1179 <main+0x49>
jmp    11e4 <main+0xb4>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
je     119f <main+0x6f>
jmp    11e4 <main+0xb4>
movsbl -0x19(%rbp),%esi
and    $0xff,%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11df <main+0xaf>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <main+0x2b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e9a(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     116a <main+0x2a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
lea    0x7(%rsp),%r14
lea    0xe85(%rip),%r15
jmp    118f <main+0x4f>
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
add    $0x1,%ebp
test   %eax,%eax
jne    115d <main+0x1d>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    115d <main+0x1d>
movzbl 0x7(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0xf,%bpl
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [8 x i8] c"0x%02x,\00"
@.str.1 = [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 i8
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32*, i32** @stdin
store i32* %10, i32** %6
store i32 0, i32* %8
br label %11
11: ; preds = %33, %2
%12 = load i32*, i32** %6
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %34
16: ; preds = %11
%17 = load i32*, i32** %6
%18 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %17)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %16
br label %34
22: ; preds = %16
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = and i32 %24, 255
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
%29 = srem i32 %28, 16
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %22
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %22
br label %11
34: ; preds = %21, %11
ret i32 0
}

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