#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 */
int atoi(char *);
int /*<<< orphan*/ isdigit(char);
int ccache_item_set_int(void *p, char *buffer) {
  int *np = (int *)p;
  char *pos;
  for (pos = buffer; pos && *pos; pos++) {
    if (!isdigit(*pos)) {
      return -1;
    }
  }
  *np = atoi(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<ccache_item_set_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x29(%rbp)
je     1160 <ccache_item_set_int+0x40>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1170 <ccache_item_set_int+0x50>
jmp    11a7 <ccache_item_set_int+0x87>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1191 <ccache_item_set_int+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <ccache_item_set_int+0x9f>
jmp    1196 <ccache_item_set_int+0x76>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1140 <ccache_item_set_int+0x20>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccache_item_set_int>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
test   %rsi,%rsi
je     1157 <ccache_item_set_int+0x37>
mov    (%r15),%al
test   %al,%al
je     1157 <ccache_item_set_int+0x37>
lea    0x1(%r15),%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     116a <ccache_item_set_int+0x4a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <ccache_item_set_int+0x20>
mov    %r15,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xffffffff,%eax
jmp    1164 <ccache_item_set_int+0x44>

LLVM IR (-O0):
define i32 @ccache_item_set_int(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
%10 = load i8*, i8** %5
store i8* %10, i8** %7
br label %11
11: ; preds = %28, %2
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %14, %11
%20 = phi i1 [ false, %11 ], [ %18, %14 ]
br i1 %20, label %21, label %31
21: ; preds = %19
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = call i32 @isdigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 -1, i32* %3
br label %35
27: ; preds = %21
br label %28
28: ; preds = %27
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %7
br label %11
31: ; preds = %19
%32 = load i8*, i8** %5
%33 = call i32 @atoi(i8* %32)
%34 = load i32*, i32** %6
store i32 %33, i32* %34
store i32 0, i32* %3
br label %35
35: ; preds = %31, %26
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @ccache_item_set_int(i8* nocapture writeonly %0, i8* %1) {
%3 = bitcast i8* %0 to i32*
%4 = icmp eq i8* %1, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %11
8: ; preds = %11
%9 = load i8, i8* %16
%10 = icmp eq i8 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %5, %8
%12 = phi i8 [ %9, %8 ], [ %6, %5 ]
%13 = phi i8* [ %16, %8 ], [ %1, %5 ]
%14 = tail call i32 @isdigit(i8 signext %12)
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %15, label %19, label %8
17: ; preds = %8, %5, %2
%18 = tail call i32 @atoi(i8* %1)
store i32 %18, i32* %3
br label %19
19: ; preds = %11, %17
%20 = phi i32 [ 0, %17 ], [ -1, %11 ]
ret i32 %20
}