#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 cget();
scalar_t__ isascii(int);
scalar_t__ isupper(int);
int tolower(int);
int /*<<< orphan*/ unget();
int evalnum(int c) {
  register int value;
  register int base;
  register int c1;
  if (c != '0')
    base = 10;
  else if ((c = cget()) == 'x' || c == 'X') {
    base = 16;
    c = cget();
  } else
    base = 8;
  value = 0;
  for (;;) {
    c1 = c;
    if (isascii(c) && isupper(c1))
      c1 = tolower(c1);
    if (c1 >= 'a')
      c1 -= ('a' - 10);
    else
      c1 -= '0';
    if (c1 < 0 || c1 >= base)
      break;
    value *= base;
    value += c1;
    c = cget();
  }
  if (c == 'u' || c == 'U')
    cget();
  unget();
  return (value);
}


x86 assembly (clang, -O0):
<evalnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x30,-0x4(%rbp)
je     1171 <evalnum+0x21>
movl   $0xa,-0xc(%rbp)
jmp    11b0 <evalnum+0x60>
mov    $0x0,%al
call   1060 <cget@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x78,%eax
je     118e <evalnum+0x3e>
cmpl   $0x58,-0x4(%rbp)
jne    11a4 <evalnum+0x54>
movl   $0x10,-0xc(%rbp)
mov    $0x0,%al
call   1060 <cget@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <evalnum+0x5b>
movl   $0x8,-0xc(%rbp)
jmp    11b0 <evalnum+0x60>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <isascii@plt>
cmp    $0x0,%rax
je     11ec <evalnum+0x9c>
mov    -0x10(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11ec <evalnum+0x9c>
mov    -0x10(%rbp),%edi
call   1040 <tolower@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x61,-0x10(%rbp)
jl     1204 <evalnum+0xb4>
mov    -0x10(%rbp),%eax
sub    $0x57,%eax
mov    %eax,-0x10(%rbp)
jmp    120d <evalnum+0xbd>
mov    -0x10(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1223 <evalnum+0xd3>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1228 <evalnum+0xd8>
jmp    124a <evalnum+0xfa>
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <cget@plt>
mov    %eax,-0x4(%rbp)
jmp    11b7 <evalnum+0x67>
cmpl   $0x75,-0x4(%rbp)
je     125e <evalnum+0x10e>
cmpl   $0x55,-0x4(%rbp)
jne    1265 <evalnum+0x115>
mov    $0x0,%al
call   1060 <cget@plt>
mov    $0x0,%al
call   1030 <unget@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalnum>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0xa,%r14d
cmp    $0x30,%edi
jne    1189 <evalnum+0x39>
xor    %eax,%eax
call   1060 <cget@plt>
mov    %eax,%ebx
and    $0xffffffdf,%eax
cmp    $0x58,%eax
jne    1183 <evalnum+0x33>
xor    %eax,%eax
call   1060 <cget@plt>
mov    %eax,%ebx
mov    $0x10,%r14d
jmp    1189 <evalnum+0x39>
mov    $0x8,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1070 <isascii@plt>
mov    %rax,%rcx
mov    %ebx,%eax
test   %rcx,%rcx
je     11b9 <evalnum+0x69>
mov    %ebx,%edi
call   1050 <isupper@plt>
mov    %rax,%rcx
mov    %ebx,%eax
test   %rcx,%rcx
je     11b9 <evalnum+0x69>
mov    %ebx,%edi
call   1040 <tolower@plt>
lea    -0x30(%rax),%edx
lea    -0x57(%rax),%ecx
cmp    $0x61,%eax
cmovl  %edx,%ecx
cmp    %r14d,%ecx
jae    11db <evalnum+0x8b>
imul   %r14d,%ebp
add    %ecx,%ebp
xor    %eax,%eax
call   1060 <cget@plt>
mov    %eax,%ebx
jmp    1190 <evalnum+0x40>
and    $0xffffffdf,%ebx
cmp    $0x55,%ebx
jne    11ea <evalnum+0x9a>
xor    %eax,%eax
call   1060 <cget@plt>
xor    %eax,%eax
call   1030 <unget@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @evalnum(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 48
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 10, i32* %4
br label %19
9: ; preds = %1
%10 = call i32 (...) @cget()
store i32 %10, i32* %2
%11 = icmp eq i32 %10, 120
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 88
br i1 %14, label %15, label %17
15: ; preds = %12, %9
store i32 16, i32* %4
%16 = call i32 (...) @cget()
store i32 %16, i32* %2
br label %18
17: ; preds = %12
store i32 8, i32* %4
br label %18
18: ; preds = %17, %15
br label %19
19: ; preds = %18, %8
store i32 0, i32* %3
br label %20
20: ; preds = %49, %19
%21 = load i32, i32* %2
store i32 %21, i32* %5
%22 = load i32, i32* %2
%23 = call i64 @isascii(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* %5
%27 = call i64 @isupper(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %5
%31 = call i32 @tolower(i32 %30)
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %25, %20
%33 = load i32, i32* %5
%34 = icmp sge i32 %33, 97
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %5
%37 = sub nsw i32 %36, 87
store i32 %37, i32* %5
br label %41
38: ; preds = %32
%39 = load i32, i32* %5
%40 = sub nsw i32 %39, 48
store i32 %40, i32* %5
br label %41
41: ; preds = %38, %35
%42 = load i32, i32* %5
%43 = icmp slt i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = load i32, i32* %5
%46 = load i32, i32* %4
%47 = icmp sge i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44, %41
br label %57
49: ; preds = %44
%50 = load i32, i32* %4
%51 = load i32, i32* %3
%52 = mul nsw i32 %51, %50
store i32 %52, i32* %3
%53 = load i32, i32* %5
%54 = load i32, i32* %3
%55 = add nsw i32 %54, %53
store i32 %55, i32* %3
%56 = call i32 (...) @cget()
store i32 %56, i32* %2
br label %20
57: ; preds = %48
%58 = load i32, i32* %2
%59 = icmp eq i32 %58, 117
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = load i32, i32* %2
%62 = icmp eq i32 %61, 85
br i1 %62, label %63, label %65
63: ; preds = %60, %57
%64 = call i32 (...) @cget()
br label %65
65: ; preds = %63, %60
%66 = call i32 (...) @unget()
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
define i32 @evalnum(i32 %0) {
%2 = icmp eq i32 %0, 48
br i1 %2, label %3, label %9
3: ; preds = %1
%4 = tail call i32 (...) @cget()
%5 = and i32 %4, -33
%6 = icmp eq i32 %5, 88
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (...) @cget()
br label %9
9: ; preds = %3, %1, %7
%10 = phi i32 [ %8, %7 ], [ %0, %1 ], [ %4, %3 ]
%11 = phi i32 [ 16, %7 ], [ 10, %1 ], [ 8, %3 ]
br label %12
12: ; preds = %28, %9
%13 = phi i32 [ %10, %9 ], [ %31, %28 ]
%14 = phi i32 [ 0, %9 ], [ %30, %28 ]
%15 = tail call i64 @isascii(i32 %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = tail call i64 @isupper(i32 %13)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @tolower(i32 %13)
br label %22
22: ; preds = %20, %17, %12
%23 = phi i32 [ %21, %20 ], [ %13, %17 ], [ %13, %12 ]
%24 = icmp sgt i32 %23, 96
%25 = select i1 %24, i32 -87, i32 -48
%26 = add nsw i32 %25, %23
%27 = icmp ult i32 %26, %11
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = mul nsw i32 %14, %11
%30 = add nsw i32 %26, %29
%31 = tail call i32 (...) @cget()
br label %12
32: ; preds = %22
%33 = and i32 %13, -33
%34 = icmp eq i32 %33, 85
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 (...) @cget()
br label %37
37: ; preds = %32, %35
%38 = tail call i32 (...) @unget()
ret i32 %14
}