#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 hex2bin(char *, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  unsigned char bbuf[128];
  int i;
  int len = hex2bin("1234567890abcdef", bbuf);
  printf("len=%d\n", len);
  if (len > 0) {
    for (i = 0; i < len; i++) {
      printf("%02X", bbuf[i]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <hex2bin@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x98(%rbp)
jle    11c7 <main+0xa7>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jge    11b9 <main+0x99>
movslq -0x94(%rbp),%rax
movzbl -0x90(%rbp,%rax,1),%esi
ff
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1176 <main+0x56>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
call   1040 <hex2bin@plt>
mov    %eax,%ebx
lea    0xebd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    1191 <main+0x61>
mov    %ebx,%r15d
lea    0xeae(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
movzbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"1234567890abcdef\00"
@.str.1 = [8 x i8] c"len=%d\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = call i32 @hex2bin(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %0
store i32 0, i32* %3
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %12
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"1234567890abcdef\00"
@.str.1 = [8 x i8] c"len=%d\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @hex2bin(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %18
6: ; preds = %0
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = call i32 @putchar(i32 10)
br label %18
18: ; preds = %16, %0
ret i32 0
}