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

/* Variables and functions */
int /*<<< orphan*/ LefError(char *, char *);
char *LefNextToken(int /*<<< orphan*/ *, int);
scalar_t__ LefParseEndStatement(int /*<<< orphan*/ *, char *);
int Lookup(char *, char **);
int /*<<< orphan*/ strcmp(char *, char *);
void LefSkipSection(FILE *f, char *section) {
  char *token;
  int keyword;
  static char *end_section[] = {"END", "ENDEXT", NULL};
  while ((token = LefNextToken(f, 1)) != NULL) {
    if ((keyword = Lookup(token, end_section)) == 0) {
      if (LefParseEndStatement(f, section))
        return;
    } else if (keyword == 1) {
      if (!strcmp(section, "BEGINEXT"))
        return;
    }
  }
  LefError("Section %s has no END record!\n", section);
  return;
}


x86 assembly (clang, -O0):
<LefSkipSection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1070 <LefNextToken@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f0 <LefSkipSection+0xa0>
mov    -0x18(%rbp),%rdi
lea    0x2ec9(%rip),%rsi
call   1040 <Lookup@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    11b9 <LefSkipSection+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <LefParseEndStatement@plt>
cmp    $0x0,%rax
je     11b4 <LefSkipSection+0x64>
jmp    1200 <LefSkipSection+0xb0>
jmp    11eb <LefSkipSection+0x9b>
cmpl   $0x1,-0x1c(%rbp)
jne    11e6 <LefSkipSection+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e1 <LefSkipSection+0x91>
jmp    1200 <LefSkipSection+0xb0>
jmp    11e6 <LefSkipSection+0x96>
jmp    11eb <LefSkipSection+0x9b>
jmp    1160 <LefSkipSection+0x10>
mov    -0x10(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1030 <LefError@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LefSkipSection>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%esi
call   1070 <LefNextToken@plt>
test   %rax,%rax
je     11d1 <LefSkipSection+0x81>
lea    0x2edc(%rip),%r15
lea    0xe90(%rip),%r12
jmp    11a1 <LefSkipSection+0x51>
nopl   (%rax)
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11c5 <LefSkipSection+0x75>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <LefNextToken@plt>
test   %rax,%rax
je     11d1 <LefSkipSection+0x81>
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <Lookup@plt>
cmp    $0x1,%eax
je     1180 <LefSkipSection+0x30>
test   %eax,%eax
jne    118f <LefSkipSection+0x3f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <LefParseEndStatement@plt>
test   %rax,%rax
je     118f <LefSkipSection+0x3f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe3c(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <LefError@plt>

LLVM IR (-O0):
@LefSkipSection.end_section = internal global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"END\00"
@.str.1 = [7 x i8] c"ENDEXT\00"
@.str.2 = [9 x i8] c"BEGINEXT\00"
@.str.3 = [31 x i8] c"Section %s has no END record!\0A\00"
define void @LefSkipSection(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %32, %2
%8 = load i32*, i32** %3
%9 = call i8* @LefNextToken(i32* %8, i32 1)
store i8* %9, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %33
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = call i32 @Lookup(i8* %12, i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @LefSkipSection.end_section, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = load i8*, i8** %4
%18 = call i64 @LefParseEndStatement(i32* %16, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %36
21: ; preds = %15
br label %32
22: ; preds = %11
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25
br label %36
30: ; preds = %25
br label %31
31: ; preds = %30, %22
br label %32
32: ; preds = %31, %21
br label %7
33: ; preds = %7
%34 = load i8*, i8** %4
%35 = call i32 @LefError(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33, %29, %20
ret void
}

LLVM IR (-O2):
@LefSkipSection.end_section = internal global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str = [4 x i8] c"END\00"
@.str.1 = [7 x i8] c"ENDEXT\00"
@.str.2 = [9 x i8] c"BEGINEXT\00"
@.str.3 = [31 x i8] c"Section %s has no END record!\0A\00"
define void @LefSkipSection(i32* %0, i8* %1) {
%3 = tail call i8* @LefNextToken(i32* %0, i32 1)
%4 = icmp eq i8* %3, null
br i1 %4, label %17, label %5
5: ; preds = %2, %14
%6 = phi i8* [ %15, %14 ], [ %3, %2 ]
%7 = tail call i32 @Lookup(i8* %6, i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @LefSkipSection.end_section, i64 0, i64 0))
switch i32 %7, label %14 [
i32 0, label %8
i32 1, label %11
]
8: ; preds = %5
%9 = tail call i64 @LefParseEndStatement(i32* %0, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %19
11: ; preds = %5
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %5, %11, %8
%15 = tail call i8* @LefNextToken(i32* %0, i32 1)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %5
17: ; preds = %14, %2
%18 = tail call i32 @LefError(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %19
19: ; preds = %11, %8, %17
ret void
}