#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  unsigned char blah;
  int result, count = 0;
  while (1) {
    result = fread(&blah, 1, 1, stdin);
    if (result < 1)
      break;
    if (count % 16 == 0) {
      fprintf(stdout, ".byte ");
    }
    fprintf(stdout, "$%02x", blah);
    if (count % 16 != 15) {
      fprintf(stdout, ",");
    } else {
      fprintf(stdout, "\n");
    }
    count++;
  }
  return 0;
}


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)
movl   $0x0,-0x1c(%rbp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%ecx
lea    -0x11(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    1168 <main+0x48>
jmp    1203 <main+0xe3>
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1193 <main+0x73>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
movzbl -0x11(%rbp),%edx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
je     11de <main+0xbe>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f5 <main+0xd5>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eb6(%rip),%rax
mov    (%rax),%ecx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
test   %eax,%eax
jle    11d7 <main+0xb7>
mov    0x2e81(%rip),%rbx
lea    0xeb1(%rip),%rbp
lea    0xea8(%rip),%r14
lea    0x7(%rsp),%r13
xor    %r12d,%r12d
jmp    11bc <main+0x9c>
nop
mov    (%rbx),%edi
movzbl 0x7(%rsp),%edx
lea    0xe89(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0xf,%r15d
mov    (%rbx),%edi
mov    %r14,%rsi
cmove  %rbp,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%r12d
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
test   %eax,%eax
jle    11d7 <main+0xb7>
mov    %r12d,%r15d
and    $0xf,%r15d
jne    1170 <main+0x50>
mov    (%rbx),%edi
lea    0xe32(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%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 = [7 x i8] c".byte \00"
@.str.1 = [6 x i8] c"$%02x\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %9
9: ; preds = %2, %36
%10 = load i32, i32* @stdin
%11 = call i32 @fread(i8* %6, i32 1, i32 1, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %9
br label %39
15: ; preds = %9
%16 = load i32, i32* %8
%17 = srem i32 %16, 16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* @stdout
%24 = load i8, i8* %6
%25 = zext i8 %24 to i32
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %8
%28 = srem i32 %27, 16
%29 = icmp ne i32 %28, 15
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
33: ; preds = %22
%34 = load i32, i32* @stdout
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %33, %30
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %9
39: ; preds = %14
ret i32 0
}

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