#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 */
char copyuntil(char *, char **, int, char *);
int /*<<< orphan*/ debug(int, char *);
char *eatwhite(char *);
int /*<<< orphan*/ isalpha(char);
int linescan(char **lp, char *tokstring) {
  int retval;
  *lp = eatwhite(*lp);
  switch (**lp) {
  case '\n':
    retval = 0;
    break;
  case ';':
  case '#':
    retval = 4;
    break;
  case '=':
    *lp = eatwhite((++(*lp)));
    copyuntil(tokstring, lp, 256, " #;\t\n");
    retval = 3;
    break;
  case '[':
    (*lp)++;
    if (copyuntil(tokstring, lp, 64, "]\n") == ']') {
      (*lp)++;
      retval = 1;
    } else {
      debug(1, "Section not closed off");
      retval = -1;
    }
    break;
  default:
    if (isalpha(**lp)) {
      copyuntil(tokstring, lp, 64, "= \t\n");
      *lp = eatwhite(*lp);
      if (**lp == '=')
        retval = 2;
      else
        retval = -1;
    } else
      retval = -1;
    break;
  }
  return retval;
}


x86 assembly (clang, -O0):
<linescan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <eatwhite@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0xa,%eax
je     11c5 <linescan+0x85>
jmp    1181 <linescan+0x41>
mov    -0x18(%rbp),%eax
sub    $0x23,%eax
je     11d1 <linescan+0x91>
jmp    1192 <linescan+0x52>
mov    -0x18(%rbp),%eax
sub    $0x3b,%eax
je     11d1 <linescan+0x91>
jmp    11a3 <linescan+0x63>
mov    -0x18(%rbp),%eax
sub    $0x3d,%eax
je     11dd <linescan+0x9d>
jmp    11b4 <linescan+0x74>
mov    -0x18(%rbp),%eax
sub    $0x5b,%eax
je     121f <linescan+0xdf>
jmp    1289 <linescan+0x149>
movl   $0x0,-0x14(%rbp)
jmp    1307 <linescan+0x1c7>
movl   $0x4,-0x14(%rbp)
jmp    1307 <linescan+0x1c7>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    %rdi,(%rax)
call   1050 <eatwhite@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x100,%edx
lea    0xdf2(%rip),%rcx
call   1030 <copyuntil@plt>
movl   $0x3,-0x14(%rbp)
jmp    1307 <linescan+0x1c7>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x40,%edx
lea    0xdc5(%rip),%rcx
call   1030 <copyuntil@plt>
movsbl %al,%eax
cmp    $0x5d,%eax
jne    126c <linescan+0x12c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x14(%rbp)
jmp    1284 <linescan+0x144>
mov    $0x1,%edi
lea    0xd91(%rip),%rsi
call   1040 <debug@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1307 <linescan+0x1c7>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
je     12fb <linescan+0x1bb>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x40,%edx
lea    0xd6b(%rip),%rcx
call   1030 <copyuntil@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <eatwhite@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    12ef <linescan+0x1af>
movl   $0x2,-0x14(%rbp)
jmp    12f6 <linescan+0x1b6>
movl   $0xffffffff,-0x14(%rbp)
jmp    1302 <linescan+0x1c2>
movl   $0xffffffff,-0x14(%rbp)
jmp    1307 <linescan+0x1c7>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linescan>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1050 <eatwhite@plt>
mov    %rax,(%rbx)
movsbl (%rax),%edi
cmp    $0x3a,%edi
jle    117a <linescan+0x3a>
cmp    $0x5b,%edi
je     11c9 <linescan+0x89>
cmp    $0x3d,%edi
je     11f6 <linescan+0xb6>
cmp    $0x3b,%edi
jne    118a <linescan+0x4a>
mov    $0x4,%eax
jmp    123c <linescan+0xfc>
xor    %eax,%eax
cmp    $0xa,%edi
je     123c <linescan+0xfc>
cmp    $0x23,%edi
je     1170 <linescan+0x30>
call   1060 <isalpha@plt>
test   %eax,%eax
je     1237 <linescan+0xf7>
lea    0xe82(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1030 <copyuntil@plt>
mov    (%rbx),%rdi
call   1050 <eatwhite@plt>
mov    %rax,(%rbx)
xor    %ecx,%ecx
cmpb   $0x3d,(%rax)
sete   %cl
lea    (%rcx,%rcx,2),%eax
add    $0xffffffff,%eax
jmp    123c <linescan+0xfc>
add    $0x1,%rax
mov    %rax,(%rbx)
lea    0xe2f(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1030 <copyuntil@plt>
cmp    $0x5d,%al
jne    1226 <linescan+0xe6>
addq   $0x1,(%rbx)
mov    $0x1,%eax
jmp    123c <linescan+0xfc>
add    $0x1,%rax
mov    %rax,(%rbx)
mov    %rax,%rdi
call   1050 <eatwhite@plt>
mov    %rax,(%rbx)
lea    0xdf1(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1030 <copyuntil@plt>
mov    $0x3,%eax
jmp    123c <linescan+0xfc>
lea    0xddc(%rip),%rsi
mov    $0x1,%edi
call   1040 <debug@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c" #;\09\0A\00"
@.str.1 = [3 x i8] c"]\0A\00"
@.str.2 = [23 x i8] c"Section not closed off\00"
@.str.3 = [5 x i8] c"= \09\0A\00"
define i32 @linescan(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
%8 = call i8* @eatwhite(i8* %7)
%9 = load i8**, i8*** %3
store i8* %8, i8** %9
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %41 [
i32 10, label %14
i32 59, label %15
i32 35, label %15
i32 61, label %16
i32 91, label %25
]
14: ; preds = %2
store i32 0, i32* %5
br label %65
15: ; preds = %2, %2
store i32 4, i32* %5
br label %65
16: ; preds = %2
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %17
%20 = call i8* @eatwhite(i8* %19)
%21 = load i8**, i8*** %3
store i8* %20, i8** %21
%22 = load i8*, i8** %4
%23 = load i8**, i8*** %3
%24 = call signext i8 @copyuntil(i8* %22, i8** %23, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 3, i32* %5
br label %65
25: ; preds = %2
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %26
%29 = load i8*, i8** %4
%30 = load i8**, i8*** %3
%31 = call signext i8 @copyuntil(i8* %29, i8** %30, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 93
br i1 %33, label %34, label %38
34: ; preds = %25
%35 = load i8**, i8*** %3
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %35
store i32 1, i32* %5
br label %40
38: ; preds = %25
%39 = call i32 @debug(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %40
40: ; preds = %38, %34
br label %65
41: ; preds = %2
%42 = load i8**, i8*** %3
%43 = load i8*, i8** %42
%44 = load i8, i8* %43
%45 = call i32 @isalpha(i8 signext %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %63
47: ; preds = %41
%48 = load i8*, i8** %4
%49 = load i8**, i8*** %3
%50 = call signext i8 @copyuntil(i8* %48, i8** %49, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%51 = load i8**, i8*** %3
%52 = load i8*, i8** %51
%53 = call i8* @eatwhite(i8* %52)
%54 = load i8**, i8*** %3
store i8* %53, i8** %54
%55 = load i8**, i8*** %3
%56 = load i8*, i8** %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 61
br i1 %59, label %60, label %61
60: ; preds = %47
store i32 2, i32* %5
br label %62
61: ; preds = %47
store i32 -1, i32* %5
br label %62
62: ; preds = %61, %60
br label %64
63: ; preds = %41
store i32 -1, i32* %5
br label %64
64: ; preds = %63, %62
br label %65
65: ; preds = %64, %40, %16, %15, %14
%66 = load i32, i32* %5
ret i32 %66
}

LLVM IR (-O2):
@.str = [6 x i8] c" #;\09\0A\00"
@.str.1 = [3 x i8] c"]\0A\00"
@.str.2 = [23 x i8] c"Section not closed off\00"
@.str.3 = [5 x i8] c"= \09\0A\00"
define i32 @linescan(i8** %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @eatwhite(i8* %3)
store i8* %4, i8** %0
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %21 [
i32 10, label %31
i32 59, label %7
i32 35, label %7
i32 61, label %8
i32 91, label %12
]
7: ; preds = %2, %2
br label %31
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %4, i64 1
store i8* %9, i8** %0
%10 = tail call i8* @eatwhite(i8* %9)
store i8* %10, i8** %0
%11 = tail call signext i8 @copyuntil(i8* %1, i8** %0, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %31
12: ; preds = %2
%13 = getelementptr inbounds i8, i8* %4, i64 1
store i8* %13, i8** %0
%14 = tail call signext i8 @copyuntil(i8* %1, i8** %0, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8 %14, 93
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %0
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %18, i8** %0
br label %31
19: ; preds = %12
%20 = tail call i32 @debug(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %31
21: ; preds = %2
%22 = tail call i32 @isalpha(i8 signext %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = tail call signext i8 @copyuntil(i8* %1, i8** %0, i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%26 = load i8*, i8** %0
%27 = tail call i8* @eatwhite(i8* %26)
store i8* %27, i8** %0
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 61
%30 = select i1 %29, i32 2, i32 -1
br label %31
31: ; preds = %21, %24, %2, %16, %19, %8, %7
%32 = phi i32 [ 1, %16 ], [ -1, %19 ], [ 3, %8 ], [ 4, %7 ], [ 0, %2 ], [ %30, %24 ], [ -1, %21 ]
ret i32 %32
}