#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 */
int /*<<< orphan*/ print2(int, char *, int, char);
char *strchr(char *, char);
int strcspn(char *, char *);
int /*<<< orphan*/ strspn(char *, char *);
int grub2_val(char **cur, char **next, int lnum) {
  if (**cur == '\'' || **cur == '\"') {
    if (!(*next = strchr((*cur) + 1, **cur))) {
      print2((1 << 0) | (1 << 1), "grub.cfg:%d missing terminating '%c'", lnum,
             **cur);
      ;
      return 0;
    }
    (*cur)++;
  } else {
    *next = *cur + strcspn(*cur, "\t =");
  }
  if (**next) {
    **next = '\0';
    (*next)++;
    *next += strspn(*next, "\t =");
  }
  return 1;
}


x86 assembly (clang, -O0):
<grub2_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     1179 <grub2_val+0x39>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11e1 <grub2_val+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11ce <grub2_val+0x8e>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    $0x3,%edi
lea    0xe46(%rip),%rsi
movsbl (%rax),%ecx
call   1060 <print2@plt>
movl   $0x0,-0x4(%rbp)
jmp    1263 <grub2_val+0x123>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    120f <grub2_val+0xcf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe2b(%rip),%rsi
call   1050 <strcspn@plt>
mov    -0x28(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     125c <grub2_val+0x11c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xde0(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grub2_val>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    (%rdi),%rbx
mov    (%rbx),%al
cmp    $0x27,%al
je     115d <grub2_val+0x1d>
cmp    $0x22,%al
jne    1185 <grub2_val+0x45>
add    $0x1,%rbx
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <strchr@plt>
mov    %rax,(%r15)
mov    0x0(%rbp),%rcx
test   %rax,%rax
je     11cd <grub2_val+0x8d>
add    $0x1,%rcx
mov    %rcx,0x0(%rbp)
mov    (%r15),%rax
jmp    119c <grub2_val+0x5c>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcspn@plt>
cltq
add    %rbx,%rax
mov    %rax,(%r15)
mov    $0x1,%ebp
cmpb   $0x0,(%rax)
je     11e6 <grub2_val+0xa6>
movb   $0x0,(%rax)
mov    (%r15),%rbx
lea    0x1(%rbx),%rdi
mov    %rdi,(%r15)
lea    0xe6b(%rip),%rsi
call   1040 <strspn@plt>
cltq
add    %rbx,%rax
add    $0x1,%rax
mov    %rax,(%r15)
jmp    11e6 <grub2_val+0xa6>
movsbl (%rcx),%ecx
lea    0xe29(%rip),%rsi
mov    $0x3,%edi
mov    %r14d,%edx
call   1060 <print2@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"grub.cfg:%d missing terminating '%c'\00"
@.str.1 = [4 x i8] c"\09 =\00"
define i32 @grub2_val(i8** %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 39
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 34
br i1 %18, label %19, label %39
19: ; preds = %13, %3
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8**, i8*** %5
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
%26 = call i8* @strchr(i8* %22, i8 signext %25)
%27 = load i8**, i8*** %6
store i8* %26, i8** %27
%28 = icmp ne i8* %26, null
br i1 %28, label %35, label %29
29: ; preds = %19
%30 = load i32, i32* %7
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = load i8, i8* %32
%34 = call i32 @print2(i32 3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %30, i8 signext %33)
store i32 0, i32* %4
br label %67
35: ; preds = %19
%36 = load i8**, i8*** %5
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %36
br label %48
39: ; preds = %13
%40 = load i8**, i8*** %5
%41 = load i8*, i8** %40
%42 = load i8**, i8*** %5
%43 = load i8*, i8** %42
%44 = call i32 @strcspn(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = load i8**, i8*** %6
store i8* %46, i8** %47
br label %48
48: ; preds = %39, %35
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %49
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %53, label %66
53: ; preds = %48
%54 = load i8**, i8*** %6
%55 = load i8*, i8** %54
store i8 0, i8* %55
%56 = load i8**, i8*** %6
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %56
%59 = load i8**, i8*** %6
%60 = load i8*, i8** %59
%61 = call i32 @strspn(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%62 = load i8**, i8*** %6
%63 = load i8*, i8** %62
%64 = sext i32 %61 to i64
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8* %65, i8** %62
br label %66
66: ; preds = %53, %48
store i32 1, i32* %4
br label %67
67: ; preds = %66, %29
%68 = load i32, i32* %4
ret i32 %68
}

LLVM IR (-O2):
@.str = [37 x i8] c"grub.cfg:%d missing terminating '%c'\00"
@.str.1 = [4 x i8] c"\09 =\00"
define i32 @grub2_val(i8** nocapture %0, i8** nocapture %1, i32 %2) {
%4 = load i8*, i8** %0
%5 = load i8, i8* %4
switch i8 %5, label %17 [
i8 39, label %6
i8 34, label %6
]
6: ; preds = %3, %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i8* @strchr(i8* %7, i8 signext %5)
store i8* %8, i8** %1
%9 = icmp eq i8* %8, null
%10 = load i8*, i8** %0
br i1 %9, label %11, label %14
11: ; preds = %6
%12 = load i8, i8* %10
%13 = tail call i32 @print2(i32 3, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %2, i8 signext %12)
br label %31
14: ; preds = %6
%15 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %15, i8** %0
%16 = load i8*, i8** %1
br label %21
17: ; preds = %3
%18 = tail call i32 @strcspn(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %4, i64 %19
store i8* %20, i8** %1
br label %21
21: ; preds = %17, %14
%22 = phi i8* [ %20, %17 ], [ %16, %14 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %21
store i8 0, i8* %22
%26 = load i8*, i8** %1
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %1
%28 = tail call i32 @strspn(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8* %30, i8** %1
br label %31
31: ; preds = %21, %25, %11
%32 = phi i32 [ 0, %11 ], [ 1, %25 ], [ 1, %21 ]
ret i32 %32
}