#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 */
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void local_double_quote_comma_delimited(char *string, char delimiter) {
  char buffer[4096];
  int i;
  for (i = 0; piece(buffer, delimiter, string, i); i++) {
    if (i != 0)
      printf(",");
    printf("\"%s\"", buffer);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<local_double_quote_comma_delimited>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x1014(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rdx
mov    -0x1014(%rbp),%ecx
movsbl %al,%esi
call   1040 <piece@plt>
cmp    $0x0,%rax
je     11a9 <local_double_quote_comma_delimited+0x89>
cmpl   $0x0,-0x1014(%rbp)
je     1180 <local_double_quote_comma_delimited+0x60>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1014(%rbp)
jmp    113f <local_double_quote_comma_delimited+0x1f>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_double_quote_comma_delimited>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rsp,%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1050 <piece@plt>
test   %rax,%rax
je     11cf <local_double_quote_comma_delimited+0x9f>
lea    0xea3(%rip),%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl %bl,%r12d
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1050 <piece@plt>
test   %rax,%rax
je     11cf <local_double_quote_comma_delimited+0x9f>
mov    $0x2,%ebx
lea    0xe6e(%rip),%r15
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1050 <piece@plt>
add    $0x1,%ebx
test   %rax,%rax
jne    11a0 <local_double_quote_comma_delimited+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [5 x i8] c"\22%s\22\00"
define void @local_double_quote_comma_delimited(i8* %0, i8 signext %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = call i64 @piece(i8* %4, i8 signext %1, i8* %0, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i64 @piece(i8* %4, i8 signext %1, i8* %0, i32 1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7, %11
%12 = phi i32 [ %15, %11 ], [ 1, %7 ]
%13 = call i32 @putchar(i32 44)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%15 = add nuw nsw i32 %12, 1
%16 = call i64 @piece(i8* %4, i8 signext %1, i8* %0, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %11
18: ; preds = %11, %7, %2
%19 = call i32 @putchar(i32 10)
ret void
}