#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*/ printf(char *, ...);
int scanf(char *, char *);
int main() {
  char ch;
  int loop = 0;
  while (scanf("%c", &ch) == 1) {
    printf("0x%02x,", 255 & (int)ch);
    if (++loop == 16) {
      loop = 0;
      printf("\n");
    }
  }
  printf("0x00\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    0xec3(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1193 <main+0x73>
movsbl -0x5(%rbp),%esi
and    $0xff,%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x10,%eax
jne    118e <main+0x6e>
movl   $0x0,-0xc(%rbp)
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
lea    0xe71(%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   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11b5 <main+0x75>
lea    0xe9f(%rip),%r14
lea    0xe95(%rip),%r15
lea    0x7(%rsp),%rbx
xor    %ebp,%ebp
jmp    1190 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11b5 <main+0x75>
movzbl 0x7(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x10,%ebp
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1180 <main+0x40>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [8 x i8] c"0x%02x,\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [6 x i8] c"0x00\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %17, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = and i32 255, %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 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 = icmp eq i32 %13, 16
br i1 %14, label %15, label %17
15: ; preds = %7
store i32 0, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %7
br label %4
18: ; preds = %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

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