#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 EOF;
int /*<<< orphan*/ error(char *);
int getchar();
void do_charconst(void) {
  int c;
  for (;;) {
    switch (c = getchar()) {
    case '\'':
      return;
    case '\\':
      c = getchar();
      if (c == EOF) {
        error("syntax error: unexpected EOF");
      }
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<do_charconst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
sub    $0x27,%eax
je     1156 <do_charconst+0x36>
jmp    1145 <do_charconst+0x25>
mov    -0x8(%rbp),%eax
sub    $0x5c,%eax
je     115c <do_charconst+0x3c>
jmp    1189 <do_charconst+0x69>
add    $0x10,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    1184 <do_charconst+0x64>
lea    0xe81(%rip),%rdi
call   1040 <error@plt>
jmp    118e <do_charconst+0x6e>
jmp    118e <do_charconst+0x6e>
jmp    1128 <do_charconst+0x8>

x86 assembly (clang, -O2):
<do_charconst>:
push   %r14
push   %rbx
push   %rax
mov    0x2ebd(%rip),%rbx
lea    0xece(%rip),%r14
jmp    1145 <do_charconst+0x25>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x27,%eax
je     1166 <do_charconst+0x46>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x5c,%eax
jne    1140 <do_charconst+0x20>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%rbx),%eax
jne    1145 <do_charconst+0x25>
mov    %r14,%rdi
call   1040 <error@plt>
jmp    1145 <do_charconst+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [29 x i8] c"syntax error: unexpected EOF\00"
define void @do_charconst() {
%1 = alloca i32
br label %2
2: ; preds = %14, %0
%3 = call i32 (...) @getchar()
store i32 %3, i32* %1
switch i32 %3, label %13 [
i32 39, label %4
i32 92, label %5
]
4: ; preds = %2
ret void
5: ; preds = %2
%6 = call i32 (...) @getchar()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
br label %14
13: ; preds = %2
br label %14
14: ; preds = %13, %12
br label %2
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [29 x i8] c"syntax error: unexpected EOF\00"
define void @do_charconst() {
br label %1
1: ; preds = %3, %0
%2 = tail call i32 (...) @getchar()
switch i32 %2, label %3 [
i32 39, label %4
i32 92, label %5
]
3: ; preds = %1, %5, %9
br label %1
4: ; preds = %1
ret void
5: ; preds = %1
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %3
9: ; preds = %5
%10 = tail call i32 @error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %3
}