#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void escape_cvs_output(FILE *fp, char *s) {
  while (*s) {
    switch (*s) {
    case '"':
      fprintf(fp, "\"\"");
      break;
    default:
      fputc(*s, fp);
      break;
    }
    s++;
  }
}


x86 assembly (clang, -O0):
<escape_cvs_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1188 <escape_cvs_output+0x68>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
sub    $0x22,%al
jne    1165 <escape_cvs_output+0x45>
jmp    1150 <escape_cvs_output+0x30>
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1177 <escape_cvs_output+0x57>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <escape_cvs_output+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape_cvs_output>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xece(%rip),%r15
jmp    1159 <escape_cvs_output+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x22,%al
je     1140 <escape_cvs_output+0x20>
test   %al,%al
je     1175 <escape_cvs_output+0x55>
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
jmp    1159 <escape_cvs_output+0x39>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\22\22\00"
define void @escape_cvs_output(i32* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %10, %2
%4 = phi i8* [ %1, %2 ], [ %11, %10 ]
%5 = load i8, i8* %4
switch i8 %5, label %8 [
i8 0, label %12
i8 34, label %6
]
6: ; preds = %3
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %10
8: ; preds = %3
%9 = tail call i32 @fputc(i8 signext %5, i32* %0)
br label %10
10: ; preds = %8, %6
%11 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
12: ; preds = %3
ret void
}