#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__ _is_valid_decimal(char const *);
scalar_t__ _is_valid_fp(char const *);
scalar_t__ _is_valid_hexadecimal(char const *);
scalar_t__ _is_valid_octal(char const *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ toktype_is_na_marker(char const *);
int toktype_infer_narrowest_type(const char *sz, unsigned int *base) {
  assert(!toktype_is_na_marker(sz));
  if (_is_valid_octal(sz)) {
    if (base)
      *base = 8;
    return (2);
  } else if (_is_valid_decimal(sz)) {
    if (base)
      *base = 10;
    return (2);
  } else if (_is_valid_hexadecimal(sz)) {
    if (base)
      *base = 16;
    return (2);
  } else if (_is_valid_fp(sz)) {
    return (4);
  }
  return (1);
}


x86 assembly (clang, -O0):
<toktype_infer_narrowest_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <toktype_is_na_marker@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <_is_valid_octal@plt>
cmp    $0x0,%rax
je     11bf <toktype_infer_narrowest_type+0x5f>
cmpq   $0x0,-0x18(%rbp)
je     11b3 <toktype_infer_narrowest_type+0x53>
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    125c <toktype_infer_narrowest_type+0xfc>
mov    -0x10(%rbp),%rdi
call   1030 <_is_valid_decimal@plt>
cmp    $0x0,%rax
je     11f3 <toktype_infer_narrowest_type+0x93>
cmpq   $0x0,-0x18(%rbp)
je     11e7 <toktype_infer_narrowest_type+0x87>
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    125c <toktype_infer_narrowest_type+0xfc>
mov    -0x10(%rbp),%rdi
call   1080 <_is_valid_hexadecimal@plt>
cmp    $0x0,%rax
je     1227 <toktype_infer_narrowest_type+0xc7>
cmpq   $0x0,-0x18(%rbp)
je     121b <toktype_infer_narrowest_type+0xbb>
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    125c <toktype_infer_narrowest_type+0xfc>
mov    -0x10(%rbp),%rdi
call   1040 <_is_valid_fp@plt>
cmp    $0x0,%rax
je     1246 <toktype_infer_narrowest_type+0xe6>
movl   $0x4,-0x4(%rbp)
jmp    125c <toktype_infer_narrowest_type+0xfc>
jmp    124b <toktype_infer_narrowest_type+0xeb>
jmp    1250 <toktype_infer_narrowest_type+0xf0>
jmp    1255 <toktype_infer_narrowest_type+0xf5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toktype_infer_narrowest_type>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1070 <toktype_is_na_marker@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1050 <_is_valid_octal@plt>
test   %rax,%rax
je     119c <toktype_infer_narrowest_type+0x3c>
mov    $0x2,%eax
test   %r14,%r14
je     11f2 <toktype_infer_narrowest_type+0x92>
movl   $0x8,(%r14)
jmp    11f2 <toktype_infer_narrowest_type+0x92>
mov    %rbx,%rdi
call   1030 <_is_valid_decimal@plt>
test   %rax,%rax
je     11bc <toktype_infer_narrowest_type+0x5c>
mov    $0x2,%eax
test   %r14,%r14
je     11f2 <toktype_infer_narrowest_type+0x92>
movl   $0xa,(%r14)
jmp    11f2 <toktype_infer_narrowest_type+0x92>
mov    %rbx,%rdi
call   1080 <_is_valid_hexadecimal@plt>
test   %rax,%rax
je     11dc <toktype_infer_narrowest_type+0x7c>
mov    $0x2,%eax
test   %r14,%r14
je     11f2 <toktype_infer_narrowest_type+0x92>
movl   $0x10,(%r14)
jmp    11f2 <toktype_infer_narrowest_type+0x92>
mov    %rbx,%rdi
call   1040 <_is_valid_fp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%eax
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @toktype_infer_narrowest_type(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = call i32 @toktype_is_na_marker(i8* %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %4
%13 = call i64 @_is_valid_octal(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32*, i32** %5
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32*, i32** %5
store i32 8, i32* %19
br label %20
20: ; preds = %18, %15
store i32 2, i32* %3
br label %50
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i64 @_is_valid_decimal(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i32*, i32** %5
store i32 10, i32* %29
br label %30
30: ; preds = %28, %25
store i32 2, i32* %3
br label %50
31: ; preds = %21
%32 = load i8*, i8** %4
%33 = call i64 @_is_valid_hexadecimal(i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32*, i32** %5
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32*, i32** %5
store i32 16, i32* %39
br label %40
40: ; preds = %38, %35
store i32 2, i32* %3
br label %50
41: ; preds = %31
%42 = load i8*, i8** %4
%43 = call i64 @_is_valid_fp(i8* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 4, i32* %3
br label %50
46: ; preds = %41
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
store i32 1, i32* %3
br label %50
50: ; preds = %49, %45, %40, %30, %20
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
define i32 @toktype_infer_narrowest_type(i8* %0, i32* writeonly %1) {
%3 = tail call i32 @toktype_is_na_marker(i8* %0)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i64 @_is_valid_octal(i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = icmp eq i32* %1, null
br i1 %10, label %28, label %11
11: ; preds = %9
store i32 8, i32* %1
br label %28
12: ; preds = %2
%13 = tail call i64 @_is_valid_decimal(i8* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = icmp eq i32* %1, null
br i1 %16, label %28, label %17
17: ; preds = %15
store i32 10, i32* %1
br label %28
18: ; preds = %12
%19 = tail call i64 @_is_valid_hexadecimal(i8* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = icmp eq i32* %1, null
br i1 %22, label %28, label %23
23: ; preds = %21
store i32 16, i32* %1
br label %28
24: ; preds = %18
%25 = tail call i64 @_is_valid_fp(i8* %0)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i32 1, i32 4
br label %28
28: ; preds = %24, %21, %23, %15, %17, %9, %11
%29 = phi i32 [ 2, %11 ], [ 2, %9 ], [ 2, %17 ], [ 2, %15 ], [ 2, %23 ], [ 2, %21 ], [ %27, %24 ]
ret i32 %29
}