#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__ isalpha(unsigned char);
int /*<<< orphan*/ luaI_auxsynterrbf(char *, char *);
int luaI_findstring(char *, char **);
int luaI_globaldefined(char *);
int checkcond(char *buff) {
  static char *opts[] = {"nil", "1"};
  int i = luaI_findstring(buff, opts);
  if (i >= 0)
    return i;
  else if (isalpha((unsigned char)buff[0]) || buff[0] == '_')
    return luaI_globaldefined(buff);
  else {
    luaI_auxsynterrbf("invalid $if condition", buff);
    return 0;
  }
}


x86 assembly (clang, -O0):
<checkcond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0x2ef9(%rip),%rsi
call   1030 <luaI_findstring@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1174 <checkcond+0x34>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <checkcond+0x82>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
jne    119a <checkcond+0x5a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    11ab <checkcond+0x6b>
mov    -0x10(%rbp),%rdi
call   1050 <luaI_globaldefined@plt>
mov    %eax,-0x4(%rbp)
jmp    11c2 <checkcond+0x82>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1040 <luaI_auxsynterrbf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkcond>:
push   %rbx
mov    %rdi,%rbx
lea    0x2f05(%rip),%rsi
call   1030 <luaI_findstring@plt>
test   %eax,%eax
js     1156 <checkcond+0x16>
pop    %rbx
ret
movzbl (%rbx),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1168 <checkcond+0x28>
cmpb   $0x5f,(%rbx)
jne    1171 <checkcond+0x31>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <luaI_globaldefined@plt>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <luaI_auxsynterrbf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@checkcond.opts = internal global [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [22 x i8] c"invalid $if condition\00"
define i32 @checkcond(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @luaI_findstring(i8* %5, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @checkcond.opts, i64 0, i64 0))
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32, i32* %4
store i32 %10, i32* %2
br label %29
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = call i64 @isalpha(i8 zeroext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 95
br i1 %22, label %23, label %26
23: ; preds = %17, %11
%24 = load i8*, i8** %3
%25 = call i32 @luaI_globaldefined(i8* %24)
store i32 %25, i32* %2
br label %29
26: ; preds = %17
%27 = load i8*, i8** %3
%28 = call i32 @luaI_auxsynterrbf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 0, i32* %2
br label %29
29: ; preds = %26, %23, %9
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@checkcond.opts = internal global [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)]
@.str = [4 x i8] c"nil\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [22 x i8] c"invalid $if condition\00"
define i32 @checkcond(i8* %0) {
%2 = tail call i32 @luaI_findstring(i8* %0, i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @checkcond.opts, i64 0, i64 0))
%3 = icmp sgt i32 %2, -1
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = tail call i64 @isalpha(i8 zeroext %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 95
br i1 %10, label %11, label %13
11: ; preds = %8, %4
%12 = tail call i32 @luaI_globaldefined(i8* %0)
br label %15
13: ; preds = %8
%14 = tail call i32 @luaI_auxsynterrbf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %1, %13, %11
%16 = phi i32 [ %12, %11 ], [ 0, %13 ], [ %2, %1 ]
ret i32 %16
}