#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 */
struct parser {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ error(struct parser *, char *);
int get(struct parser *);
int /*<<< orphan*/ unget(struct parser *);
void parse_string(struct parser *p) {
  int c;
  for (c = get(p); c != -1; c = get(p)) {
    if (c == '"') {
      c = get(p);
      if (c != '"') {
        if (c != -1)
          unget(p);
        return;
      }
    }
  }
  error(p, "EOF in middle of string");
}


x86 assembly (clang, -O0):
<parse_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     11a5 <parse_string+0x75>
cmpl   $0x22,-0xc(%rbp)
jne    118f <parse_string+0x5f>
mov    -0x8(%rbp),%rdi
call   1040 <get@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x22,-0xc(%rbp)
je     118a <parse_string+0x5a>
cmpl   $0xffffffff,-0xc(%rbp)
je     1185 <parse_string+0x55>
mov    -0x8(%rbp),%rdi
call   1030 <unget@plt>
jmp    11b5 <parse_string+0x85>
jmp    118f <parse_string+0x5f>
jmp    1194 <parse_string+0x64>
mov    -0x8(%rbp),%rdi
call   1040 <get@plt>
mov    %eax,-0xc(%rbp)
jmp    1148 <parse_string+0x18>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_string>:
push   %rbx
mov    %rdi,%rbx
jmp    1145 <parse_string+0x15>
cs nopw 0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     1166 <parse_string+0x36>
mov    %rbx,%rdi
call   1040 <get@plt>
cmp    $0x22,%eax
jne    1140 <parse_string+0x10>
mov    %rbx,%rdi
call   1040 <get@plt>
cmp    $0x22,%eax
je     1145 <parse_string+0x15>
cmp    $0xffffffff,%eax
jne    1176 <parse_string+0x46>
pop    %rbx
ret
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <error@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <unget@plt>

LLVM IR (-O0):
%struct.parser = type { i32 }
@.str = [24 x i8] c"EOF in middle of string\00"
define void @parse_string(%struct.parser* %0) {
%2 = alloca %struct.parser*
%3 = alloca i32
store %struct.parser* %0, %struct.parser** %2
%4 = load %struct.parser*, %struct.parser** %2
%5 = call i32 @get(%struct.parser* %4)
store i32 %5, i32* %3
br label %6
6: ; preds = %26, %1
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 34
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load %struct.parser*, %struct.parser** %2
%14 = call i32 @get(%struct.parser* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 34
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load %struct.parser*, %struct.parser** %2
%22 = call i32 @unget(%struct.parser* %21)
br label %23
23: ; preds = %20, %17
br label %32
24: ; preds = %12
br label %25
25: ; preds = %24, %9
br label %26
26: ; preds = %25
%27 = load %struct.parser*, %struct.parser** %2
%28 = call i32 @get(%struct.parser* %27)
store i32 %28, i32* %3
br label %6
29: ; preds = %6
%30 = load %struct.parser*, %struct.parser** %2
%31 = call i32 @error(%struct.parser* %30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %29, %23
ret void
}

LLVM IR (-O2):
%struct.parser = type { i32 }
@.str = [24 x i8] c"EOF in middle of string\00"
define void @parse_string(%struct.parser* %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call i32 @get(%struct.parser* %0)
switch i32 %3, label %6 [
i32 -1, label %9
i32 34, label %4
]
4: ; preds = %2
%5 = tail call i32 @get(%struct.parser* %0)
switch i32 %5, label %7 [
i32 34, label %6
i32 -1, label %11
]
6: ; preds = %4, %2
br label %2
7: ; preds = %4
%8 = tail call i32 @unget(%struct.parser* %0)
br label %11
9: ; preds = %2
%10 = tail call i32 @error(%struct.parser* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %4, %7, %9
ret void
}