#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*/ skipspace(char **);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int gethex(char **c) {
  int value;
  skipspace(c);
  if (!(**c))
    return (0);
  sscanf(*c, "%x", &value);
  while (**c != ' ' && (**c))
    (*c)++;
  return (value);
}


x86 assembly (clang, -O0):
<gethex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <skipspace@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
jne    1151 <gethex+0x31>
movl   $0x0,-0x4(%rbp)
jmp    11bc <gethex+0x9c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea1(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x15(%rbp)
je     1193 <gethex+0x73>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11a3 <gethex+0x83>
jmp    11b6 <gethex+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1168 <gethex+0x48>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gethex>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <skipspace@plt>
mov    (%rbx),%rdi
cmpb   $0x0,(%rdi)
je     1165 <gethex+0x45>
lea    0xec4(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
mov    (%rbx),%rax
nopl   0x0(%rax)
add    $0x1,%rax
testb  $0xdf,-0x1(%rax)
je     115f <gethex+0x3f>
mov    %rax,(%rbx)
jmp    1150 <gethex+0x30>
mov    0xc(%rsp),%eax
jmp    1167 <gethex+0x47>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
define i32 @gethex(i8** %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @skipspace(i8** %0)
%5 = load i8*, i8** %0
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %1
%9 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i8*, i8** %0
br label %11
11: ; preds = %14, %8
%12 = phi i8* [ %15, %14 ], [ %10, %8 ]
%13 = load i8, i8* %12
switch i8 %13, label %14 [
i8 32, label %16
i8 0, label %16
]
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %15, i8** %0
br label %11
16: ; preds = %11, %11
%17 = load i32, i32* %2
br label %18
18: ; preds = %1, %16
%19 = phi i32 [ %17, %16 ], [ 0, %1 ]
ret i32 %19
}