#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 */
char EOF;
char getChar();
scalar_t__ isdigit(char);
int /*<<< orphan*/ ungetChar();
int getNumber() {
  int var = 0;
  char ch;
  while ((ch = getChar()) != EOF && isdigit(ch))
    var = var * 10 + ch - '0';
  ungetChar();
  return var;
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getChar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%ecx
mov    0x2e95(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x6(%rbp)
je     1176 <getNumber+0x46>
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    1186 <getNumber+0x56>
jmp    119b <getNumber+0x6b>
imul   $0xa,-0x4(%rbp),%eax
movsbl -0x5(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <getNumber+0xf>
mov    $0x0,%al
call   1050 <ungetChar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumber>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getChar@plt>
mov    0x2ea2(%rip),%r15
cmp    (%r15),%al
je     1177 <getNumber+0x47>
xor    %r14d,%r14d
xchg   %ax,%ax
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1177 <getNumber+0x47>
lea    (%r14,%r14,4),%eax
lea    (%rbx,%rax,2),%r14d
add    $0xffffffd0,%r14d
xor    %eax,%eax
call   1040 <getChar@plt>
cmp    (%r15),%al
jne    1150 <getNumber+0x20>
xor    %eax,%eax
call   1050 <ungetChar@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @getNumber() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %15, %0
%4 = call signext i8 (...) @getChar()
store i8 %4, i8* %2
%5 = sext i8 %4 to i32
%6 = load i8, i8* @EOF
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8, i8* %2
%11 = call i64 @isdigit(i8 signext %10)
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %9, %3
%14 = phi i1 [ false, %3 ], [ %12, %9 ]
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = load i32, i32* %1
%17 = mul nsw i32 %16, 10
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = add nsw i32 %17, %19
%21 = sub nsw i32 %20, 48
store i32 %21, i32* %1
br label %3
22: ; preds = %13
%23 = call i32 (...) @ungetChar()
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @getNumber() {
%1 = tail call signext i8 (...) @getChar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %17, label %4
4: ; preds = %0, %9
%5 = phi i8 [ %14, %9 ], [ %1, %0 ]
%6 = phi i32 [ %13, %9 ], [ 0, %0 ]
%7 = tail call i64 @isdigit(i8 signext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %4
%10 = sext i8 %5 to i32
%11 = mul nsw i32 %6, 10
%12 = add i32 %11, -48
%13 = add i32 %12, %10
%14 = tail call signext i8 (...) @getChar()
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %4
17: ; preds = %4, %9, %0
%18 = phi i32 [ 0, %0 ], [ %13, %9 ], [ %6, %4 ]
%19 = tail call i32 (...) @ungetChar()
ret i32 %18
}