#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 */
scalar_t__ isdigit(int);
scalar_t__ isspace(int);
int nextchar(int);
int cutint(int fd) {
  int c;
  int n = 0;
  do {
    c = nextchar(fd);
  } while (isspace(c));
  while (isdigit(c)) {
    n = n * 10 + c - '0';
    c = nextchar(fd);
  }
  return n;
}


x86 assembly (clang, -O0):
<cutint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <nextchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    1142 <cutint+0x12>
jmp    1164 <cutint+0x34>
mov    -0x8(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1193 <cutint+0x63>
imul   $0xa,-0xc(%rbp),%eax
add    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <nextchar@plt>
mov    %eax,-0x8(%rbp)
jmp    1164 <cutint+0x34>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutint>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   1050 <nextchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <cutint+0x10>
mov    %ebx,%edi
call   1030 <isdigit@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1190 <cutint+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x0(%rbp,%rbp,4),%eax
lea    (%rbx,%rax,2),%ebp
add    $0xffffffd0,%ebp
mov    %r14d,%edi
call   1050 <nextchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1170 <cutint+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @cutint(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call i32 @nextchar(i32 %0)
%4 = tail call i64 @isspace(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %2
6: ; preds = %2
%7 = tail call i64 @isdigit(i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6, %9
%10 = phi i32 [ %14, %9 ], [ 0, %6 ]
%11 = phi i32 [ %15, %9 ], [ %3, %6 ]
%12 = mul nsw i32 %10, 10
%13 = add i32 %11, -48
%14 = add i32 %13, %12
%15 = tail call i32 @nextchar(i32 %0)
%16 = tail call i64 @isdigit(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %6
%19 = phi i32 [ 0, %6 ], [ %14, %9 ]
ret i32 %19
}