#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int ch, total = 0;
  do {
    while ((ch = getchar()) != EOF) {
      total++;
      printf("0x%02x,\n", ch);
      if (total % 16 == 0)
        break;
    }
  } while (ch != EOF);
  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,-0x18(%rbp)
jmp    1142 <main+0x22>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e95(%rip),%rcx
cmp    (%rcx),%eax
je     1191 <main+0x71>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118c <main+0x6c>
jmp    1191 <main+0x71>
jmp    1142 <main+0x22>
jmp    1196 <main+0x76>
mov    -0x14(%rbp),%eax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%eax
jne    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    0x2eb5(%rip),%r15
lea    0xec6(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%eax
je     1166 <main+0x46>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x1,%ebx
test   $0xf,%al
jne    1140 <main+0x20>
cmp    (%r15),%ebp
jne    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [9 x i8] c"0x%02x,\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %8
%4 = phi i32 [ %9, %8 ], [ 0, %2 ]
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = add i32 %4, 1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%11 = trunc i32 %9 to i4
%12 = icmp eq i4 %11, 0
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %5, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %3
16: ; preds = %8, %3
ret i32 0
}