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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ stdout;
int main() {
  unsigned char data[512];
  size_t addr = 0;
  int iRead = 0;
  while ((iRead = read(0, data, sizeof(data))) > 0) {
    int i;
    for (i = 0; i < iRead; ++i) {
      if ((addr & ((1 << 3) - 1)) == 0)
        printf(" ");
      if ((addr & ((1 << 4) - 1)) == 0)
        printf("\n%07x:", addr);
      printf(" %02X", data[i]);
      fflush(stdout);
      addr++;
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x218(%rbp)
movl   $0x0,-0x21c(%rbp)
lea    -0x210(%rbp),%rsi
xor    %edi,%edi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x21c(%rbp)
cmp    $0x0,%eax
jle    1238 <main+0x108>
movl   $0x0,-0x220(%rbp)
mov    -0x220(%rbp),%eax
cmp    -0x21c(%rbp),%eax
jge    1233 <main+0x103>
mov    -0x218(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    11b8 <main+0x88>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x218(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    11e2 <main+0xb2>
mov    -0x218(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x220(%rbp),%rax
movzbl -0x210(%rbp,%rax,1),%esi
ff
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x218(%rbp)
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x220(%rbp)
jmp    1183 <main+0x53>
jmp    1157 <main+0x27>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x200,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1202 <main+0xc2>
lea    0xe98(%rip),%r12
mov    0x2e6a(%rip),%r13
xor    %ebp,%ebp
jmp    1196 <main+0x56>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rsp,%rsi
mov    $0x200,%edx
call   1050 <read@plt>
add    %r15,%rbp
test   %eax,%eax
jle    1202 <main+0xc2>
mov    %eax,%r14d
xor    %r15d,%r15d
jmp    11c1 <main+0x81>
xchg   %ax,%ax
movzbl (%rsp,%r15,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     1180 <main+0x40>
lea    (%r15,%rbp,1),%rbx
test   $0x7,%bl
je     11e0 <main+0xa0>
test   $0xf,%bl
jne    11a0 <main+0x60>
jmp    11ef <main+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
test   $0xf,%bl
jne    11a0 <main+0x60>
lea    0xe0a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [7 x i8] c"\0A%07x:\00"
@.str.2 = [6 x i8] c" %02X\00"
@stdout = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
store i32 0, i32* %4
br label %6
6: ; preds = %42, %0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%8 = call i32 @read(i32 0, i8* %7, i32 512)
store i32 %8, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %43
10: ; preds = %6
store i32 0, i32* %5
br label %11
11: ; preds = %39, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %42
15: ; preds = %11
%16 = load i64, i64* %3
%17 = and i64 %16, 7
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = load i64, i64* %3
%23 = and i64 %22, 15
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i64, i64* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %26)
br label %28
28: ; preds = %25, %21
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @stdout
%36 = call i32 @fflush(i32 %35)
%37 = load i64, i64* %3
%38 = add i64 %37, 1
store i64 %38, i64* %3
br label %39
39: ; preds = %28
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %11
42: ; preds = %11
br label %6
43: ; preds = %6
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"\0A%07x:\00"
@.str.2 = [6 x i8] c" %02X\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = call i32 @read(i32 0, i8* %2, i32 512)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %8, label %34
5: ; preds = %24
%6 = call i32 @read(i32 0, i8* %2, i32 512)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %34
8: ; preds = %0, %5
%9 = phi i32 [ %6, %5 ], [ %3, %0 ]
%10 = phi i64 [ %31, %5 ], [ 0, %0 ]
%11 = zext i32 %9 to i64
br label %12
12: ; preds = %8, %24
%13 = phi i64 [ 0, %8 ], [ %32, %24 ]
%14 = phi i64 [ %10, %8 ], [ %31, %24 ]
%15 = and i64 %14, 7
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @putchar(i32 32)
br label %19
19: ; preds = %17, %12
%20 = and i64 %14, 15
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %14)
br label %24
24: ; preds = %22, %19
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 %13
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @stdout
%30 = tail call i32 @fflush(i32 %29)
%31 = add i64 %14, 1
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %32, %11
br i1 %33, label %5, label %12
34: ; preds = %5, %0
%35 = tail call i32 @putchar(i32 10)
ret i32 0
}