#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 strlen(char *);
int main(int argc, char *argv[]) {
  char *ptr = 0;
  int len = 0;
  if (argc == 1) {
    printf("usage: \r\n");
    printf("example 1: ./converter 1122334455\r\n");
    printf("example 2: cat file_in | xargs ./converter > file_out\r\n");
    return -1;
  }
  ptr = argv[1];
  len = strlen(ptr) / 2;
  printf("length = %d\r\n\r\n", len);
  printf("{\r\n");
  while (len--) {
    printf("0x");
    printf("%c", *ptr++);
    printf("%c,", *ptr++);
    if (((len % 16)) == 0 && (len != 0))
      printf("\r\n");
  }
  printf("\r\n");
  printf("},\r\n");
  return 1;
}


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)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1185 <main+0x65>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <main+0x15a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1257 <main+0x137>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1252 <main+0x132>
cmpl   $0x0,-0x1c(%rbp)
je     1252 <main+0x132>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c4 <main+0xa4>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1175 <main+0x35>
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r13d
lea    0xee1(%rip),%r15
lea    0xeb7(%rip),%r12
jmp    1234 <main+0xf4>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
lea    0xe6c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r14d
mov    $0x1,%r13d
lea    0xe60(%rip),%r15
cmp    $0x3,%r14d
jae    11c9 <main+0x89>
lea    0xe5e(%rip),%r12
jmp    1234 <main+0xf4>
add    $0xffffffff,%ebp
lea    0xe3d(%rip),%r13
lea    0xe39(%rip),%r14
lea    0xe44(%rip),%r12
jmp    11f9 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x2,%rbx
add    $0xffffffff,%ebp
jae    122e <main+0xee>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
je     11f0 <main+0xb0>
mov    %ebp,%eax
and    $0xf,%eax
jne    11f0 <main+0xb0>
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    11f0 <main+0xb0>
mov    $0x1,%r13d
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"usage: \0D\0A\00"
@.str.1 = [36 x i8] c"example 1: ./converter 1122334455\0D\0A\00"
@.str.2 = [56 x i8] c"example 2: cat file_in | xargs ./converter > file_out\0D\0A\00"
@.str.3 = [16 x i8] c"length = %d\0D\0A\0D\0A\00"
@.str.4 = [4 x i8] c"{\0D\0A\00"
@.str.5 = [3 x i8] c"0x\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [4 x i8] c"%c,\00"
@.str.8 = [3 x i8] c"\0D\0A\00"
@.str.9 = [5 x i8] c"},\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = sdiv i32 %19, 2
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %48, %14
%25 = load i32, i32* %7
%26 = add nsw i32 %25, -1
store i32 %26, i32* %7
%27 = icmp ne i32 %25, 0
br i1 %27, label %28, label %49
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %6
%32 = load i8, i8* %30
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
%37 = load i8, i8* %35
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %7
%41 = srem i32 %40, 16
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %28
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %48
48: ; preds = %46, %43, %28
br label %24
49: ; preds = %24
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %52
52: ; preds = %49, %10
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str.3 = [16 x i8] c"length = %d\0D\0A\0D\0A\00"
@.str.5 = [3 x i8] c"0x\00"
@.str.7 = [4 x i8] c"%c,\00"
@str = [3 x i8] c"{\0D\00"
@str.11 = [4 x i8] c"},\0D\00"
@str.12 = [2 x i8] c"\0D\00"
@str.13 = [9 x i8] c"usage: \0D\00"
@str.14 = [35 x i8] c"example 1: ./converter 1122334455\0D\00"
@str.15 = [55 x i8] c"example 2: cat file_in | xargs ./converter > file_out\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0))
br label %36
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = sdiv i32 %9, 2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%13 = add i32 %9, 1
%14 = icmp ult i32 %13, 3
br i1 %14, label %36, label %15
15: ; preds = %6, %34
%16 = phi i32 [ %18, %34 ], [ %10, %6 ]
%17 = phi i8* [ %24, %34 ], [ %8, %6 ]
%18 = add nsw i32 %16, -1
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = load i8, i8* %17
%22 = sext i8 %21 to i32
%23 = tail call i32 @putchar(i32 %22)
%24 = getelementptr inbounds i8, i8* %17, i64 2
%25 = load i8, i8* %20
%26 = sext i8 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%28 = and i32 %18, 15
%29 = icmp eq i32 %28, 0
%30 = icmp ne i32 %18, 0
%31 = and i1 %30, %29
br i1 %31, label %32, label %34
32: ; preds = %15
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
br label %34
34: ; preds = %32, %15
%35 = icmp eq i32 %18, 0
br i1 %35, label %36, label %15
36: ; preds = %34, %6, %4
%37 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0), %4 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0), %6 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0), %34 ]
%38 = phi i8* [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.15, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0), %6 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0), %34 ]
%39 = phi i32 [ -1, %4 ], [ 1, %6 ], [ 1, %34 ]
%40 = tail call i32 @puts(i8* dereferenceable(1) %37)
%41 = tail call i32 @puts(i8* dereferenceable(1) %38)
ret i32 %39
}