#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*/ abort();
int getchar();
int /*<<< orphan*/ print(char *, ...);
int main(int argc, char **argv) {
  int c;
  if (argc != 2)
    abort();
  print("static unsigned char %s[] = {", argv[1]);
  while ((c = getchar()) != EOF) {
    print("0x%02x, ", (unsigned char)c);
  }
  print("};\n");
  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)
cmpl   $0x2,-0x8(%rbp)
je     1157 <main+0x27>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
je     119f <main+0x6f>
mov    -0x14(%rbp),%eax
movzbl %al,%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
jmp    116d <main+0x3d>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a1 <main+0x71>
mov    0x8(%rsi),%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8f(%rip),%r14
cmp    (%r14),%eax
je     1189 <main+0x59>
lea    0xeb9(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <print@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
jne    1170 <main+0x40>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1040 <print@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"static unsigned char %s[] = {\00"
@EOF = global i32 0
@.str.1 = [9 x i8] c"0x%02x, \00"
@.str.2 = [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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %20, %11
%17 = call i32 (...) @getchar()
store i32 %17, i32* %6
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* %6
%22 = trunc i32 %21 to i8
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %16
25: ; preds = %16
%26 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"static unsigned char %s[] = {\00"
@EOF = global i32 0
@.str.1 = [9 x i8] c"0x%02x, \00"
@.str.2 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %20, label %13
13: ; preds = %6, %13
%14 = phi i32 [ %17, %13 ], [ %10, %6 ]
%15 = and i32 %14, 255
%16 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %13
20: ; preds = %13, %6
%21 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}