#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 */
char ReadWhiteSpace(int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ gl_err(char *);
scalar_t__ isdigit(int);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
void ReadNumber(FILE *file, int *result) {
  register int number = 0;
  register char digit;
  register int vorz = 1;
  if ((digit = ReadWhiteSpace(file)) == '-') {
    vorz = -1;
    digit = ReadWhiteSpace(file);
  }
  if (isdigit((int)digit))
    number = digit - '0';
  else
    gl_err("ReadNumber: digit expected");
  while (isdigit((int)(digit = getc(file))))
    number = number * 10 + digit - '0';
  ungetc(digit, file);
  *result = vorz * number;
}


x86 assembly (clang, -O0):
<ReadNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ReadWhiteSpace@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
cmp    $0x2d,%eax
jne    1199 <ReadNumber+0x49>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ReadWhiteSpace@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11bb <ReadNumber+0x6b>
movsbl -0x15(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
jmp    11c7 <ReadNumber+0x77>
lea    0xe3e(%rip),%rdi
call   1060 <gl_err@plt>
jmp    11cc <ReadNumber+0x7c>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11ff <ReadNumber+0xaf>
imul   $0xa,-0x14(%rbp),%eax
movsbl -0x15(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
jmp    11cc <ReadNumber+0x7c>
mov    -0x15(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <ungetc@plt>
mov    -0x1c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadNumber>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <ReadWhiteSpace@plt>
cmp    $0x2d,%al
jne    117a <ReadNumber+0x2a>
mov    %r15,%rdi
call   1050 <ReadWhiteSpace@plt>
mov    $0xffffffff,%r13d
jmp    1180 <ReadNumber+0x30>
mov    $0x1,%r13d
movsbl %al,%r12d
mov    %r12d,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1197 <ReadNumber+0x47>
add    $0xffffffd0,%r12d
jmp    11bc <ReadNumber+0x6c>
lea    0xe62(%rip),%rdi
call   1060 <gl_err@plt>
xor    %r12d,%r12d
jmp    11bc <ReadNumber+0x6c>
nopl   0x0(%rax,%rax,1)
lea    (%r12,%r12,4),%eax
lea    (%rbx,%rax,2),%r12d
add    $0xffffffd0,%r12d
mov    %r15,%rdi
call   1070 <getc@plt>
mov    %eax,%ebp
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11b0 <ReadNumber+0x60>
imul   %r13d,%r12d
movsbl %bpl,%edi
mov    %r15,%rsi
call   1040 <ungetc@plt>
mov    %r12d,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"ReadNumber: digit expected\00"
define void @ReadNumber(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 1, i32* %7
%8 = load i32*, i32** %3
%9 = call signext i8 @ReadWhiteSpace(i32* %8)
store i8 %9, i8* %6
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %2
store i32 -1, i32* %7
%13 = load i32*, i32** %3
%14 = call signext i8 @ReadWhiteSpace(i32* %13)
store i8 %14, i8* %6
br label %15
15: ; preds = %12, %2
%16 = load i8, i8* %6
%17 = sext i8 %16 to i32
%18 = call i64 @isdigit(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 48
store i32 %23, i32* %5
br label %26
24: ; preds = %15
%25 = call i32 @gl_err(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
br label %27
27: ; preds = %33, %26
%28 = load i32*, i32** %3
%29 = call signext i8 @getc(i32* %28)
store i8 %29, i8* %6
%30 = sext i8 %29 to i32
%31 = call i64 @isdigit(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = load i32, i32* %5
%35 = mul nsw i32 %34, 10
%36 = load i8, i8* %6
%37 = sext i8 %36 to i32
%38 = add nsw i32 %35, %37
%39 = sub nsw i32 %38, 48
store i32 %39, i32* %5
br label %27
40: ; preds = %27
%41 = load i8, i8* %6
%42 = load i32*, i32** %3
%43 = call i32 @ungetc(i8 signext %41, i32* %42)
%44 = load i32, i32* %7
%45 = load i32, i32* %5
%46 = mul nsw i32 %44, %45
%47 = load i32*, i32** %4
store i32 %46, i32* %47
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"ReadNumber: digit expected\00"
define void @ReadNumber(i32* %0, i32* nocapture writeonly %1) {
%3 = tail call signext i8 @ReadWhiteSpace(i32* %0)
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call signext i8 @ReadWhiteSpace(i32* %0)
br label %7
7: ; preds = %5, %2
%8 = phi i8 [ %6, %5 ], [ %3, %2 ]
%9 = phi i32 [ -1, %5 ], [ 1, %2 ]
%10 = sext i8 %8 to i32
%11 = tail call i64 @isdigit(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = add nsw i32 %10, -48
br label %17
15: ; preds = %7
%16 = tail call i32 @gl_err(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ 0, %15 ]
%19 = tail call signext i8 @getc(i32* %0)
%20 = sext i8 %19 to i32
%21 = tail call i64 @isdigit(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %17, %23
%24 = phi i32 [ %30, %23 ], [ %20, %17 ]
%25 = phi i32 [ %28, %23 ], [ %18, %17 ]
%26 = mul nsw i32 %25, 10
%27 = add i32 %26, -48
%28 = add i32 %27, %24
%29 = tail call signext i8 @getc(i32* %0)
%30 = sext i8 %29 to i32
%31 = tail call i64 @isdigit(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %23
33: ; preds = %23, %17
%34 = phi i32 [ %18, %17 ], [ %28, %23 ]
%35 = phi i8 [ %19, %17 ], [ %29, %23 ]
%36 = tail call i32 @ungetc(i8 signext %35, i32* %0)
%37 = mul nsw i32 %34, %9
store i32 %37, i32* %1
ret void
}