#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 */
typedef int u_char;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ LefError(char *);
char *LefNextToken(int /*<<< orphan*/ *, int);
int LookupFull(char *, char **);
u_char LefParseEndStatement(FILE *f, char *match) {
  char *token;
  int keyword, words;
  char *match_name[2];
  match_name[0] = match;
  match_name[1] = NULL;
  token = LefNextToken(f, (match == NULL) ? 0 : 1);
  if (token == NULL) {
    LefError("Bad file read while looking for END statement\n");
    return 0;
  }
  if ((*token == '\n') && (match == NULL))
    return 1;
  else {
    keyword = LookupFull(token, match_name);
    if (keyword == 0)
      return 1;
    else
      return 0;
  }
}


x86 assembly (clang, -O0):
<LefParseEndStatement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
xor    %eax,%eax
cmp    $0x0,%rcx
cmove  %eax,%esi
call   1040 <LefNextToken@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1192 <LefParseEndStatement+0x62>
lea    0xe7f(%rip),%rdi
call   1030 <LefError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <LefParseEndStatement+0xb6>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11b9 <LefParseEndStatement+0x89>
cmpq   $0x0,-0x18(%rbp)
jne    11b9 <LefParseEndStatement+0x89>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <LefParseEndStatement+0xb6>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <LookupFull@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11df <LefParseEndStatement+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <LefParseEndStatement+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LefParseEndStatement>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rsi,(%rsp)
movq   $0x0,0x8(%rsp)
xor    %esi,%esi
test   %rbx,%rbx
setne  %sil
call   1040 <LefNextToken@plt>
test   %rax,%rax
je     117b <LefParseEndStatement+0x4b>
test   %rbx,%rbx
jne    1167 <LefParseEndStatement+0x37>
mov    $0x1,%ecx
cmpb   $0xa,(%rax)
je     1189 <LefParseEndStatement+0x59>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <LookupFull@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
jmp    1189 <LefParseEndStatement+0x59>
lea    0xe7e(%rip),%rdi
call   1030 <LefError@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Bad file read while looking for END statement\0A\00"
define i32 @LefParseEndStatement(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i8*]
store i32* %0, i32** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
store i8* %10, i8** %11
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 1
store i8* null, i8** %12
%13 = load i32*, i32** %4
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 0, i32 1
%18 = call i8* @LefNextToken(i32* %13, i32 %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @LefError(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %40
23: ; preds = %2
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8*, i8** %5
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 1, i32* %3
br label %40
32: ; preds = %28, %23
%33 = load i8*, i8** %6
%34 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
%35 = call i32 @LookupFull(i8* %33, i8** %34)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %32
store i32 1, i32* %3
br label %40
39: ; preds = %32
store i32 0, i32* %3
br label %40
40: ; preds = %39, %38, %31, %21
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [47 x i8] c"Bad file read while looking for END statement\0A\00"
define i32 @LefParseEndStatement(i32* %0, i8* %1) {
%3 = alloca [2 x i8*]
%4 = bitcast [2 x i8*]* %3 to i8*
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
store i8* %1, i8** %5
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 1
store i8* null, i8** %6
%7 = icmp eq i8* %1, null
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
%10 = tail call i8* @LefNextToken(i32* %0, i32 %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @LefError(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %22
14: ; preds = %2
%15 = load i8, i8* %10
%16 = icmp eq i8 %15, 10
%17 = and i1 %7, %16
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = call i32 @LookupFull(i8* %10, i8** %5)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %18, %14, %12
%23 = phi i32 [ 0, %12 ], [ 1, %14 ], [ %21, %18 ]
ret i32 %23
}