#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*/ fputc(char, int /*<<< orphan*/ *);
void writeCSVRow(FILE *file, char **entries, int n) {
  fputc('\n', file);
  int i;
  for (i = 0; i < n; i++) {
    char *entry = entries[i];
    char c;
    while (c = *(entry++)) {
      if (c == ',') {
        fputc('\\', file);
      }
      fputc(c, file);
    }
    if (i < n - 1) {
      fputc(',', file);
    }
  }
}


x86 assembly (clang, -O0):
<writeCSVRow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d1 <writeCSVRow+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
cmp    $0x0,%al
je     119f <writeCSVRow+0x8f>
movsbl -0x21(%rbp),%eax
cmp    $0x2c,%eax
jne    118b <writeCSVRow+0x7b>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <fputc@plt>
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1154 <writeCSVRow+0x44>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11be <writeCSVRow+0xae>
mov    -0x8(%rbp),%rsi
mov    $0x2c,%edi
call   1030 <fputc@plt>
jmp    11c3 <writeCSVRow+0xb3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <writeCSVRow+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeCSVRow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,(%rsp)
mov    %rdi,%rbx
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %r15d,%r15d
jle    11b1 <writeCSVRow+0xa1>
lea    -0x1(%r15),%r12d
mov    %r15d,%r15d
xor    %r13d,%r13d
jmp    1159 <writeCSVRow+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
cmp    %r15,%r13
je     11b1 <writeCSVRow+0xa1>
mov    (%rsp),%rax
mov    (%rax,%r13,8),%rbp
jmp    118d <writeCSVRow+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x5c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbp
movsbl %r14b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movzbl 0x0(%rbp),%r14d
cmp    $0x2c,%r14b
je     1170 <writeCSVRow+0x60>
test   %r14b,%r14b
jne    117d <writeCSVRow+0x6d>
cmp    %r12,%r13
jae    1150 <writeCSVRow+0x40>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1150 <writeCSVRow+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @writeCSVRow(i32* %0, i8** %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8
store i32* %0, i32** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%10 = load i32*, i32** %4
%11 = call i32 @fputc(i8 signext 10, i32* %10)
store i32 0, i32* %7
br label %12
12: ; preds = %47, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %50
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
store i8* %21, i8** %8
br label %22
22: ; preds = %34, %16
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %8
%25 = load i8, i8* %23
store i8 %25, i8* %9
%26 = icmp ne i8 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %22
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 44
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32*, i32** %4
%33 = call i32 @fputc(i8 signext 92, i32* %32)
br label %34
34: ; preds = %31, %27
%35 = load i8, i8* %9
%36 = load i32*, i32** %4
%37 = call i32 @fputc(i8 signext %35, i32* %36)
br label %22
38: ; preds = %22
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i32*, i32** %4
%45 = call i32 @fputc(i8 signext 44, i32* %44)
br label %46
46: ; preds = %43, %38
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %12
50: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @writeCSVRow(i32* nocapture %0, i8** nocapture %1, i32 %2) {
%4 = tail call i32 @fputc(i8 signext 10, i32* %0)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %29
6: ; preds = %3
%7 = add nsw i32 %2, -1
%8 = zext i32 %7 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %26
%11 = phi i64 [ 0, %6 ], [ %27, %26 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
br label %14
14: ; preds = %20, %10
%15 = phi i8* [ %13, %10 ], [ %16, %20 ]
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %15
switch i8 %17, label %20 [
i8 0, label %22
i8 44, label %18
]
18: ; preds = %14
%19 = tail call i32 @fputc(i8 signext 92, i32* %0)
br label %20
20: ; preds = %14, %18
%21 = tail call i32 @fputc(i8 signext %17, i32* %0)
br label %14
22: ; preds = %14
%23 = icmp ult i64 %11, %8
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = tail call i32 @fputc(i8 signext 44, i32* %0)
br label %26
26: ; preds = %24, %22
%27 = add nuw nsw i64 %11, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %10
29: ; preds = %26, %3
ret void
}