#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__ errno;
scalar_t__ strcmp(char *, char *);
int strtol(char *, char **, int /*<<< orphan*/);
int parse_int(int *ret, char *data, int keywords) {
  char *end;
  int temp;
  if (keywords & 1 && strcmp(data, "none") == 0) {
    *ret = -1;
    return 1;
  } else if (keywords & 2 && strcmp(data, "no") == 0) {
    *ret = 0;
    return 1;
  } else if (keywords & 2 && strcmp(data, "yes") == 0) {
    *ret = 1;
    return 1;
  }
  errno = 0;
  temp = strtol(data, &end, 0);
  if (errno || *end)
    return 0;
  *ret = temp;
  return 1;
}


x86 assembly (clang, -O0):
<parse_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1172 <parse_int+0x52>
mov    -0x18(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1172 <parse_int+0x52>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1257 <parse_int+0x137>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11b1 <parse_int+0x91>
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b1 <parse_int+0x91>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1257 <parse_int+0x137>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11f0 <parse_int+0xd0>
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <parse_int+0xd0>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1257 <parse_int+0x137>
jmp    11f5 <parse_int+0xd5>
jmp    11fa <parse_int+0xda>
mov    0x2ddf(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2dbf(%rip),%rax
cmpq   $0x0,(%rax)
jne    123b <parse_int+0x11b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1247 <parse_int+0x127>
movl   $0x0,-0x4(%rbp)
jmp    1257 <parse_int+0x137>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
test   $0x1,%bpl
je     1149 <parse_int+0x29>
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a5 <parse_int+0x85>
test   $0x2,%bpl
je     1177 <parse_int+0x57>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ac <parse_int+0x8c>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b0 <parse_int+0x90>
mov    0x2e62(%rip),%r15
movq   $0x0,(%r15)
mov    %rsp,%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <strtol@plt>
cmpq   $0x0,(%r15)
jne    11bd <parse_int+0x9d>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    11bd <parse_int+0x9d>
jmp    11b5 <parse_int+0x95>
mov    $0xffffffff,%eax
jmp    11b5 <parse_int+0x95>
xor    %eax,%eax
jmp    11b5 <parse_int+0x95>
mov    $0x1,%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"none\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [4 x i8] c"yes\00"
@errno = global i64 0
define i32 @parse_int(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = and i32 %10, 1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32*, i32** %5
store i32 -1, i32* %18
store i32 1, i32* %4
br label %55
19: ; preds = %13, %3
%20 = load i32, i32* %7
%21 = and i32 %20, 2
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32*, i32** %5
store i32 0, i32* %28
store i32 1, i32* %4
br label %55
29: ; preds = %23, %19
%30 = load i32, i32* %7
%31 = and i32 %30, 2
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32*, i32** %5
store i32 1, i32* %38
store i32 1, i32* %4
br label %55
39: ; preds = %33, %29
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
store i64 0, i64* @errno
%42 = load i8*, i8** %6
%43 = call i32 @strtol(i8* %42, i8** %8, i32 0)
store i32 %43, i32* %9
%44 = load i64, i64* @errno
%45 = icmp ne i64 %44, 0
br i1 %45, label %51, label %46
46: ; preds = %41
%47 = load i8*, i8** %8
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %46, %41
store i32 0, i32* %4
br label %55
52: ; preds = %46
%53 = load i32, i32* %9
%54 = load i32*, i32** %5
store i32 %53, i32* %54
store i32 1, i32* %4
br label %55
55: ; preds = %52, %51, %37, %27, %17
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@.str = [5 x i8] c"none\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [4 x i8] c"yes\00"
@errno = global i64 0
define i32 @parse_int(i32* nocapture writeonly %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = and i32 %2, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %8, %3
%12 = and i32 %2, 2
%13 = icmp eq i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %11, %17
store i64 0, i64* @errno
%21 = call i32 @strtol(i8* %1, i8** %4, i32 0)
%22 = load i64, i64* @errno
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24, %17, %14, %8
%29 = phi i32 [ -1, %8 ], [ 0, %14 ], [ 1, %17 ], [ %21, %24 ]
store i32 %29, i32* %0
br label %30
30: ; preds = %28, %20, %24
%31 = phi i32 [ 0, %24 ], [ 0, %20 ], [ 1, %28 ]
ret i32 %31
}