#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 */
struct jelio_buf {
  int dummy;
};

/* Variables and functions */
scalar_t__ char_isspace(int);
int /*<<< orphan*/ jelio_buffer_getc(struct jelio_buf *);
int jelio_buffer_peekc(struct jelio_buf *);
int i_lu_conv(void *value, int n, void *inbuf) {
  struct jelio_buf *jb = inbuf;
  unsigned long int *ival = value;
  int c, count = 0, wcount = 0;
  *ival = 0;
  for (c = jelio_buffer_peekc(jb); char_isspace(c);
       c = jelio_buffer_peekc(jb)) {
    jelio_buffer_getc(jb);
    wcount++;
  }
  while (1) {
    c = jelio_buffer_peekc(jb);
    if (c < '0' || c > '9')
      break;
    count++;
    jelio_buffer_getc(jb);
    *ival *= 10;
    *ival += c - '0';
  }
  if (!count)
    return 0;
  return count + wcount;
}


x86 assembly (clang, -O0):
<i_lu_conv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1050 <char_isspace@plt>
cmp    $0x0,%rax
je     11ad <i_lu_conv+0x7d>
mov    -0x28(%rbp),%rdi
call   1030 <jelio_buffer_getc@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,-0x34(%rbp)
jmp    1178 <i_lu_conv+0x48>
jmp    11b2 <i_lu_conv+0x82>
mov    -0x28(%rbp),%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x30,-0x34(%rbp)
jl     11d2 <i_lu_conv+0xa2>
cmpl   $0x39,-0x34(%rbp)
jle    11d7 <i_lu_conv+0xa7>
jmp    120c <i_lu_conv+0xdc>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <jelio_buffer_getc@plt>
mov    -0x30(%rbp),%rax
imul   $0xa,(%rax),%rcx
mov    %rcx,(%rax)
mov    -0x34(%rbp),%eax
sub    $0x30,%eax
movslq %eax,%rcx
mov    -0x30(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
jmp    11b2 <i_lu_conv+0x82>
cmpl   $0x0,-0x38(%rbp)
jne    1222 <i_lu_conv+0xf2>
movl   $0x0,-0x4(%rbp)
jmp    122b <i_lu_conv+0xfb>
mov    -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i_lu_conv>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rdi,%r14
movq   $0x0,(%rdi)
mov    %rdx,%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,%edi
call   1050 <char_isspace@plt>
xor    %r12d,%r12d
mov    $0x0,%ebp
test   %rax,%rax
je     118f <i_lu_conv+0x5f>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <jelio_buffer_getc@plt>
add    $0x1,%ebp
mov    %r15,%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,%edi
call   1050 <char_isspace@plt>
test   %rax,%rax
jne    1170 <i_lu_conv+0x40>
mov    %r15,%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,%ebx
lea    -0x3a(%rbx),%eax
cmp    $0xfffffff6,%eax
jb     11df <i_lu_conv+0xaf>
mov    %ebp,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <jelio_buffer_getc@plt>
mov    (%r14),%rax
lea    (%rax,%rax,4),%rax
add    $0xffffffd0,%ebx
lea    (%rbx,%rax,2),%rax
mov    %rax,(%r14)
mov    %r15,%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,%ebx
add    $0xffffffc6,%eax
add    $0x1,%r12d
cmp    $0xfffffff5,%eax
ja     11b0 <i_lu_conv+0x80>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.jelio_buf = type { i32 }
define i32 @i_lu_conv(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.jelio_buf*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%13 = load i8*, i8** %7
%14 = bitcast i8* %13 to %struct.jelio_buf*
store %struct.jelio_buf* %14, %struct.jelio_buf** %8
%15 = load i8*, i8** %5
%16 = bitcast i8* %15 to i64*
store i64* %16, i64** %9
store i32 0, i32* %11
store i32 0, i32* %12
%17 = load i64*, i64** %9
store i64 0, i64* %17
%18 = load %struct.jelio_buf*, %struct.jelio_buf** %8
%19 = call i32 @jelio_buffer_peekc(%struct.jelio_buf* %18)
store i32 %19, i32* %10
br label %20
20: ; preds = %29, %3
%21 = load i32, i32* %10
%22 = call i64 @char_isspace(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load %struct.jelio_buf*, %struct.jelio_buf** %8
%26 = call i32 @jelio_buffer_getc(%struct.jelio_buf* %25)
%27 = load i32, i32* %12
%28 = add nsw i32 %27, 1
store i32 %28, i32* %12
br label %29
29: ; preds = %24
%30 = load %struct.jelio_buf*, %struct.jelio_buf** %8
%31 = call i32 @jelio_buffer_peekc(%struct.jelio_buf* %30)
store i32 %31, i32* %10
br label %20
32: ; preds = %20
br label %33
33: ; preds = %32, %42
%34 = load %struct.jelio_buf*, %struct.jelio_buf** %8
%35 = call i32 @jelio_buffer_peekc(%struct.jelio_buf* %34)
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = icmp slt i32 %36, 48
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = load i32, i32* %10
%40 = icmp sgt i32 %39, 57
br i1 %40, label %41, label %42
41: ; preds = %38, %33
br label %56
42: ; preds = %38
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
%45 = load %struct.jelio_buf*, %struct.jelio_buf** %8
%46 = call i32 @jelio_buffer_getc(%struct.jelio_buf* %45)
%47 = load i64*, i64** %9
%48 = load i64, i64* %47
%49 = mul i64 %48, 10
store i64 %49, i64* %47
%50 = load i32, i32* %10
%51 = sub nsw i32 %50, 48
%52 = sext i32 %51 to i64
%53 = load i64*, i64** %9
%54 = load i64, i64* %53
%55 = add i64 %54, %52
store i64 %55, i64* %53
br label %33
56: ; preds = %41
%57 = load i32, i32* %11
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %56
store i32 0, i32* %4
br label %64
60: ; preds = %56
%61 = load i32, i32* %11
%62 = load i32, i32* %12
%63 = add nsw i32 %61, %62
store i32 %63, i32* %4
br label %64
64: ; preds = %60, %59
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
%struct.jelio_buf = type { i32 }
define i32 @i_lu_conv(i8* nocapture %0, i32 %1, i8* %2) {
%4 = bitcast i8* %2 to %struct.jelio_buf*
%5 = bitcast i8* %0 to i64*
store i64 0, i64* %5
%6 = tail call i32 @jelio_buffer_peekc(%struct.jelio_buf* %4)
%7 = tail call i64 @char_isspace(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %14, %3
%10 = phi i32 [ 0, %3 ], [ %17, %14 ]
%11 = tail call i32 @jelio_buffer_peekc(%struct.jelio_buf* %4)
%12 = add i32 %11, -58
%13 = icmp ult i32 %12, -10
br i1 %13, label %36, label %21
14: ; preds = %3, %14
%15 = phi i32 [ %17, %14 ], [ 0, %3 ]
%16 = tail call i32 @jelio_buffer_getc(%struct.jelio_buf* %4)
%17 = add nuw nsw i32 %15, 1
%18 = tail call i32 @jelio_buffer_peekc(%struct.jelio_buf* %4)
%19 = tail call i64 @char_isspace(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %9, label %14
21: ; preds = %9, %21
%22 = phi i32 [ %31, %21 ], [ %11, %9 ]
%23 = phi i32 [ %24, %21 ], [ 0, %9 ]
%24 = add nuw nsw i32 %23, 1
%25 = tail call i32 @jelio_buffer_getc(%struct.jelio_buf* %4)
%26 = load i64, i64* %5
%27 = mul i64 %26, 10
%28 = add nsw i32 %22, -48
%29 = zext i32 %28 to i64
%30 = add i64 %27, %29
store i64 %30, i64* %5
%31 = tail call i32 @jelio_buffer_peekc(%struct.jelio_buf* %4)
%32 = add i32 %31, -58
%33 = icmp ult i32 %32, -10
br i1 %33, label %34, label %21
34: ; preds = %21
%35 = add nuw nsw i32 %24, %10
br label %36
36: ; preds = %9, %34
%37 = phi i32 [ %35, %34 ], [ 0, %9 ]
ret i32 %37
}