#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 ch();
int /*<<< orphan*/ code_segment_gtext();
int /*<<< orphan*/ data_segment_gdata();
char gch();
int /*<<< orphan*/ gen_def_byte();
int /*<<< orphan*/ generate_label(int);
int getlabel();
int /*<<< orphan*/ match(char *);
int /*<<< orphan*/ newline();
int /*<<< orphan*/ output_byte(char);
int /*<<< orphan*/ output_number(char);
char spechar();
int quoted_string(int *len, int *position) {
  char c;
  int x;
  int l;
  if (!match("\""))
    return (0);
  if (position) {
    data_segment_gdata();
    *position = getlabel();
    generate_label(*position);
  }
  x = 0;
  while (ch() != '"') {
    if (ch() == 0) {
      break;
    }
    c = gch();
    c = (c == '\\') ? spechar() : c;
    if (x == 0)
      gen_def_byte();
    else
      output_byte(',');
    output_number(c);
    if (x++ == 7) {
      x = 0;
      newline();
    }
    l++;
  }
  gch();
  if (x != 0)
    newline();
  gen_def_byte();
  output_number(0);
  newline();
  if (len)
    *len = l + 1;
  if (position)
    code_segment_gtext();
  return (1);
}


x86 assembly (clang, -O0):
<quoted_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe29(%rip),%rdi
call   10a0 <match@plt>
cmp    $0x0,%eax
jne    11f1 <quoted_string+0x31>
movl   $0x0,-0x4(%rbp)
jmp    133b <quoted_string+0x17b>
cmpq   $0x0,-0x18(%rbp)
je     121d <quoted_string+0x5d>
mov    $0x0,%al
call   1070 <data_segment_gdata@plt>
mov    $0x0,%al
call   1060 <getlabel@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   10e0 <generate_label@plt>
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <ch@plt>
movsbl %al,%eax
cmp    $0x22,%eax
je     12de <quoted_string+0x11e>
mov    $0x0,%al
call   1040 <ch@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    124f <quoted_string+0x8f>
jmp    12de <quoted_string+0x11e>
mov    $0x0,%al
call   10c0 <gch@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x5c,%eax
jne    1278 <quoted_string+0xb8>
mov    $0x0,%al
call   10d0 <spechar@plt>
movsbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    127f <quoted_string+0xbf>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %al,-0x19(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    129b <quoted_string+0xdb>
mov    $0x0,%al
call   10b0 <gen_def_byte@plt>
jmp    12a5 <quoted_string+0xe5>
mov    $0x2c,%edi
call   1050 <output_byte@plt>
movsbl -0x19(%rbp),%edi
call   1080 <output_number@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x7,%eax
jne    12d0 <quoted_string+0x110>
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <newline@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1224 <quoted_string+0x64>
mov    $0x0,%al
call   10c0 <gch@plt>
cmpl   $0x0,-0x20(%rbp)
je     12f6 <quoted_string+0x136>
mov    $0x0,%al
call   1030 <newline@plt>
mov    $0x0,%al
call   10b0 <gen_def_byte@plt>
xor    %edi,%edi
call   1080 <output_number@plt>
mov    $0x0,%al
call   1030 <newline@plt>
cmpq   $0x0,-0x10(%rbp)
je     1322 <quoted_string+0x162>
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1334 <quoted_string+0x174>
mov    $0x0,%al
call   1090 <code_segment_gtext@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quoted_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe2b(%rip),%rdi
call   10a0 <match@plt>
test   %eax,%eax
je     1212 <quoted_string+0x52>
test   %r15,%r15
je     11fb <quoted_string+0x3b>
xor    %eax,%eax
call   1070 <data_segment_gdata@plt>
xor    %eax,%eax
call   1060 <getlabel@plt>
mov    %eax,(%r15)
mov    %eax,%edi
call   10e0 <generate_label@plt>
xor    %eax,%eax
call   1040 <ch@plt>
cmp    $0x22,%al
jne    1219 <quoted_string+0x59>
xor    %eax,%eax
call   10c0 <gch@plt>
jmp    12af <quoted_string+0xef>
xor    %ebp,%ebp
jmp    12dd <quoted_string+0x11d>
xor    %r12d,%r12d
jmp    1242 <quoted_string+0x82>
xchg   %ax,%ax
xor    %eax,%eax
call   10b0 <gen_def_byte@plt>
mov    %ebp,%edi
call   1080 <output_number@plt>
mov    $0x1,%r12d
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <ch@plt>
cmp    $0x22,%al
je     129c <quoted_string+0xdc>
xor    %eax,%eax
call   1040 <ch@plt>
test   %al,%al
je     129c <quoted_string+0xdc>
xor    %eax,%eax
call   10c0 <gch@plt>
cmp    $0x5c,%al
jne    125f <quoted_string+0x9f>
xor    %eax,%eax
call   10d0 <spechar@plt>
movsbl %al,%ebp
test   %r12d,%r12d
je     1220 <quoted_string+0x60>
mov    $0x2c,%edi
call   1050 <output_byte@plt>
mov    %ebp,%edi
call   1080 <output_number@plt>
cmp    $0x7,%r12d
je     1290 <quoted_string+0xd0>
add    $0x1,%r12d
jmp    1234 <quoted_string+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <newline@plt>
jmp    1234 <quoted_string+0x74>
xor    %eax,%eax
call   10c0 <gch@plt>
test   %r12d,%r12d
je     12af <quoted_string+0xef>
xor    %eax,%eax
call   1030 <newline@plt>
xor    %eax,%eax
call   10b0 <gen_def_byte@plt>
xor    %edi,%edi
call   1080 <output_number@plt>
xor    %eax,%eax
call   1030 <newline@plt>
test   %r14,%r14
je     12cc <quoted_string+0x10c>
mov    %ebx,(%r14)
mov    $0x1,%ebp
test   %r15,%r15
je     12dd <quoted_string+0x11d>
xor    %eax,%eax
call   1090 <code_segment_gtext@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
define i32 @quoted_string(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%9 = call i32 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %85
12: ; preds = %2
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = call i32 (...) @data_segment_gdata()
%17 = call i32 (...) @getlabel()
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = call i32 @generate_label(i32 %20)
br label %22
22: ; preds = %15, %12
store i32 0, i32* %7
br label %23
23: ; preds = %60, %22
%24 = call signext i8 (...) @ch()
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 34
br i1 %26, label %27, label %63
27: ; preds = %23
%28 = call signext i8 (...) @ch()
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
br label %63
32: ; preds = %27
%33 = call signext i8 (...) @gch()
store i8 %33, i8* %6
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 92
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call signext i8 (...) @spechar()
%39 = sext i8 %38 to i32
br label %43
40: ; preds = %32
%41 = load i8, i8* %6
%42 = sext i8 %41 to i32
br label %43
43: ; preds = %40, %37
%44 = phi i32 [ %39, %37 ], [ %42, %40 ]
%45 = trunc i32 %44 to i8
store i8 %45, i8* %6
%46 = load i32, i32* %7
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 (...) @gen_def_byte()
br label %52
50: ; preds = %43
%51 = call i32 @output_byte(i8 signext 44)
br label %52
52: ; preds = %50, %48
%53 = load i8, i8* %6
%54 = call i32 @output_number(i8 signext %53)
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
%57 = icmp eq i32 %55, 7
br i1 %57, label %58, label %60
58: ; preds = %52
store i32 0, i32* %7
%59 = call i32 (...) @newline()
br label %60
60: ; preds = %58, %52
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %23
63: ; preds = %31, %23
%64 = call signext i8 (...) @gch()
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %63
%68 = call i32 (...) @newline()
br label %69
69: ; preds = %67, %63
%70 = call i32 (...) @gen_def_byte()
%71 = call i32 @output_number(i8 signext 0)
%72 = call i32 (...) @newline()
%73 = load i32*, i32** %4
%74 = icmp ne i32* %73, null
br i1 %74, label %75, label %79
75: ; preds = %69
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
%78 = load i32*, i32** %4
store i32 %77, i32* %78
br label %79
79: ; preds = %75, %69
%80 = load i32*, i32** %5
%81 = icmp ne i32* %80, null
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 (...) @code_segment_gtext()
br label %84
84: ; preds = %82, %79
store i32 1, i32* %3
br label %85
85: ; preds = %84, %11
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str = [2 x i8] c"\22\00"
define i32 @quoted_string(i32* writeonly %0, i32* writeonly %1) {
%3 = tail call i32 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %61, label %5
5: ; preds = %2
%6 = icmp eq i32* %1, null
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = tail call i32 (...) @data_segment_gdata()
%9 = tail call i32 (...) @getlabel()
store i32 %9, i32* %1
%10 = tail call i32 @generate_label(i32 %9)
br label %11
11: ; preds = %7, %5
%12 = tail call signext i8 (...) @ch()
%13 = icmp eq i8 %12, 34
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call signext i8 (...) @gch()
br label %51
16: ; preds = %11, %39
%17 = phi i32 [ %41, %39 ], [ undef, %11 ]
%18 = phi i32 [ %40, %39 ], [ 0, %11 ]
%19 = tail call signext i8 (...) @ch()
%20 = icmp eq i8 %19, 0
br i1 %20, label %44, label %21
21: ; preds = %16
%22 = tail call signext i8 (...) @gch()
%23 = icmp eq i8 %22, 92
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call signext i8 (...) @spechar()
br label %26
26: ; preds = %21, %24
%27 = phi i8 [ %25, %24 ], [ %22, %21 ]
%28 = icmp eq i32 %18, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 (...) @gen_def_byte()
%31 = tail call i32 @output_number(i8 signext %27)
br label %39
32: ; preds = %26
%33 = tail call i32 @output_byte(i8 signext 44)
%34 = tail call i32 @output_number(i8 signext %27)
%35 = add nsw i32 %18, 1
%36 = icmp eq i32 %18, 7
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = tail call i32 (...) @newline()
br label %39
39: ; preds = %29, %37, %32
%40 = phi i32 [ 0, %37 ], [ %35, %32 ], [ 1, %29 ]
%41 = add i32 %17, 1
%42 = tail call signext i8 (...) @ch()
%43 = icmp eq i8 %42, 34
br i1 %43, label %44, label %16
44: ; preds = %39, %16
%45 = phi i32 [ %40, %39 ], [ %18, %16 ]
%46 = phi i32 [ %41, %39 ], [ %17, %16 ]
%47 = tail call signext i8 (...) @gch()
%48 = icmp eq i32 %45, 0
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = tail call i32 (...) @newline()
br label %51
51: ; preds = %14, %49, %44
%52 = phi i32 [ undef, %14 ], [ %46, %49 ], [ %46, %44 ]
%53 = tail call i32 (...) @gen_def_byte()
%54 = tail call i32 @output_number(i8 signext 0)
%55 = tail call i32 (...) @newline()
%56 = icmp eq i32* %0, null
br i1 %56, label %58, label %57
57: ; preds = %51
store i32 %52, i32* %0
br label %58
58: ; preds = %57, %51
br i1 %6, label %61, label %59
59: ; preds = %58
%60 = tail call i32 (...) @code_segment_gtext()
br label %61
61: ; preds = %58, %59, %2
%62 = phi i32 [ 0, %2 ], [ 1, %59 ], [ 1, %58 ]
ret i32 %62
}