#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 EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, scalar_t__, long);
scalar_t__ ftell(int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int get_num(FILE *fp) {
  int number = 0;
  char ch;
  while (isspace(ch = fgetc(fp)))
    ;
  fseek(fp, ftell(fp) - 1, 0L);
  while (EOF != (ch = fgetc(fp)) && !isspace(ch)) {
    number *= 10;
    number += ch - '0';
  }
  return number;
}


x86 assembly (clang, -O0):
<get_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1176 <get_num+0x36>
jmp    1153 <get_num+0x13>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rsi
sub    $0x1,%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <fseek@plt>
mov    0x2e46(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    -0x20(%rbp),%ecx
mov    %al,-0xd(%rbp)
movsbl %al,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
je     11dc <get_num+0x9c>
movsbl -0xd(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11ec <get_num+0xac>
jmp    1205 <get_num+0xc5>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsbl -0xd(%rbp),%eax
sub    $0x30,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    119b <get_num+0x5b>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_num>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <fgetc@plt>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <get_num+0x10>
mov    %r14,%rdi
call   1050 <ftell@plt>
lea    -0x1(%rax),%rsi
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %edx,%edx
call   1060 <fseek@plt>
mov    0x2e63(%rip),%r12
mov    (%r12),%bl
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    %al,%bl
je     11cc <get_num+0x8c>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsbl %al,%ebx
mov    %ebx,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    11cc <get_num+0x8c>
lea    (%r15,%r15,4),%eax
lea    (%rbx,%rax,2),%r15d
add    $0xffffffd0,%r15d
movzbl (%r12),%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    %al,%bl
jne    11a0 <get_num+0x60>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @get_num(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %10, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @fgetc(i32* %6)
store i8 %7, i8* %4
%8 = call i64 @isspace(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %5
11: ; preds = %5
%12 = load i32*, i32** %2
%13 = load i32*, i32** %2
%14 = call i64 @ftell(i32* %13)
%15 = sub nsw i64 %14, 1
%16 = call i32 @fseek(i32* %12, i64 %15, i64 0)
br label %17
17: ; preds = %31, %11
%18 = load i8, i8* @EOF
%19 = sext i8 %18 to i32
%20 = load i32*, i32** %2
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %19, %22
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i8, i8* %4
%26 = call i64 @isspace(i8 signext %25)
%27 = icmp ne i64 %26, 0
%28 = xor i1 %27, true
br label %29
29: ; preds = %24, %17
%30 = phi i1 [ false, %17 ], [ %28, %24 ]
br i1 %30, label %31, label %39
31: ; preds = %29
%32 = load i32, i32* %3
%33 = mul nsw i32 %32, 10
store i32 %33, i32* %3
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 48
%37 = load i32, i32* %3
%38 = add nsw i32 %37, %36
store i32 %38, i32* %3
br label %17
39: ; preds = %29
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @get_num(i32* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = tail call i64 @isspace(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %2
6: ; preds = %2
%7 = tail call i64 @ftell(i32* %0)
%8 = add nsw i64 %7, -1
%9 = tail call i32 @fseek(i32* %0, i64 %8, i64 0)
%10 = load i8, i8* @EOF
%11 = tail call signext i8 @fgetc(i32* %0)
%12 = icmp eq i8 %10, %11
br i1 %12, label %26, label %13
13: ; preds = %6, %18
%14 = phi i8 [ %24, %18 ], [ %11, %6 ]
%15 = phi i32 [ %22, %18 ], [ 0, %6 ]
%16 = tail call i64 @isspace(i8 signext %14)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = sext i8 %14 to i32
%20 = mul nsw i32 %15, 10
%21 = add i32 %20, -48
%22 = add i32 %21, %19
%23 = load i8, i8* @EOF
%24 = tail call signext i8 @fgetc(i32* %0)
%25 = icmp eq i8 %23, %24
br i1 %25, label %26, label %13
26: ; preds = %13, %18, %6
%27 = phi i32 [ 0, %6 ], [ %22, %18 ], [ %15, %13 ]
ret i32 %27
}