#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  int c;
  int i;
  if (argc != 1) {
    int ishelp = 0;
    FILE *stream;
    if (argc == 2 && argv[1][0] == '-') {
      const char *opt = &argv[1][1];
      if (*opt == '-')
        ++opt;
      ishelp = *opt == 'h' || *opt == 'H';
    }
    stream = ishelp ? stdout : stderr;
    fprintf(stream, "Usage: %s < input_file > output_file\n", argv[0]);
    fprintf(stream, "Prints bytes from stdin in hex format.\n");
    exit(!ishelp);
  };
  i = 0;
  while ((c = getc(stdin)) != EOF) {
    printf("0x%02x,", c);
    if (++i == 16) {
      printf("\n");
      i = 0;
    }
  }
  if (i != 0)
    printf("\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1252 <main+0x112>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11e1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b1 <main+0x71>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x68,%ecx
mov    %al,-0x31(%rbp)
je     11d6 <main+0x96>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x48,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11fe <main+0xbe>
mov    0x2dd6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    120c <main+0xcc>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d6f(%rip),%rcx
cmp    (%rcx),%eax
je     12b6 <main+0x176>
mov    -0x14(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x10,%eax
jne    12b1 <main+0x171>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
jmp    1259 <main+0x119>
cmpl   $0x0,-0x18(%rbp)
je     12ce <main+0x18e>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
je     11d3 <main+0x73>
cmp    $0x1,%edi
jne    11fa <main+0x9a>
mov    0x2e6c(%rip),%r14
mov    (%r14),%edi
call   1080 <getc@plt>
mov    0x2e55(%rip),%r15
cmp    (%r15),%eax
je     124b <main+0xeb>
lea    0xeb3(%rip),%rbx
xor    %ebp,%ebp
jmp    11b1 <main+0x51>
nop
mov    (%r14),%edi
call   1080 <getc@plt>
cmp    (%r15),%eax
je     123d <main+0xdd>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x10,%ebp
jne    11a0 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    11a0 <main+0x40>
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    11fa <main+0x9a>
xor    %ecx,%ecx
cmpb   $0x2d,0x1(%rax)
sete   %cl
mov    0x1(%rcx,%rax,1),%al
and    $0xdf,%al
cmp    $0x48,%al
jne    11fa <main+0x9a>
mov    0x2dd2(%rip),%rax
xor    %ebp,%ebp
jmp    1206 <main+0xa6>
mov    0x2dcf(%rip),%rax
mov    $0x1,%ebp
mov    (%rax),%rbx
mov    (%rsi),%rdx
lea    0xded(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe02(%rip),%rdi
mov    $0x27,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %ebp,%edi
call   1060 <exit@plt>
test   %ebp,%ebp
je     124b <main+0xeb>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32* null
@stderr = global i32* null
@.str = [38 x i8] c"Usage: %s < input_file > output_file\0A\00"
@.str.1 = [40 x i8] c"Prints bytes from stdin in hex format.\0A\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.2 = [8 x i8] c"0x%02x,\00"
@.str.3 = [2 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 i32
%9 = alloca i32*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %70
13: ; preds = %2
store i32 0, i32* %8
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %49
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br i1 %23, label %24, label %49
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 45
br i1 %32, label %33, label %36
33: ; preds = %24
%34 = load i8*, i8** %10
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %10
br label %36
36: ; preds = %33, %24
%37 = load i8*, i8** %10
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 104
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = load i8*, i8** %10
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 72
br label %46
46: ; preds = %41, %36
%47 = phi i1 [ true, %36 ], [ %45, %41 ]
%48 = zext i1 %47 to i32
store i32 %48, i32* %8
br label %49
49: ; preds = %46, %16, %13
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = load i32*, i32** @stdout
br label %56
54: ; preds = %49
%55 = load i32*, i32** @stderr
br label %56
56: ; preds = %54, %52
%57 = phi i32* [ %53, %52 ], [ %55, %54 ]
store i32* %57, i32** %9
%58 = load i32*, i32** %9
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 0
%61 = load i8*, i8** %60
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %61)
%63 = load i32*, i32** %9
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%65 = load i32, i32* %8
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
%68 = zext i1 %67 to i32
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %2
store i32 0, i32* %7
br label %71
71: ; preds = %84, %70
%72 = load i32, i32* @stdin
%73 = call i32 @getc(i32 %72)
store i32 %73, i32* %6
%74 = load i32, i32* @EOF
%75 = icmp ne i32 %73, %74
br i1 %75, label %76, label %85
76: ; preds = %71
%77 = load i32, i32* %6
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %77)
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
%81 = icmp eq i32 %80, 16
br i1 %81, label %82, label %84
82: ; preds = %76
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %84
84: ; preds = %82, %76
br label %71
85: ; preds = %71
%86 = load i32, i32* %7
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %88, %85
%91 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdout = global i32* null
@stderr = global i32* null
@.str = [38 x i8] c"Usage: %s < input_file > output_file\0A\00"
@.str.1 = [40 x i8] c"Prints bytes from stdin in hex format.\0A\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.2 = [8 x i8] c"0x%02x,\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %22 [
i32 1, label %3
i32 2, label %8
]
3: ; preds = %2
%4 = load i32, i32* @stdin
%5 = tail call i32 @getc(i32 %4)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %49, label %31
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
%17 = getelementptr inbounds i8, i8* %10, i64 2
%18 = select i1 %16, i8* %17, i8* %14
%19 = load i8, i8* %18
%20 = and i8 %19, -33
%21 = icmp eq i8 %20, 72
br i1 %21, label %23, label %22
22: ; preds = %2, %8, %13
br label %23
23: ; preds = %13, %22
%24 = phi i32 [ 1, %22 ], [ 0, %13 ]
%25 = phi i32** [ @stderr, %22 ], [ @stdout, %13 ]
%26 = load i32*, i32** %25
%27 = load i8*, i8** %1
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i64 39, i64 1, i32* %26)
%30 = tail call i32 @exit(i32 %24)
unreachable
31: ; preds = %3, %39
%32 = phi i32 [ %42, %39 ], [ %5, %3 ]
%33 = phi i32 [ %40, %39 ], [ 0, %3 ]
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%35 = add nsw i32 %33, 1
%36 = icmp eq i32 %35, 16
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = tail call i32 @putchar(i32 10)
br label %39
39: ; preds = %37, %31
%40 = phi i32 [ 0, %37 ], [ %35, %31 ]
%41 = load i32, i32* @stdin
%42 = tail call i32 @getc(i32 %41)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %31
45: ; preds = %39
%46 = icmp eq i32 %40, 0
br i1 %46, label %49, label %47
47: ; preds = %45
%48 = tail call i32 @putchar(i32 10)
br label %49
49: ; preds = %3, %47, %45
%50 = tail call i32 @exit(i32 0)
unreachable
}