#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 EOF;
int /*<<< orphan*/ discard_char();
char get_char();
char get_char_class(char);
char peek_2_char();
char peek_char();
void get_string_literal(char *buffer) {
  int i = 0;
  discard_char();
  char c = peek_char();
  char cclass = get_char_class(c);
  char prev_char;
  while ((c != '\"') && (EOF != peek_char())) {
    if ((peek_char() == '\\') &&
        ((peek_2_char() == '\"') || (peek_2_char() == '\\'))) {
      buffer[i++] = peek_2_char();
      discard_char();
      prev_char = get_char();
      c = peek_char();
      cclass = get_char_class(c);
      continue;
    }
    if (i < 256) {
      buffer[i++] = c;
    }
    prev_char = get_char();
    c = peek_char();
    cclass = get_char_class(c);
  }
  buffer[i] = 0;
  discard_char();
}


x86 assembly (clang, -O0):
<get_string_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1060 <discard_char@plt>
mov    $0x0,%al
call   1050 <peek_char@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%edi
call   1040 <get_char_class@plt>
mov    %al,-0xe(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x22,%ecx
mov    %al,-0x10(%rbp)
je     11b6 <get_string_literal+0x66>
mov    0x2e4f(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <peek_char@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x10(%rbp)
mov    -0x10(%rbp),%al
test   $0x1,%al
jne    11c6 <get_string_literal+0x76>
jmp    1293 <get_string_literal+0x143>
mov    $0x0,%al
call   1050 <peek_char@plt>
movsbl %al,%eax
cmp    $0x5c,%eax
jne    1249 <get_string_literal+0xf9>
mov    $0x0,%al
call   1030 <peek_2_char@plt>
movsbl %al,%eax
cmp    $0x22,%eax
je     11ff <get_string_literal+0xaf>
mov    $0x0,%al
call   1030 <peek_2_char@plt>
movsbl %al,%eax
cmp    $0x5c,%eax
jne    1249 <get_string_literal+0xf9>
mov    $0x0,%al
call   1030 <peek_2_char@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0x0,%al
call   1060 <discard_char@plt>
mov    $0x0,%al
call   1070 <get_char@plt>
mov    %al,-0xf(%rbp)
mov    $0x0,%al
call   1050 <peek_char@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%edi
call   1040 <get_char_class@plt>
mov    %al,-0xe(%rbp)
jmp    1180 <get_string_literal+0x30>
cmpl   $0x100,-0xc(%rbp)
jge    126e <get_string_literal+0x11e>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0x0,%al
call   1070 <get_char@plt>
mov    %al,-0xf(%rbp)
mov    $0x0,%al
call   1050 <peek_char@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%edi
call   1040 <get_char_class@plt>
mov    %al,-0xe(%rbp)
jmp    1180 <get_string_literal+0x30>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1060 <discard_char@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_string_literal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %r15d,%r15d
xor    %eax,%eax
call   1060 <discard_char@plt>
xor    %eax,%eax
call   1050 <peek_char@plt>
mov    %eax,%r13d
movsbl %al,%edi
call   1040 <get_char_class@plt>
cmp    $0x22,%r13b
jne    119d <get_string_literal+0x4d>
movslq %r15d,%rax
movb   $0x0,(%r14,%rax,1)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <discard_char@plt>
mov    0x2e44(%rip),%r12
xor    %r15d,%r15d
jmp    11ea <get_string_literal+0x9a>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <peek_2_char@plt>
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %al,(%r14,%rcx,1)
xor    %eax,%eax
call   1060 <discard_char@plt>
xor    %eax,%eax
call   1070 <get_char@plt>
xor    %eax,%eax
call   1050 <peek_char@plt>
mov    %eax,%r13d
movsbl %al,%ebp
mov    %ebp,%edi
call   1040 <get_char_class@plt>
cmp    $0x22,%bpl
je     1180 <get_string_literal+0x30>
movzbl (%r12),%ebx
xor    %eax,%eax
call   1050 <peek_char@plt>
cmp    %al,%bl
je     1180 <get_string_literal+0x30>
xor    %eax,%eax
call   1050 <peek_char@plt>
cmp    $0x5c,%al
jne    1220 <get_string_literal+0xd0>
xor    %eax,%eax
call   1030 <peek_2_char@plt>
cmp    $0x22,%al
je     11b0 <get_string_literal+0x60>
xor    %eax,%eax
call   1030 <peek_2_char@plt>
cmp    $0x5c,%al
je     11b0 <get_string_literal+0x60>
nopl   0x0(%rax,%rax,1)
cmp    $0xff,%r15d
jg     11c9 <get_string_literal+0x79>
movslq %r15d,%rax
add    $0x1,%r15d
mov    %r13b,(%r14,%rax,1)
jmp    11c9 <get_string_literal+0x79>

LLVM IR (-O0):
@EOF = global i8 0
define void @get_string_literal(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%7 = call i32 (...) @discard_char()
%8 = call signext i8 (...) @peek_char()
store i8 %8, i8* %4
%9 = load i8, i8* %4
%10 = call signext i8 @get_char_class(i8 signext %9)
store i8 %10, i8* %5
br label %11
11: ; preds = %57, %35, %1
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 34
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i8, i8* @EOF
%17 = sext i8 %16 to i32
%18 = call signext i8 (...) @peek_char()
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br label %21
21: ; preds = %15, %11
%22 = phi i1 [ false, %11 ], [ %20, %15 ]
br i1 %22, label %23, label %62
23: ; preds = %21
%24 = call signext i8 (...) @peek_char()
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 92
br i1 %26, label %27, label %47
27: ; preds = %23
%28 = call signext i8 (...) @peek_2_char()
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 34
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = call signext i8 (...) @peek_2_char()
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 92
br i1 %34, label %35, label %47
35: ; preds = %31, %27
%36 = call signext i8 (...) @peek_2_char()
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 %36, i8* %41
%42 = call i32 (...) @discard_char()
%43 = call signext i8 (...) @get_char()
store i8 %43, i8* %6
%44 = call signext i8 (...) @peek_char()
store i8 %44, i8* %4
%45 = load i8, i8* %4
%46 = call signext i8 @get_char_class(i8 signext %45)
store i8 %46, i8* %5
br label %11
47: ; preds = %31, %23
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, 256
br i1 %49, label %50, label %57
50: ; preds = %47
%51 = load i8, i8* %4
%52 = load i8*, i8** %2
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 %51, i8* %56
br label %57
57: ; preds = %50, %47
%58 = call signext i8 (...) @get_char()
store i8 %58, i8* %6
%59 = call signext i8 (...) @peek_char()
store i8 %59, i8* %4
%60 = load i8, i8* %4
%61 = call signext i8 @get_char_class(i8 signext %60)
store i8 %61, i8* %5
br label %11
62: ; preds = %21
%63 = load i8*, i8** %2
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 0, i8* %66
%67 = call i32 (...) @discard_char()
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @get_string_literal(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @discard_char()
%3 = tail call signext i8 (...) @peek_char()
%4 = tail call signext i8 @get_char_class(i8 signext %3)
%5 = icmp eq i8 %3, 34
br i1 %5, label %39, label %6
6: ; preds = %1, %27
%7 = phi i8 [ %30, %27 ], [ %3, %1 ]
%8 = phi i32 [ %28, %27 ], [ 0, %1 ]
%9 = load i8, i8* @EOF
%10 = tail call signext i8 (...) @peek_char()
%11 = icmp eq i8 %9, %10
br i1 %11, label %39, label %12
12: ; preds = %6
%13 = tail call signext i8 (...) @peek_char()
%14 = icmp eq i8 %13, 92
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = tail call signext i8 (...) @peek_2_char()
%17 = icmp eq i8 %16, 34
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = tail call signext i8 (...) @peek_2_char()
%20 = icmp eq i8 %19, 92
br i1 %20, label %21, label %33
21: ; preds = %18, %15
%22 = tail call signext i8 (...) @peek_2_char()
%23 = add nsw i32 %8, 1
%24 = sext i32 %8 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
store i8 %22, i8* %25
%26 = tail call i32 (...) @discard_char()
br label %27
27: ; preds = %33, %35, %21
%28 = phi i32 [ %23, %21 ], [ %36, %35 ], [ %8, %33 ]
%29 = tail call signext i8 (...) @get_char()
%30 = tail call signext i8 (...) @peek_char()
%31 = tail call signext i8 @get_char_class(i8 signext %30)
%32 = icmp eq i8 %30, 34
br i1 %32, label %39, label %6
33: ; preds = %18, %12
%34 = icmp slt i32 %8, 256
br i1 %34, label %35, label %27
35: ; preds = %33
%36 = add nsw i32 %8, 1
%37 = sext i32 %8 to i64
%38 = getelementptr inbounds i8, i8* %0, i64 %37
store i8 %7, i8* %38
br label %27
39: ; preds = %6, %27, %1
%40 = phi i32 [ 0, %1 ], [ %28, %27 ], [ %8, %6 ]
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %0, i64 %41
store i8 0, i8* %42
%43 = tail call i32 (...) @discard_char()
ret void
}