#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*/ EXIT_FAILURE;
int /*<<< orphan*/ escape_sequence();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int inside_single_quote(void) {
  int c, state;
  state = 0;
  while (c = getchar()) {
    if (c == '\'' && state) {
      putchar(c);
      return 0;
    } else if (c != '\'' && state) {
      printf("\nError: missing terminating ' character\n");
      exit(EXIT_FAILURE);
    }
    if (c == '\\') {
      escape_sequence();
      state = 1;
    } else if (c != '\\') {
      putchar(c);
      state = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<inside_single_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     120d <inside_single_quote+0xbd>
cmpl   $0x27,-0x8(%rbp)
jne    119a <inside_single_quote+0x4a>
cmpl   $0x0,-0xc(%rbp)
je     119a <inside_single_quote+0x4a>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    1214 <inside_single_quote+0xc4>
cmpl   $0x27,-0x8(%rbp)
je     11c8 <inside_single_quote+0x78>
cmpl   $0x0,-0xc(%rbp)
je     11c8 <inside_single_quote+0x78>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11cd <inside_single_quote+0x7d>
cmpl   $0x5c,-0x8(%rbp)
jne    11ea <inside_single_quote+0x9a>
mov    $0x0,%al
call   1060 <escape_sequence@plt>
movl   $0x1,-0xc(%rbp)
jmp    1208 <inside_single_quote+0xb8>
cmpl   $0x5c,-0x8(%rbp)
je     1203 <inside_single_quote+0xb3>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0xc(%rbp)
jmp    1208 <inside_single_quote+0xb8>
jmp    115f <inside_single_quote+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inside_single_quote>:
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
test   %eax,%eax
je     11a5 <inside_single_quote+0x55>
xor    %ecx,%ecx
jmp    1174 <inside_single_quote+0x24>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%cl
test   %eax,%eax
je     11a5 <inside_single_quote+0x55>
test   $0x1,%cl
je     117e <inside_single_quote+0x2e>
cmp    $0x27,%eax
je     119b <inside_single_quote+0x4b>
cmp    $0x27,%eax
sete   %dl
not    %cl
or     %dl,%cl
test   $0x1,%cl
je     11a9 <inside_single_quote+0x59>
cmp    $0x5c,%eax
jne    1160 <inside_single_quote+0x10>
xor    %eax,%eax
call   1060 <escape_sequence@plt>
jmp    1167 <inside_single_quote+0x17>
mov    $0x27,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"\0AError: missing terminating ' character\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @inside_single_quote() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %39, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %40
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 39
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @putchar(i32 %14)
store i32 0, i32* %1
br label %41
16: ; preds = %10, %7
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 39
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %19, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 92
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (...) @escape_sequence()
store i32 1, i32* %3
br label %39
32: ; preds = %27
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 92
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %2
%37 = call i32 @putchar(i32 %36)
store i32 1, i32* %3
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38, %30
br label %4
40: ; preds = %4
store i32 0, i32* %1
br label %41
41: ; preds = %40, %13
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [40 x i8] c"\0AError: missing terminating ' character\00"
define i32 @inside_single_quote() {
%1 = tail call i32 (...) @getchar()
%2 = icmp eq i32 %1, 0
br i1 %2, label %26, label %3
3: ; preds = %0, %23
%4 = phi i32 [ %24, %23 ], [ %1, %0 ]
%5 = phi i1 [ true, %23 ], [ false, %0 ]
%6 = icmp eq i32 %4, 39
%7 = and i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @putchar(i32 39)
br label %26
10: ; preds = %3
%11 = icmp ne i32 %4, 39
%12 = and i1 %5, %11
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
%18 = icmp eq i32 %4, 92
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 (...) @escape_sequence()
br label %23
21: ; preds = %17
%22 = tail call i32 @putchar(i32 %4)
br label %23
23: ; preds = %21, %19
%24 = tail call i32 (...) @getchar()
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %3
26: ; preds = %23, %0, %8
ret i32 0
}