#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 fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int i, end = 0;
  unsigned char byte;
  printf("char %s[] = {\n", argc > 1 ? argv[1] : "data");
  while (1) {
    printf("  ");
    for (i = 0; i < 16; i++) {
      if (fread(&byte, 1, 1, stdin) != 1) {
        end = 1;
        break;
      }
      printf("0x%02x,", (unsigned int)byte);
    }
    printf("\n");
    if (end) {
      break;
    }
  }
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1158 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1168 <main+0x48>
lea    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1168 <main+0x48>
mov    -0x28(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11e7 <main+0xc7>
mov    0x2e48(%rip),%rax
mov    (%rax),%ecx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11c7 <main+0xa7>
movl   $0x1,-0x18(%rbp)
jmp    11e7 <main+0xc7>
movzbl -0x19(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x6f>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1204 <main+0xe4>
jmp    1209 <main+0xe9>
jmp    117a <main+0x5a>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1157 <main+0x17>
mov    0x8(%rsi),%rsi
jmp    115e <main+0x1e>
lea    0xeb1(%rip),%rsi
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea1(%rip),%r14
mov    0x2e6e(%rip),%r12
lea    0xf(%rsp),%rbx
lea    0xe91(%rip),%r15
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x10,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    11db <main+0x9b>
movzbl 0xf(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1186 <main+0x46>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe33(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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