#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 */
scalar_t__ isxdigit(char const);
unsigned int simple_guess_base(const char *cp) {
  if (cp[0] == '0') {
    if (((cp[1]) | 0x20) == 'x' && isxdigit(cp[2])) {
      return 16;
    } else {
      return 8;
    }
  } else {
    return 10;
  }
}


x86 assembly (clang, -O0):
<simple_guess_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    116f <simple_guess_base+0x5f>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
or     $0x20,%eax
cmp    $0x78,%eax
jne    1163 <simple_guess_base+0x53>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <isxdigit@plt>
cmp    $0x0,%rax
je     1163 <simple_guess_base+0x53>
movl   $0x10,-0x4(%rbp)
jmp    1176 <simple_guess_base+0x66>
movl   $0x8,-0x4(%rbp)
jmp    1176 <simple_guess_base+0x66>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_guess_base>:
push   %rax
mov    $0xa,%eax
cmpb   $0x30,(%rdi)
jne    113a <simple_guess_base+0x2a>
mov    0x1(%rdi),%al
and    $0xdf,%al
cmp    $0x58,%al
jne    113c <simple_guess_base+0x2c>
movsbl 0x2(%rdi),%edi
call   1030 <isxdigit@plt>
mov    %rax,%rcx
mov    $0x10,%eax
test   %rcx,%rcx
je     113c <simple_guess_base+0x2c>
pop    %rcx
ret
mov    $0x8,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @simple_guess_base(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 48
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = or i32 %13, 32
%15 = icmp eq i32 %14, 120
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = load i8, i8* %18
%20 = call i64 @isxdigit(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 16, i32* %2
br label %25
23: ; preds = %16, %9
store i32 8, i32* %2
br label %25
24: ; preds = %1
store i32 10, i32* %2
br label %25
25: ; preds = %24, %23, %22
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @simple_guess_base(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 48
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = and i8 %6, -33
%8 = icmp eq i8 %7, 88
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i64 @isxdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9, %4
br label %15
15: ; preds = %1, %9, %14
%16 = phi i32 [ 8, %14 ], [ 16, %9 ], [ 10, %1 ]
ret i32 %16
}