#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 */
char ahextobin(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int test_ahextobin(void) {
  char c;
  char i;
  for (c = '0', i = 0; c <= '9'; c++, i++) {
    if (ahextobin(&c) != i) {
      fprintf(stderr, "ahextobin(): failed %d != %c\n", i, c);
      return 0;
    }
  }
  for (c = 'A', i = 10; c <= 'F'; c++, i++) {
    if (ahextobin(&c) != i) {
      fprintf(stderr, "ahextobin(): failed %d != %c\n", i, c);
      return 0;
    }
  }
  for (c = 'a', i = 10; c <= 'f'; c++, i++) {
    if (ahextobin(&c) != i) {
      fprintf(stderr, "ahextobin(): failed %d != %c\n", i, c);
      return 0;
    }
  }
  fprintf(stderr, "ahextobin(): Passed\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_ahextobin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x30,-0x5(%rbp)
movb   $0x0,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     119a <test_ahextobin+0x7a>
lea    -0x5(%rbp),%rdi
call   1040 <ahextobin@plt>
movsbl %al,%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
je     1180 <test_ahextobin+0x60>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
movsbl -0x6(%rbp),%edx
movsbl -0x5(%rbp),%ecx
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_ahextobin+0x17c>
jmp    1185 <test_ahextobin+0x65>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    1130 <test_ahextobin+0x10>
movb   $0x41,-0x5(%rbp)
movb   $0xa,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     120c <test_ahextobin+0xec>
lea    -0x5(%rbp),%rdi
call   1040 <ahextobin@plt>
movsbl %al,%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
je     11f2 <test_ahextobin+0xd2>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
movsbl -0x6(%rbp),%edx
movsbl -0x5(%rbp),%ecx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_ahextobin+0x17c>
jmp    11f7 <test_ahextobin+0xd7>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    11a2 <test_ahextobin+0x82>
movb   $0x61,-0x5(%rbp)
movb   $0xa,-0x6(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     127e <test_ahextobin+0x15e>
lea    -0x5(%rbp),%rdi
call   1040 <ahextobin@plt>
movsbl %al,%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
je     1264 <test_ahextobin+0x144>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
movsbl -0x6(%rbp),%edx
movsbl -0x5(%rbp),%ecx
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <test_ahextobin+0x17c>
jmp    1269 <test_ahextobin+0x149>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    1214 <test_ahextobin+0xf4>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ahextobin>:
push   %rbp
push   %rbx
push   %rax
movb   $0x30,0x7(%rsp)
xor    %ebp,%ebp
lea    0x7(%rsp),%rbx
nop
mov    %rbx,%rdi
call   1040 <ahextobin@plt>
cmp    %al,%bpl
jne    11cc <test_ahextobin+0xac>
movzbl 0x7(%rsp),%eax
add    $0x1,%al
mov    %al,0x7(%rsp)
add    $0x1,%bpl
cmp    $0x3a,%al
jl     1130 <test_ahextobin+0x10>
movb   $0x41,0x7(%rsp)
mov    $0xa,%bl
lea    0x7(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <ahextobin@plt>
cmp    %al,%bl
jne    11d2 <test_ahextobin+0xb2>
movzbl 0x7(%rsp),%eax
add    $0x1,%al
mov    %al,0x7(%rsp)
add    $0x1,%bl
cmp    $0x47,%al
jl     1160 <test_ahextobin+0x40>
movb   $0x61,0x7(%rsp)
mov    $0xa,%bl
lea    0x7(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <ahextobin@plt>
cmp    %al,%bl
jne    11d2 <test_ahextobin+0xb2>
movzbl 0x7(%rsp),%eax
add    $0x1,%al
mov    %al,0x7(%rsp)
add    $0x1,%bl
cmp    $0x67,%al
jl     1190 <test_ahextobin+0x70>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%ebx
jmp    11f3 <test_ahextobin+0xd3>
movsbl %bpl,%edx
jmp    11d5 <test_ahextobin+0xb5>
movsbl %bl,%edx
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
movsbl 0x7(%rsp),%ecx
lea    0xe16(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"ahextobin(): failed %d != %c\0A\00"
@.str.1 = [21 x i8] c"ahextobin(): Passed\0A\00"
define i32 @test_ahextobin() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
store i8 48, i8* %2
store i8 0, i8* %3
br label %4
4: ; preds = %22, %0
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp sle i32 %6, 57
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = call signext i8 @ahextobin(i8* %2)
%10 = sext i8 %9 to i32
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %21
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
store i32 0, i32* %1
br label %78
21: ; preds = %8
br label %22
22: ; preds = %21
%23 = load i8, i8* %2
%24 = add i8 %23, 1
store i8 %24, i8* %2
%25 = load i8, i8* %3
%26 = add i8 %25, 1
store i8 %26, i8* %3
br label %4
27: ; preds = %4
store i8 65, i8* %2
store i8 10, i8* %3
br label %28
28: ; preds = %46, %27
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = icmp sle i32 %30, 70
br i1 %31, label %32, label %51
32: ; preds = %28
%33 = call signext i8 @ahextobin(i8* %2)
%34 = sext i8 %33 to i32
%35 = load i8, i8* %3
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %34, %36
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %41, i32 %43)
store i32 0, i32* %1
br label %78
45: ; preds = %32
br label %46
46: ; preds = %45
%47 = load i8, i8* %2
%48 = add i8 %47, 1
store i8 %48, i8* %2
%49 = load i8, i8* %3
%50 = add i8 %49, 1
store i8 %50, i8* %3
br label %28
51: ; preds = %28
store i8 97, i8* %2
store i8 10, i8* %3
br label %52
52: ; preds = %70, %51
%53 = load i8, i8* %2
%54 = sext i8 %53 to i32
%55 = icmp sle i32 %54, 102
br i1 %55, label %56, label %75
56: ; preds = %52
%57 = call signext i8 @ahextobin(i8* %2)
%58 = sext i8 %57 to i32
%59 = load i8, i8* %3
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %58, %60
br i1 %61, label %62, label %69
62: ; preds = %56
%63 = load i32, i32* @stderr
%64 = load i8, i8* %3
%65 = sext i8 %64 to i32
%66 = load i8, i8* %2
%67 = sext i8 %66 to i32
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %65, i32 %67)
store i32 0, i32* %1
br label %78
69: ; preds = %56
br label %70
70: ; preds = %69
%71 = load i8, i8* %2
%72 = add i8 %71, 1
store i8 %72, i8* %2
%73 = load i8, i8* %3
%74 = add i8 %73, 1
store i8 %74, i8* %3
br label %52
75: ; preds = %52
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %78
78: ; preds = %75, %62, %38, %14
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"ahextobin(): failed %d != %c\0A\00"
@.str.1 = [21 x i8] c"ahextobin(): Passed\0A\00"
define i32 @test_ahextobin() {
%1 = alloca i8
store i8 48, i8* %1
br label %2
2: ; preds = %0, %12
%3 = phi i8 [ 0, %0 ], [ %15, %12 ]
%4 = call signext i8 @ahextobin(i8* %1)
%5 = icmp eq i8 %4, %3
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = sext i8 %3 to i32
%8 = load i32, i32* @stderr
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
br label %52
12: ; preds = %2
%13 = load i8, i8* %1
%14 = add i8 %13, 1
store i8 %14, i8* %1
%15 = add i8 %3, 1
%16 = icmp slt i8 %14, 58
br i1 %16, label %2, label %17
17: ; preds = %12
store i8 65, i8* %1
br label %18
18: ; preds = %17, %28
%19 = phi i8 [ 10, %17 ], [ %31, %28 ]
%20 = call signext i8 @ahextobin(i8* %1)
%21 = icmp eq i8 %20, %19
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = sext i8 %19 to i32
%24 = load i32, i32* @stderr
%25 = load i8, i8* %1
%26 = sext i8 %25 to i32
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %26)
br label %52
28: ; preds = %18
%29 = load i8, i8* %1
%30 = add i8 %29, 1
store i8 %30, i8* %1
%31 = add i8 %19, 1
%32 = icmp slt i8 %30, 71
br i1 %32, label %18, label %33
33: ; preds = %28
store i8 97, i8* %1
br label %34
34: ; preds = %33, %44
%35 = phi i8 [ 10, %33 ], [ %47, %44 ]
%36 = call signext i8 @ahextobin(i8* %1)
%37 = icmp eq i8 %36, %35
br i1 %37, label %44, label %38
38: ; preds = %34
%39 = sext i8 %35 to i32
%40 = load i32, i32* @stderr
%41 = load i8, i8* %1
%42 = sext i8 %41 to i32
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %42)
br label %52
44: ; preds = %34
%45 = load i8, i8* %1
%46 = add i8 %45, 1
store i8 %46, i8* %1
%47 = add i8 %35, 1
%48 = icmp slt i8 %46, 103
br i1 %48, label %34, label %49
49: ; preds = %44
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %49, %38, %22, %6
%53 = phi i32 [ 0, %6 ], [ 0, %22 ], [ 0, %38 ], [ 1, %49 ]
ret i32 %53
}