#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__ alldigits(char *);
int atoi(char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int atoiwi(char *str) {
  register int len;
  len = strlen(str);
  if (len != 0) {
    if (strncmp(str, "infinity", len) == 0 || strncmp(str, "all", len) == 0 ||
        strncmp(str, "maximum", len) == 0) {
      return (-1);
    } else if (alldigits(str)) {
      return (atoi(str));
    } else {
      return (-2);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<atoiwi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f5 <atoiwi+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe90(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11b9 <atoiwi+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe7c(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11b9 <atoiwi+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe63(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c5 <atoiwi+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <atoiwi+0xbc>
mov    -0x10(%rbp),%rdi
call   1060 <alldigits@plt>
cmp    $0x0,%rax
je     11e9 <atoiwi+0xa9>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <atoiwi+0xbc>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11fc <atoiwi+0xbc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atoiwi>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     11b3 <atoiwi+0x73>
mov    %eax,%ebp
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     11b6 <atoiwi+0x76>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b6 <atoiwi+0x76>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b6 <atoiwi+0x76>
mov    %rbx,%rdi
call   1060 <alldigits@plt>
test   %rax,%rax
je     11be <atoiwi+0x7e>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <atoi@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xfffffffe,%r14d
jmp    11b6 <atoiwi+0x76>

LLVM IR (-O0):
@.str = [9 x i8] c"infinity\00"
@.str.1 = [4 x i8] c"all\00"
@.str.2 = [8 x i8] c"maximum\00"
define i32 @atoiwi(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19, %14, %9
store i32 -1, i32* %2
br label %34
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = call i64 @alldigits(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %2
br label %34
32: ; preds = %25
store i32 -2, i32* %2
br label %34
33: ; preds = %1
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %29, %24
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [9 x i8] c"infinity\00"
@.str.1 = [4 x i8] c"all\00"
@.str.2 = [8 x i8] c"maximum\00"
define i32 @atoiwi(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = tail call i64 @alldigits(i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @atoi(i8* %0)
br label %18
18: ; preds = %1, %13, %4, %7, %10, %16
%19 = phi i32 [ %17, %16 ], [ -1, %10 ], [ -1, %7 ], [ -1, %4 ], [ -2, %13 ], [ 0, %1 ]
ret i32 %19
}