#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 *format(char *, ...);
char *quote_char(char c) {
  if (c == '\\')
    return format("'\\%c'", c);
  if (c == '\'')
    return format("'\\''");
  return format("'%c'", c);
}


x86 assembly (clang, -O0):
<quote_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x5c,%eax
jne    1146 <quote_char+0x36>
movsbl -0x9(%rbp),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <format@plt>
mov    %rax,-0x8(%rbp)
jmp    1180 <quote_char+0x70>
movsbl -0x9(%rbp),%eax
cmp    $0x27,%eax
jne    116a <quote_char+0x5a>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <format@plt>
mov    %rax,-0x8(%rbp)
jmp    1180 <quote_char+0x70>
movsbl -0x9(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <format@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quote_char>:
cmp    $0x27,%dil
je     112f <quote_char+0x1f>
cmp    $0x5c,%dil
jne    113d <quote_char+0x2d>
lea    0xedd(%rip),%rdi
mov    $0x5c,%esi
xor    %eax,%eax
jmp    1030 <format@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
jmp    1030 <format@plt>
movsbl %dil,%esi
lea    0xec3(%rip),%rdi
xor    %eax,%eax
jmp    1030 <format@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"'\\%c'\00"
@.str.1 = [5 x i8] c"'\\''\00"
@.str.2 = [5 x i8] c"'%c'\00"
define i8* @quote_char(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 92
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = call i8* (i8*, ...) @format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
store i8* %10, i8** %2
br label %21
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 39
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i8* (i8*, ...) @format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %2
br label %21
17: ; preds = %11
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = call i8* (i8*, ...) @format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %19)
store i8* %20, i8** %2
br label %21
21: ; preds = %17, %15, %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"'\\%c'\00"
@.str.1 = [5 x i8] c"'\\''\00"
@.str.2 = [5 x i8] c"'%c'\00"
define i8* @quote_char(i8 signext %0) {
switch i8 %0, label %6 [
i8 92, label %2
i8 39, label %4
]
2: ; preds = %1
%3 = tail call i8* (i8*, ...) @format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 92)
br label %9
4: ; preds = %1
%5 = tail call i8* (i8*, ...) @format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %9
6: ; preds = %1
%7 = sext i8 %0 to i32
%8 = tail call i8* (i8*, ...) @format(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %6, %4, %2
%10 = phi i8* [ %3, %2 ], [ %5, %4 ], [ %8, %6 ]
ret i8* %10
}