#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*/ exit_usage(char *);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *id = "data";
  int c, i;
  if (argc == 2) {
    if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
      exit_usage(argv[0]);
    }
    id = argv[1];
  }
  if (argc > 2)
    exit_usage(argv[0]);
  i = 0;
  printf("const unsigned char %s[] = {\n\t  ", id);
  while ((c = fgetc(stdin)) != EOF) {
    unsigned char a = c;
    if (i > 0)
      printf(", ");
    printf("0x%02X", a);
    if (i % 8 == 7)
      printf("\n\t");
    i++;
  }
  printf("\n};\n\nconst unsigned int %s_len = %d;\n\n", id, i);
  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)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11bd <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11a5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11b1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <exit_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11d3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <exit_usage@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%eax
je     126c <main+0x12c>
mov    -0x1c(%rbp),%eax
mov    %al,-0x21(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    122a <main+0xea>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x21(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    125e <main+0x11e>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ec <main+0xac>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xdc3(%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   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    118c <main+0x4c>
mov    0x8(%rbp),%rbx
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     117d <main+0x3d>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    119e <main+0x5e>
mov    0x0(%rbp),%rdi
call   1030 <exit_usage@plt>
mov    0x8(%rbp),%rbx
jmp    119e <main+0x5e>
lea    0xe6d(%rip),%rbx
jle    119e <main+0x5e>
mov    0x0(%rbp),%rdi
call   1030 <exit_usage@plt>
lea    0xe6a(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,(%rsp)
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e2c(%rip),%r14
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    0x2e15(%rip),%r12
cmp    (%r12),%eax
je     11f5 <main+0xb5>
movzbl %al,%esi
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    $0x1,%ebp
cmp    (%r12),%eax
jne    121a <main+0xda>
lea    0xe41(%rip),%rdi
mov    (%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    $0x1,%ebp
lea    0xe08(%rip),%r15
lea    0xe04(%rip),%r13
jmp    1253 <main+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r12),%eax
je     11f5 <main+0xb5>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %bl,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    1240 <main+0x100>
lea    0xdc1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <main+0x100>

LLVM IR (-O0):
@.str = [5 x i8] c"data\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [33 x i8] c"const unsigned char %s[] = {\0A\09 \00"
@stdin = global i32 0
@EOF = global i32 0
@.str.4 = [3 x i8] c", \00"
@.str.5 = [7 x i8] c"0x%02X\00"
@.str.6 = [3 x i8] c"\0A\09\00"
@.str.7 = [39 x i8] c"\0A};\0A\0Aconst unsigned int %s_len = %d;\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %33
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %18, %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @exit_usage(i8* %27)
br label %29
29: ; preds = %24, %18
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
store i8* %32, i8** %6
br label %33
33: ; preds = %29, %2
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 2
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @exit_usage(i8* %39)
br label %41
41: ; preds = %36, %33
store i32 0, i32* %8
%42 = load i8*, i8** %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %65, %41
%45 = load i32, i32* @stdin
%46 = call i32 @fgetc(i32 %45)
store i32 %46, i32* %7
%47 = load i32, i32* @EOF
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %68
49: ; preds = %44
%50 = load i32, i32* %7
%51 = trunc i32 %50 to i8
store i8 %51, i8* %9
%52 = load i32, i32* %8
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = load i8, i8* %9
%58 = zext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %8
%61 = srem i32 %60, 8
%62 = icmp eq i32 %61, 7
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %65
65: ; preds = %63, %56
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
store i32 %67, i32* %8
br label %44
68: ; preds = %44
%69 = load i8*, i8** %6
%70 = load i32, i32* %8
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i8* %69, i32 %70)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"data\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [33 x i8] c"const unsigned char %s[] = {\0A\09 \00"
@stdin = global i32 0
@EOF = global i32 0
@.str.4 = [3 x i8] c", \00"
@.str.5 = [7 x i8] c"0x%02X\00"
@.str.6 = [3 x i8] c"\0A\09\00"
@.str.7 = [39 x i8] c"\0A};\0A\0Aconst unsigned int %s_len = %d;\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %9, %4
%13 = load i8*, i8** %1
%14 = tail call i32 @exit_usage(i8* %13)
%15 = load i8*, i8** %5
br label %21
16: ; preds = %2
%17 = icmp sgt i32 %0, 2
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i8*, i8** %1
%20 = tail call i32 @exit_usage(i8* %19)
br label %21
21: ; preds = %12, %9, %18, %16
%22 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %18 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %16 ], [ %6, %9 ], [ %15, %12 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stdin
%25 = tail call i32 @fgetc(i32 %24)
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %51, label %28
28: ; preds = %21
%29 = and i32 %25, 255
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stdin
%32 = tail call i32 @fgetc(i32 %31)
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
br i1 %34, label %51, label %35
35: ; preds = %28, %45
%36 = phi i32 [ %48, %45 ], [ %32, %28 ]
%37 = phi i32 [ %46, %45 ], [ 1, %28 ]
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%39 = and i32 %36, 255
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = and i32 %37, 7
%42 = icmp eq i32 %41, 7
br i1 %42, label %43, label %45
43: ; preds = %35
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %45
45: ; preds = %43, %35
%46 = add nuw nsw i32 %37, 1
%47 = load i32, i32* @stdin
%48 = tail call i32 @fgetc(i32 %47)
%49 = load i32, i32* @EOF
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %35
51: ; preds = %45, %28, %21
%52 = phi i32 [ 0, %21 ], [ 1, %28 ], [ %46, %45 ]
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i8* %22, i32 %52)
ret i32 0
}