#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 str2uchar(char *, unsigned char *);
unsigned char atob(char *str_in) {
  unsigned char b = 0;
  int rv;
  rv = str2uchar(str_in, &b);
  switch (rv) {
  case -1:
    printf("atob error: input pointer is NULL\n");
    break;
  case -2:
    printf("atob error: string-to-number conversion overflow\n");
    break;
  case -3:
    printf("atob error: numeric argument is too big for one byte\n");
    break;
  default:
    break;
  }
  return (b);
}


x86 assembly (clang, -O0):
<atob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1030 <str2uchar@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0xfffffffd,%eax
je     1198 <atob+0x78>
jmp    1154 <atob+0x34>
mov    -0x14(%rbp),%eax
sub    $0xfffffffe,%eax
je     1187 <atob+0x67>
jmp    1165 <atob+0x45>
mov    -0x14(%rbp),%eax
sub    $0xffffffff,%eax
jne    11a9 <atob+0x89>
jmp    1176 <atob+0x56>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <atob+0x8e>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <atob+0x8e>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <atob+0x8e>
jmp    11ae <atob+0x8e>
movzbl -0x9(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atob>:
push   %rax
movb   $0x0,0x7(%rsp)
lea    0x7(%rsp),%rsi
call   1030 <str2uchar@plt>
cmp    $0xfffffffd,%eax
jb     114d <atob+0x2d>
add    $0x3,%eax
cltq
lea    0xf47(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1040 <puts@plt>
mov    0x7(%rsp),%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"atob error: input pointer is NULL\0A\00"
@.str.1 = [50 x i8] c"atob error: string-to-number conversion overflow\0A\00"
@.str.2 = [54 x i8] c"atob error: numeric argument is too big for one byte\0A\00"
define zeroext i8 @atob(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
store i8 0, i8* %3
%5 = load i8*, i8** %2
%6 = call i32 @str2uchar(i8* %5, i8* %3)
store i32 %6, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %14 [
i32 -1, label %8
i32 -2, label %10
i32 -3, label %12
]
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %15
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %15
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %15
14: ; preds = %1
br label %15
15: ; preds = %14, %12, %10, %8
%16 = load i8, i8* %3
ret i8 %16
}

LLVM IR (-O2):
@str = [53 x i8] c"atob error: numeric argument is too big for one byte\00"
@str.3 = [49 x i8] c"atob error: string-to-number conversion overflow\00"
@str.4 = [34 x i8] c"atob error: input pointer is NULL\00"
@reltable.atob = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @str to i64), i64 ptrtoint ([3 x i32]* @reltable.atob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([49 x i8]* @str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.atob to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.atob to i64)) to i32)]
define zeroext i8 @atob(i8* %0) {
%2 = alloca i8
store i8 0, i8* %2
%3 = call i32 @str2uchar(i8* %0, i8* %2)
%4 = icmp ugt i32 %3, -4
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = add i32 %3, 3
%7 = sext i32 %6 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.atob to i8*), i64 %8)
%10 = call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %1, %5
%12 = load i8, i8* %2
ret i8 %12
}