#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 EOF;
int /*<<< orphan*/ print_offset(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int readl_16(char *);
int main(void) {
  int nbchars;
  char line[17];
  int offset = 0;
  int i;
  while ((nbchars = readl_16(line)) != EOF) {
    print_offset(offset++);
    for (i = 0; i < nbchars; i++) {
      if (!(i % 2))
        putchar(' ');
      printf("%02X", line[i]);
    }
    while (i < 16) {
      if (!(i % 2))
        putchar(' ');
      printf("  ");
      i++;
    }
    printf(" %s\n", line);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <readl_16@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
je     1237 <main+0xf7>
mov    -0x24(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
call   1040 <print_offset@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d7 <main+0x97>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b2 <main+0x72>
mov    $0x20,%edi
call   1030 <putchar@plt>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1188 <main+0x48>
jmp    11dc <main+0x9c>
cmpl   $0x10,-0x28(%rbp)
jge    1220 <main+0xe0>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1204 <main+0xc4>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11dc <main+0x9c>
lea    -0x20(%rbp),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1156 <main+0x16>
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    %rsp,%rdi
call   1060 <readl_16@plt>
mov    %eax,%r15d
mov    0x2e88(%rip),%rax
cmp    (%rax),%r15d
jne    1176 <main+0x36>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe83(%rip),%r14
lea    0xe81(%rip),%rbx
xor    %r13d,%r13d
jmp    11bf <main+0x7f>
nopl   0x0(%rax)
add    $0x1,%r13d
lea    0xe6d(%rip),%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1060 <readl_16@plt>
mov    %eax,%r15d
mov    0x2e2e(%rip),%rax
cmp    (%rax),%r15d
je     1165 <main+0x25>
mov    %r13d,%edi
call   1040 <print_offset@plt>
mov    $0x0,%ebp
test   %r15d,%r15d
jle    1236 <main+0xf6>
mov    %r15d,%ebp
xor    %r12d,%r12d
jmp    11f8 <main+0xb8>
nopl   0x0(%rax)
movsbl (%rsp,%r12,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
je     1210 <main+0xd0>
test   $0x1,%r12b
jne    11e0 <main+0xa0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11e0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
mov    %r15d,%ebp
cmp    $0xf,%r15d
jbe    1236 <main+0xf6>
jmp    1190 <main+0x50>
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x10,%ebp
je     1190 <main+0x50>
test   $0x1,%bpl
jne    1220 <main+0xe0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1220 <main+0xe0>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%02X\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [5 x i8] c" %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %49, %0
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%8 = call i32 @readl_16(i8* %7)
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %52
11: ; preds = %6
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
%14 = call i32 @print_offset(i32 %12)
store i32 0, i32* %5
br label %15
15: ; preds = %32, %11
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load i32, i32* %5
%21 = srem i32 %20, 2
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 @putchar(i8 signext 32)
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %15
35: ; preds = %15
br label %36
36: ; preds = %45, %35
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 16
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32, i32* %5
%41 = srem i32 %40, 2
%42 = icmp ne i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 @putchar(i8 signext 32)
br label %45
45: ; preds = %43, %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %36
49: ; preds = %36
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %6
52: ; preds = %6
%53 = load i32, i32* %1
ret i32 %53
}

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