#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 uid_t;
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_uid_conv(void *value, int n, void *inbuf) {
  struct jelio_buf *jb = inbuf;
  uid_t *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_uid_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
movl   $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     11ac <i_uid_conv+0x7c>
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    1177 <i_uid_conv+0x47>
jmp    11b1 <i_uid_conv+0x81>
mov    -0x28(%rbp),%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x30,-0x34(%rbp)
jl     11d1 <i_uid_conv+0xa1>
cmpl   $0x39,-0x34(%rbp)
jle    11d6 <i_uid_conv+0xa6>
jmp    1204 <i_uid_conv+0xd4>
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),%ecx
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
sub    $0x30,%ecx
mov    -0x30(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11b1 <i_uid_conv+0x81>
cmpl   $0x0,-0x38(%rbp)
jne    121a <i_uid_conv+0xea>
movl   $0x0,-0x4(%rbp)
jmp    1223 <i_uid_conv+0xf3>
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_uid_conv>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rdi,%r14
movl   $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_uid_conv+0x5f>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%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_uid_conv+0x40>
mov    %r15,%rdi
call   1040 <jelio_buffer_peekc@plt>
mov    %eax,%ebx
lea    -0x3a(%rbx),%eax
cmp    $0xfffffff6,%eax
jb     11dd <i_uid_conv+0xad>
mov    %ebp,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <jelio_buffer_getc@plt>
mov    (%r14),%eax
lea    (%rax,%rax,4),%eax
lea    (%rbx,%rax,2),%eax
add    $0xffffffd0,%eax
mov    %eax,(%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_uid_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_uid_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 i32*
%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 i32*
store i32* %16, i32** %9
store i32 0, i32* %11
store i32 0, i32* %12
%17 = load i32*, i32** %9
store i32 0, i32* %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 %55
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 i32*, i32** %9
%48 = load i32, i32* %47
%49 = mul nsw i32 %48, 10
store i32 %49, i32* %47
%50 = load i32, i32* %10
%51 = sub nsw i32 %50, 48
%52 = load i32*, i32** %9
%53 = load i32, i32* %52
%54 = add nsw i32 %53, %51
store i32 %54, i32* %52
br label %33
55: ; preds = %41
%56 = load i32, i32* %11
%57 = icmp ne i32 %56, 0
br i1 %57, label %59, label %58
58: ; preds = %55
store i32 0, i32* %4
br label %63
59: ; preds = %55
%60 = load i32, i32* %11
%61 = load i32, i32* %12
%62 = add nsw i32 %60, %61
store i32 %62, i32* %4
br label %63
63: ; preds = %59, %58
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
%struct.jelio_buf = type { i32 }
define i32 @i_uid_conv(i8* nocapture %0, i32 %1, i8* %2) {
%4 = bitcast i8* %2 to %struct.jelio_buf*
%5 = bitcast i8* %0 to i32*
store i32 0, i32* %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 %35, 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 [ %30, %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 i32, i32* %5
%27 = mul nsw i32 %26, 10
%28 = add nsw i32 %22, -48
%29 = add nsw i32 %28, %27
store i32 %29, i32* %5
%30 = tail call i32 @jelio_buffer_peekc(%struct.jelio_buf* %4)
%31 = add i32 %30, -58
%32 = icmp ult i32 %31, -10
br i1 %32, label %33, label %21
33: ; preds = %21
%34 = add nuw nsw i32 %24, %10
br label %35
35: ; preds = %9, %33
%36 = phi i32 [ %34, %33 ], [ 0, %9 ]
ret i32 %36
}