#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fgetc(int /*<<< orphan*/ *);
scalar_t__ isDigit(int);
int getNumber(FILE *f, int *base) {
  int res = 0;
  while ((isDigit(*base)) && (f)) {
    res *= 10;
    res += *base - '0';
    *base = fgetc(f);
  }
  return res;
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <isDigit@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x15(%rbp)
je     115f <getNumber+0x3f>
cmpq   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    116f <getNumber+0x4f>
jmp    119b <getNumber+0x7b>
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sub    $0x30,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1137 <getNumber+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumber>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%edi
call   1040 <isDigit@plt>
xor    %ebx,%ebx
test   %r14,%r14
je     1163 <getNumber+0x43>
test   %rax,%rax
je     1163 <getNumber+0x43>
xor    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
mov    (%r15),%ecx
lea    (%rcx,%rax,2),%ebx
add    $0xffffffd0,%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,(%r15)
mov    %eax,%edi
call   1040 <isDigit@plt>
test   %rax,%rax
jne    1140 <getNumber+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @getNumber(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %16, %2
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = call i64 @isDigit(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32*, i32** %3
%13 = icmp ne i32* %12, null
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %27
16: ; preds = %14
%17 = load i32, i32* %5
%18 = mul nsw i32 %17, 10
store i32 %18, i32* %5
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = sub nsw i32 %20, 48
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
store i32 %23, i32* %5
%24 = load i32*, i32** %3
%25 = call i32 @fgetc(i32* %24)
%26 = load i32*, i32** %4
store i32 %25, i32* %26
br label %6
27: ; preds = %14
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @getNumber(i32* %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = tail call i64 @isDigit(i32 %3)
%5 = icmp ne i64 %4, 0
%6 = icmp ne i32* %0, null
%7 = and i1 %6, %5
br i1 %7, label %8, label %17
8: ; preds = %2, %8
%9 = phi i32 [ %13, %8 ], [ 0, %2 ]
%10 = mul nsw i32 %9, 10
%11 = load i32, i32* %1
%12 = add i32 %10, -48
%13 = add i32 %12, %11
%14 = tail call i32 @fgetc(i32* %0)
store i32 %14, i32* %1
%15 = tail call i64 @isDigit(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %2
%18 = phi i32 [ 0, %2 ], [ %13, %8 ]
ret i32 %18
}