#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*/ die_at(int /*<<< orphan*/ *, char *);
int read_char_single(char *, char **, unsigned int);
long read_quoted_char(char *start, char **end, int *multichar, int clip_256) {
  unsigned long total = 0;
  unsigned i;
  *multichar = 0;
  if (*start == '\'')
    die_at(NULL, "empty char constant");
  for (i = 0;; i++) {
    int ch;
    if (!*start)
      die_at(NULL, "no terminating quote to character");
    ch = read_char_single(start, &start, i);
    if (clip_256)
      total = (total * 256) + (0xff & ch);
    else
      total += ch;
    if (*start == '\'')
      break;
    *multichar = 1;
  }
  *end = start + 1;
  return total;
}


x86 assembly (clang, -O0):
<read_quoted_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1169 <read_quoted_char+0x49>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9c(%rip),%rsi
call   1030 <die_at@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    118d <read_quoted_char+0x6d>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe8c(%rip),%rsi
call   1030 <die_at@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    -0x8(%rbp),%rsi
call   1040 <read_char_single@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11ca <read_quoted_char+0xaa>
mov    -0x28(%rbp),%rax
shl    $0x8,%rax
mov    -0x30(%rbp),%ecx
and    $0xff,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    11d6 <read_quoted_char+0xb6>
movslq -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    11eb <read_quoted_char+0xcb>
jmp    1203 <read_quoted_char+0xe3>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <read_quoted_char+0x50>
mov    -0x8(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_quoted_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,0x10(%rsp)
mov    %rdi,%r13
mov    %rdi,0x8(%rsp)
movl   $0x0,(%rdx)
cmpb   $0x27,(%rdi)
jne    115a <read_quoted_char+0x3a>
lea    0xead(%rip),%rsi
xor    %edi,%edi
call   1030 <die_at@plt>
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
xor    %ebx,%ebx
cmpb   $0x0,0x0(%r13)
jne    1183 <read_quoted_char+0x63>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
lea    0xe9b(%rip),%rsi
call   1030 <die_at@plt>
mov    0x8(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <read_char_single@plt>
test   %r15d,%r15d
je     11b0 <read_quoted_char+0x90>
shl    $0x8,%rbx
movzbl %al,%eax
or     %rax,%rbx
jmp    11b5 <read_quoted_char+0x95>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cltq
add    %rax,%rbx
mov    0x8(%rsp),%r13
cmpb   $0x27,0x0(%r13)
je     11d5 <read_quoted_char+0xb5>
movl   $0x1,(%r12)
add    $0x1,%ebp
cmpb   $0x0,0x0(%r13)
jne    1183 <read_quoted_char+0x63>
jmp    1170 <read_quoted_char+0x50>
add    $0x1,%r13
mov    0x10(%rsp),%rax
mov    %r13,(%rax)
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"empty char constant\00"
@.str.1 = [34 x i8] c"no terminating quote to character\00"
define i64 @read_quoted_char(i8* %0, i8** %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i64 0, i64* %9
%12 = load i32*, i32** %7
store i32 0, i32* %12
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 39
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = call i32 @die_at(i32* null, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %4
store i32 0, i32* %10
br label %20
20: ; preds = %52, %19
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = call i32 @die_at(i32* null, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i8*, i8** %5
%28 = load i32, i32* %10
%29 = call i32 @read_char_single(i8* %27, i8** %5, i32 %28)
store i32 %29, i32* %11
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %26
%33 = load i64, i64* %9
%34 = mul i64 %33, 256
%35 = load i32, i32* %11
%36 = and i32 255, %35
%37 = sext i32 %36 to i64
%38 = add i64 %34, %37
store i64 %38, i64* %9
br label %44
39: ; preds = %26
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = load i64, i64* %9
%43 = add i64 %42, %41
store i64 %43, i64* %9
br label %44
44: ; preds = %39, %32
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 39
br i1 %48, label %49, label %50
49: ; preds = %44
br label %55
50: ; preds = %44
%51 = load i32*, i32** %7
store i32 1, i32* %51
br label %52
52: ; preds = %50
%53 = load i32, i32* %10
%54 = add i32 %53, 1
store i32 %54, i32* %10
br label %20
55: ; preds = %49
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i64 1
%58 = load i8**, i8*** %6
store i8* %57, i8** %58
%59 = load i64, i64* %9
ret i64 %59
}

LLVM IR (-O2):
@.str = [20 x i8] c"empty char constant\00"
@.str.1 = [34 x i8] c"no terminating quote to character\00"
define i64 @read_quoted_char(i8* %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2, i32 %3) {
%5 = alloca i8*
store i8* %0, i8** %5
store i32 0, i32* %2
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 39
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @die_at(i32* null, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = icmp eq i32 %3, 0
br label %12
12: ; preds = %37, %10
%13 = phi i8* [ %0, %10 ], [ %34, %37 ]
%14 = phi i32 [ 0, %10 ], [ %38, %37 ]
%15 = phi i64 [ 0, %10 ], [ %33, %37 ]
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 @die_at(i32* null, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %5
br label %21
21: ; preds = %18, %12
%22 = phi i8* [ %20, %18 ], [ %13, %12 ]
%23 = call i32 @read_char_single(i8* %22, i8** %5, i32 %14)
br i1 %11, label %29, label %24
24: ; preds = %21
%25 = shl i64 %15, 8
%26 = and i32 %23, 255
%27 = zext i32 %26 to i64
%28 = or i64 %25, %27
br label %32
29: ; preds = %21
%30 = sext i32 %23 to i64
%31 = add i64 %15, %30
br label %32
32: ; preds = %29, %24
%33 = phi i64 [ %28, %24 ], [ %31, %29 ]
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 39
br i1 %36, label %39, label %37
37: ; preds = %32
store i32 1, i32* %2
%38 = add i32 %14, 1
br label %12
39: ; preds = %32
%40 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %40, i8** %1
ret i64 %33
}