#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*/ sscanf(char *, char *, int *);
int strlen(char *);
int hex2bin(unsigned char *buf, char *hex) {
  int i, j;
  if (strlen(hex) != 0x20)
    return 1;
  for (i = 0; i < 0x10; i++) {
    if (!sscanf(hex, "%2X", &j))
      return 1;
    hex += 2;
    *buf++ = j;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hex2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x20,%eax
je     114e <hex2bin+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    11bf <hex2bin+0x9f>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11b8 <hex2bin+0x98>
mov    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
jne    1188 <hex2bin+0x68>
movl   $0x1,-0x4(%rbp)
jmp    11bf <hex2bin+0x9f>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <hex2bin+0x35>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2bin>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    $0x20,%eax
jne    1379 <hex2bin+0x259>
lea    0xeb4(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x2(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,(%rbx)
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x4(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x1(%rbx)
lea    0xe6a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x6(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x2(%rbx)
lea    0xe46(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x8(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x3(%rbx)
lea    0xe22(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0xa(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x4(%rbx)
lea    0xdfe(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0xc(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x5(%rbx)
lea    0xdda(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0xe(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x6(%rbx)
lea    0xdb6(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x10(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x7(%rbx)
lea    0xd92(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x12(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x8(%rbx)
lea    0xd6e(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x14(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0x9(%rbx)
lea    0xd4a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x16(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0xa(%rbx)
lea    0xd26(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x18(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0xb(%rbx)
lea    0xd02(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x1a(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0xc(%rbx)
lea    0xce2(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
lea    0x1c(%rbp),%rdi
mov    0xc(%rsp),%al
mov    %al,0xd(%rbx)
lea    0xcc2(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
add    $0x1e,%rbp
mov    0xc(%rsp),%al
mov    %al,0xe(%rbx)
lea    0xca2(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
call   1040 <sscanf@plt>
test   %eax,%eax
je     1379 <hex2bin+0x259>
mov    0xc(%rsp),%al
mov    %al,0xf(%rbx)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%2X\00"
define i32 @hex2bin(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 32
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %32
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %28, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 16
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = load i8*, i8** %5
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %7)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 1, i32* %3
br label %32
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8* %23, i8** %5
%24 = load i32, i32* %7
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
store i8 %25, i8* %26
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %13
31: ; preds = %13
store i32 0, i32* %3
br label %32
32: ; preds = %31, %20, %11
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2X\00"
define i32 @hex2bin(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp eq i32 %5, 32
br i1 %6, label %7, label %118
7: ; preds = %2
%8 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %118, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %1, i64 2
%12 = load i32, i32* %3
%13 = trunc i32 %12 to i8
store i8 %13, i8* %0
%14 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %118, label %16
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %0, i64 1
%18 = getelementptr inbounds i8, i8* %1, i64 4
%19 = load i32, i32* %3
%20 = trunc i32 %19 to i8
store i8 %20, i8* %17
%21 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %118, label %23
23: ; preds = %16
%24 = getelementptr inbounds i8, i8* %0, i64 2
%25 = getelementptr inbounds i8, i8* %1, i64 6
%26 = load i32, i32* %3
%27 = trunc i32 %26 to i8
store i8 %27, i8* %24
%28 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %118, label %30
30: ; preds = %23
%31 = getelementptr inbounds i8, i8* %0, i64 3
%32 = getelementptr inbounds i8, i8* %1, i64 8
%33 = load i32, i32* %3
%34 = trunc i32 %33 to i8
store i8 %34, i8* %31
%35 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%36 = icmp eq i32 %35, 0
br i1 %36, label %118, label %37
37: ; preds = %30
%38 = getelementptr inbounds i8, i8* %0, i64 4
%39 = getelementptr inbounds i8, i8* %1, i64 10
%40 = load i32, i32* %3
%41 = trunc i32 %40 to i8
store i8 %41, i8* %38
%42 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%43 = icmp eq i32 %42, 0
br i1 %43, label %118, label %44
44: ; preds = %37
%45 = getelementptr inbounds i8, i8* %0, i64 5
%46 = getelementptr inbounds i8, i8* %1, i64 12
%47 = load i32, i32* %3
%48 = trunc i32 %47 to i8
store i8 %48, i8* %45
%49 = call i32 @sscanf(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%50 = icmp eq i32 %49, 0
br i1 %50, label %118, label %51
51: ; preds = %44
%52 = getelementptr inbounds i8, i8* %0, i64 6
%53 = getelementptr inbounds i8, i8* %1, i64 14
%54 = load i32, i32* %3
%55 = trunc i32 %54 to i8
store i8 %55, i8* %52
%56 = call i32 @sscanf(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%57 = icmp eq i32 %56, 0
br i1 %57, label %118, label %58
58: ; preds = %51
%59 = getelementptr inbounds i8, i8* %0, i64 7
%60 = getelementptr inbounds i8, i8* %1, i64 16
%61 = load i32, i32* %3
%62 = trunc i32 %61 to i8
store i8 %62, i8* %59
%63 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%64 = icmp eq i32 %63, 0
br i1 %64, label %118, label %65
65: ; preds = %58
%66 = getelementptr inbounds i8, i8* %0, i64 8
%67 = getelementptr inbounds i8, i8* %1, i64 18
%68 = load i32, i32* %3
%69 = trunc i32 %68 to i8
store i8 %69, i8* %66
%70 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%71 = icmp eq i32 %70, 0
br i1 %71, label %118, label %72
72: ; preds = %65
%73 = getelementptr inbounds i8, i8* %0, i64 9
%74 = getelementptr inbounds i8, i8* %1, i64 20
%75 = load i32, i32* %3
%76 = trunc i32 %75 to i8
store i8 %76, i8* %73
%77 = call i32 @sscanf(i8* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%78 = icmp eq i32 %77, 0
br i1 %78, label %118, label %79
79: ; preds = %72
%80 = getelementptr inbounds i8, i8* %0, i64 10
%81 = getelementptr inbounds i8, i8* %1, i64 22
%82 = load i32, i32* %3
%83 = trunc i32 %82 to i8
store i8 %83, i8* %80
%84 = call i32 @sscanf(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%85 = icmp eq i32 %84, 0
br i1 %85, label %118, label %86
86: ; preds = %79
%87 = getelementptr inbounds i8, i8* %0, i64 11
%88 = getelementptr inbounds i8, i8* %1, i64 24
%89 = load i32, i32* %3
%90 = trunc i32 %89 to i8
store i8 %90, i8* %87
%91 = call i32 @sscanf(i8* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%92 = icmp eq i32 %91, 0
br i1 %92, label %118, label %93
93: ; preds = %86
%94 = getelementptr inbounds i8, i8* %0, i64 12
%95 = getelementptr inbounds i8, i8* %1, i64 26
%96 = load i32, i32* %3
%97 = trunc i32 %96 to i8
store i8 %97, i8* %94
%98 = call i32 @sscanf(i8* %95, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%99 = icmp eq i32 %98, 0
br i1 %99, label %118, label %100
100: ; preds = %93
%101 = getelementptr inbounds i8, i8* %0, i64 13
%102 = getelementptr inbounds i8, i8* %1, i64 28
%103 = load i32, i32* %3
%104 = trunc i32 %103 to i8
store i8 %104, i8* %101
%105 = call i32 @sscanf(i8* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%106 = icmp eq i32 %105, 0
br i1 %106, label %118, label %107
107: ; preds = %100
%108 = getelementptr inbounds i8, i8* %0, i64 14
%109 = getelementptr inbounds i8, i8* %1, i64 30
%110 = load i32, i32* %3
%111 = trunc i32 %110 to i8
store i8 %111, i8* %108
%112 = call i32 @sscanf(i8* %109, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%113 = icmp eq i32 %112, 0
br i1 %113, label %118, label %114
114: ; preds = %107
%115 = getelementptr inbounds i8, i8* %0, i64 15
%116 = load i32, i32* %3
%117 = trunc i32 %116 to i8
store i8 %117, i8* %115
br label %118
118: ; preds = %7, %10, %16, %23, %30, %37, %44, %51, %58, %65, %72, %79, %86, %93, %100, %107, %114, %2
%119 = phi i32 [ 1, %2 ], [ 1, %7 ], [ 1, %10 ], [ 1, %16 ], [ 1, %23 ], [ 1, %30 ], [ 1, %37 ], [ 1, %44 ], [ 1, %51 ], [ 1, %58 ], [ 1, %65 ], [ 1, %72 ], [ 1, %79 ], [ 1, %86 ], [ 1, %93 ], [ 1, %100 ], [ 1, %107 ], [ 0, %114 ]
ret i32 %119
}