#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 */
int /*<<< orphan*/ fix_any_dollar_signs(char *);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ trim(char *);
void output_row(char *row, char delimiter, int max_piece) {
  int p;
  char field[65535 + 1];
  for (p = 0; piece(field, delimiter, row, p); p++) {
    if (max_piece && p > max_piece)
      break;
    fix_any_dollar_signs(field);
    trim(field);
    if (p)
      printf(",");
    if (!*field || strcmp(field, "is_null") == 0 || strcmp(field, "/") == 0) {
      printf("%s", "null");
    } else {
      printf("\'%s\'", field);
    }
  }
}


x86 assembly (clang, -O0):
<output_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x10020(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
movsbl %al,%esi
call   1070 <piece@plt>
cmp    $0x0,%rax
je     1266 <output_row+0x116>
cmpl   $0x0,-0x10(%rbp)
je     11ad <output_row+0x5d>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11ad <output_row+0x5d>
jmp    1266 <output_row+0x116>
lea    -0x10020(%rbp),%rdi
call   1060 <fix_any_dollar_signs@plt>
lea    -0x10020(%rbp),%rdi
call   1040 <trim@plt>
cmpl   $0x0,-0x14(%rbp)
je     11dd <output_row+0x8d>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpb   $0x0,-0x10020(%rbp)
je     1224 <output_row+0xd4>
lea    -0x10020(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1224 <output_row+0xd4>
lea    -0x10020(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123e <output_row+0xee>
lea    0xde1(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1253 <output_row+0x103>
lea    -0x10020(%rbp),%rsi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_row+0x108>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <output_row+0x1f>
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_row>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10008,%rsp
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r14
mov    %rsp,%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1080 <piece@plt>
test   %rax,%rax
je     1244 <output_row+0xe4>
mov    %rsp,%rbx
lea    0xe6a(%rip),%r12
movsbl %r15b,%r13d
xor    %r15d,%r15d
jmp    11db <output_row+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe53(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1080 <piece@plt>
test   %rax,%rax
je     1244 <output_row+0xe4>
test   %ebp,%ebp
je     11e4 <output_row+0x84>
cmp    %ebp,%r15d
jg     1244 <output_row+0xe4>
mov    %rbx,%rdi
call   1070 <fix_any_dollar_signs@plt>
mov    %rbx,%rdi
call   1050 <trim@plt>
test   %r15d,%r15d
je     1203 <output_row+0xa3>
mov    $0x2c,%edi
call   1030 <putchar@plt>
cmpb   $0x0,(%rsp)
je     11b0 <output_row+0x50>
mov    %rbx,%rdi
lea    0xded(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b0 <output_row+0x50>
mov    %rbx,%rdi
lea    0xde1(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b0 <output_row+0x50>
lea    0xdd1(%rip),%rdi
mov    %rbx,%rsi
jmp    11ba <output_row+0x5a>
add    $0x10008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [8 x i8] c"is_null\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"null\00"
@.str.5 = [5 x i8] c"'%s'\00"
define void @output_row(i8* %0, i8 signext %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca [65536 x i8]
store i8* %0, i8** %4
store i8 %1, i8* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %51, %3
%10 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%11 = load i8, i8* %5
%12 = load i8*, i8** %4
%13 = load i32, i32* %7
%14 = call i64 @piece(i8* %10, i8 signext %11, i8* %12, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %54
16: ; preds = %9
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
br label %54
24: ; preds = %19, %16
%25 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%26 = call i32 @fix_any_dollar_signs(i8* %25)
%27 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%28 = call i32 @trim(i8* %27)
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
%34 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %33
%38 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41, %37, %33
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %50
47: ; preds = %41
%48 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %47, %45
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %9
54: ; preds = %23, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"is_null\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"null\00"
@.str.5 = [5 x i8] c"'%s'\00"
define void @output_row(i8* %0, i8 signext %1, i32 %2) {
%4 = alloca [65536 x i8]
%5 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
%6 = call i64 @piece(i8* %5, i8 signext %1, i8* %0, i32 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %3
%9 = icmp ne i32 %2, 0
br label %10
10: ; preds = %8, %33
%11 = phi i32 [ 0, %8 ], [ %34, %33 ]
%12 = icmp sgt i32 %11, %2
%13 = and i1 %9, %12
br i1 %13, label %37, label %14
14: ; preds = %10
%15 = call i32 @fix_any_dollar_signs(i8* %5)
%16 = call i32 @trim(i8* %5)
%17 = icmp eq i32 %11, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 @putchar(i32 44)
br label %20
20: ; preds = %18, %14
%21 = load i8, i8* %5
%22 = icmp eq i8 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26, %23, %20
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %5)
br label %33
33: ; preds = %29, %31
%34 = add nuw nsw i32 %11, 1
%35 = call i64 @piece(i8* %5, i8 signext %1, i8* %0, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %10
37: ; preds = %33, %10, %3
ret void
}