#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 main() {
  int ch;
  int cnt = 0;
  printf("\"");
  while ((ch = getchar()) != EOF) {
    printf("\\x%02X", ch);
    if (++cnt % 10 == 0)
      printf("\"\n\"");
  }
  printf("\"\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
je     119b <main+0x7b>
mov    -0x8(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1196 <main+0x76>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1144 <main+0x24>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x22,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e85(%rip),%r15
cmp    (%r15),%eax
jne    1185 <main+0x45>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%ebp
mov    $0x1,%ebx
mov    $0xcccccccd,%r13d
lea    0xe64(%rip),%r12
jmp    11b2 <main+0x72>
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    (%r15),%eax
je     1168 <main+0x28>
mov    %ebx,%ecx
imul   %r13,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%r14d
add    %r14d,%r14d
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    %ebp,%r14d
jne    11a0 <main+0x60>
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <main+0x60>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [7 x i8] c"\\x%02X\00"
@.str.2 = [4 x i8] c"\22\0A\22\00"
@str = [2 x i8] c"\22\00"
define i32 @main() {
%1 = tail call i32 @putchar(i32 34)
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %18, label %5
5: ; preds = %0, %14
%6 = phi i32 [ %15, %14 ], [ %2, %0 ]
%7 = phi i32 [ %9, %14 ], [ 0, %0 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%9 = add nuw nsw i32 %7, 1
%10 = urem i32 %9, 10
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %5
18: ; preds = %14, %0
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}