#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 lexer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lexer_add_to_lexeme(struct lexer *, int /*<<< orphan*/);
int /*<<< orphan*/ lexer_next_char(struct lexer *);
int lexer_next_peek(struct lexer *);
int lexer_read_escaped_until(struct lexer *, char *);
int /*<<< orphan*/ lexer_report_error(struct lexer *, char *);
int lexer_read_literal_quoted(struct lexer *lx) {
  int c = lexer_next_peek(lx);
  if (c != '\'')
    lexer_report_error(lx, "Missing opening quote.\n");
  lexer_add_to_lexeme(lx, lexer_next_char(lx));
  int count = lexer_read_escaped_until(lx, "'");
  lexer_add_to_lexeme(lx, lexer_next_char(lx));
  return count;
}


x86 assembly (clang, -O0):
<lexer_read_literal_quoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <lexer_next_peek@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x27,-0xc(%rbp)
je     1182 <lexer_read_literal_quoted+0x32>
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1070 <lexer_report_error@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <lexer_next_char@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <lexer_add_to_lexeme@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <lexer_read_escaped_until@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <lexer_next_char@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1050 <lexer_add_to_lexeme@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_read_literal_quoted>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <lexer_next_peek@plt>
cmp    $0x27,%eax
je     116f <lexer_read_literal_quoted+0x1f>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1070 <lexer_report_error@plt>
mov    %rbx,%rdi
call   1040 <lexer_next_char@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <lexer_add_to_lexeme@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1060 <lexer_read_escaped_until@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <lexer_next_char@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <lexer_add_to_lexeme@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.lexer = type { i32 }
@.str = [24 x i8] c"Missing opening quote.\0A\00"
@.str.1 = [2 x i8] c"'\00"
define i32 @lexer_read_literal_quoted(%struct.lexer* %0) {
%2 = alloca %struct.lexer*
%3 = alloca i32
%4 = alloca i32
store %struct.lexer* %0, %struct.lexer** %2
%5 = load %struct.lexer*, %struct.lexer** %2
%6 = call i32 @lexer_next_peek(%struct.lexer* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 39
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load %struct.lexer*, %struct.lexer** %2
%11 = call i32 @lexer_report_error(%struct.lexer* %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %1
%13 = load %struct.lexer*, %struct.lexer** %2
%14 = load %struct.lexer*, %struct.lexer** %2
%15 = call i32 @lexer_next_char(%struct.lexer* %14)
%16 = call i32 @lexer_add_to_lexeme(%struct.lexer* %13, i32 %15)
%17 = load %struct.lexer*, %struct.lexer** %2
%18 = call i32 @lexer_read_escaped_until(%struct.lexer* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %4
%19 = load %struct.lexer*, %struct.lexer** %2
%20 = load %struct.lexer*, %struct.lexer** %2
%21 = call i32 @lexer_next_char(%struct.lexer* %20)
%22 = call i32 @lexer_add_to_lexeme(%struct.lexer* %19, i32 %21)
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
%struct.lexer = type { i32 }
@.str = [24 x i8] c"Missing opening quote.\0A\00"
@.str.1 = [2 x i8] c"'\00"
define i32 @lexer_read_literal_quoted(%struct.lexer* %0) {
%2 = tail call i32 @lexer_next_peek(%struct.lexer* %0)
%3 = icmp eq i32 %2, 39
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @lexer_report_error(%struct.lexer* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @lexer_next_char(%struct.lexer* %0)
%8 = tail call i32 @lexer_add_to_lexeme(%struct.lexer* %0, i32 %7)
%9 = tail call i32 @lexer_read_escaped_until(%struct.lexer* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @lexer_next_char(%struct.lexer* %0)
%11 = tail call i32 @lexer_add_to_lexeme(%struct.lexer* %0, i32 %10)
ret i32 %9
}