#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 getchar();
int /*<<< orphan*/ putchar(char);
void print_quoted(char quote_char) {
  char c;
  putchar(quote_char);
  while ((c = getchar()) != quote_char) {
    putchar(c);
    if (c == '\\') {
      putchar(getchar());
    }
  }
  putchar(c);
}


x86 assembly (clang, -O0):
<print_quoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x2(%rbp)
movsbl %al,%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
je     117a <print_quoted+0x5a>
movsbl -0x2(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x2(%rbp),%eax
cmp    $0x5c,%eax
jne    1175 <print_quoted+0x55>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1137 <print_quoted+0x17>
movsbl -0x2(%rbp),%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_quoted>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    %bl,%al
je     115c <print_quoted+0x3c>
movsbl %al,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0x5c,%bpl
jne    1135 <print_quoted+0x15>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl %al,%edi
jmp    1130 <print_quoted+0x10>
movsbl %bl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @print_quoted(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = call i32 @putchar(i8 signext %4)
br label %6
6: ; preds = %21, %1
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %3
%8 = sext i8 %7 to i32
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %22
12: ; preds = %6
%13 = load i8, i8* %3
%14 = call i32 @putchar(i8 signext %13)
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 92
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call signext i8 (...) @getchar()
%20 = call i32 @putchar(i8 signext %19)
br label %21
21: ; preds = %18, %12
br label %6
22: ; preds = %6
%23 = load i8, i8* %3
%24 = call i32 @putchar(i8 signext %23)
ret void
}

LLVM IR (-O2):
define void @print_quoted(i8 signext %0) {
%2 = tail call i32 @putchar(i8 signext %0)
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, %0
br i1 %4, label %15, label %5
5: ; preds = %1, %12
%6 = phi i8 [ %13, %12 ], [ %3, %1 ]
%7 = tail call i32 @putchar(i8 signext %6)
%8 = icmp eq i8 %6, 92
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call signext i8 (...) @getchar()
%11 = tail call i32 @putchar(i8 signext %10)
br label %12
12: ; preds = %9, %5
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, %0
br i1 %14, label %15, label %5
15: ; preds = %12, %1
%16 = tail call i32 @putchar(i8 signext %0)
ret void
}