#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 INT_MAX;
int INT_MIN;
int atoi(char const *);
scalar_t__ strcmp(char const *, char *);
int epk_str2int(const char *val) {
  if (!val)
    return INT_MIN;
  if (strcmp(val, "unlimited") == 0 || strcmp(val, "Unlimited") == 0 ||
      strcmp(val, "UNLIMITED") == 0) {
    return INT_MAX;
  } else if (atoi(val) < 0)
    return INT_MIN;
  else
    return atoi(val);
}


x86 assembly (clang, -O0):
<epk_str2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1148 <epk_str2int+0x28>
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <epk_str2int+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1196 <epk_str2int+0x76>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1196 <epk_str2int+0x76>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a7 <epk_str2int+0x87>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <epk_str2int+0xb6>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
cmp    $0x0,%eax
jge    11ca <epk_str2int+0xaa>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <epk_str2int+0xb6>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epk_str2int>:
push   %rbx
test   %rdi,%rdi
je     116e <epk_str2int+0x4e>
mov    %rdi,%rbx
lea    0xed0(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1177 <epk_str2int+0x57>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1177 <epk_str2int+0x57>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1177 <epk_str2int+0x57>
mov    %rbx,%rdi
call   1040 <atoi@plt>
test   %eax,%eax
jns    1180 <epk_str2int+0x60>
mov    0x2e6b(%rip),%rax
jmp    117e <epk_str2int+0x5e>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
@.str = [10 x i8] c"unlimited\00"
@.str.1 = [10 x i8] c"Unlimited\00"
@.str.2 = [10 x i8] c"UNLIMITED\00"
@INT_MAX = global i32 0
define i32 @epk_str2int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = load i32, i32* @INT_MIN
store i32 %7, i32* %2
br label %31
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16, %12, %8
%21 = load i32, i32* @INT_MAX
store i32 %21, i32* %2
br label %31
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i32 @atoi(i8* %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32, i32* @INT_MIN
store i32 %27, i32* %2
br label %31
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %2
br label %31
31: ; preds = %28, %26, %20, %6
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@.str = [10 x i8] c"unlimited\00"
@.str.1 = [10 x i8] c"Unlimited\00"
@.str.2 = [10 x i8] c"UNLIMITED\00"
@INT_MAX = global i32 0
define i32 @epk_str2int(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @INT_MIN
br label %21
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %8, %5
%15 = load i32, i32* @INT_MAX
br label %21
16: ; preds = %11
%17 = tail call i32 @atoi(i8* %0)
%18 = icmp slt i32 %17, 0
%19 = load i32, i32* @INT_MIN
%20 = select i1 %18, i32 %19, i32 %17
br label %21
21: ; preds = %16, %14, %3
%22 = phi i32 [ %15, %14 ], [ %4, %3 ], [ %20, %16 ]
ret i32 %22
}