#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;
int /*<<< orphan*/ SEEK_CUR;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int nextNumber(FILE *fp) {
  char c = 0;
  while (c < '0' || c > '9') {
    c = fgetc(fp);
    if (c == EOF)
      return -1;
    if (c == '\n')
      return 0;
  }
  fseek(fp, -1, SEEK_CUR);
  return 1;
}


x86 assembly (clang, -O0):
<nextNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x12(%rbp)
jl     114f <nextNumber+0x2f>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    115f <nextNumber+0x3f>
jmp    11ab <nextNumber+0x8b>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e6a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    118d <nextNumber+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <nextNumber+0xa9>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    11a6 <nextNumber+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <nextNumber+0xa9>
jmp    1130 <nextNumber+0x10>
mov    -0x10(%rbp),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1040 <fseek@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextNumber>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
mov    0x2eb0(%rip),%r14
add    $0xc6,%al
cmp    $0xf5,%al
ja     114b <nextNumber+0x2b>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r14),%al
je     1168 <nextNumber+0x48>
cmp    $0xa,%al
jne    1130 <nextNumber+0x10>
xor    %eax,%eax
jmp    116d <nextNumber+0x4d>
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1040 <fseek@plt>
mov    $0x1,%eax
jmp    116d <nextNumber+0x4d>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
@SEEK_CUR = global i32 0
define i32 @nextNumber(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
store i32* %0, i32** %3
store i8 0, i8* %4
br label %5
5: ; preds = %29, %1
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp slt i32 %7, 48
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp sgt i32 %11, 57
br label %13
13: ; preds = %9, %5
%14 = phi i1 [ true, %5 ], [ %12, %9 ]
br i1 %14, label %15, label %30
15: ; preds = %13
%16 = load i32*, i32** %3
%17 = call signext i8 @fgetc(i32* %16)
store i8 %17, i8* %4
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %15
store i32 -1, i32* %2
br label %34
24: ; preds = %15
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 0, i32* %2
br label %34
29: ; preds = %24
br label %5
30: ; preds = %13
%31 = load i32*, i32** %3
%32 = load i32, i32* @SEEK_CUR
%33 = call i32 @fseek(i32* %31, i32 -1, i32 %32)
store i32 1, i32* %2
br label %34
34: ; preds = %30, %28, %23
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@EOF = global i8 0
@SEEK_CUR = global i32 0
define i32 @nextNumber(i32* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i8 [ 0, %1 ], [ %7, %10 ]
%4 = add i8 %3, -58
%5 = icmp ult i8 %4, -10
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = tail call signext i8 @fgetc(i32* %0)
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %15, label %10
10: ; preds = %6
%11 = icmp eq i8 %7, 10
br i1 %11, label %15, label %2
12: ; preds = %2
%13 = load i32, i32* @SEEK_CUR
%14 = tail call i32 @fseek(i32* %0, i32 -1, i32 %13)
br label %15
15: ; preds = %10, %6, %12
%16 = phi i32 [ 1, %12 ], [ 0, %10 ], [ -1, %6 ]
ret i32 %16
}