#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 *, char *, char *, ...);
scalar_t__ strcmp(char *, char *);
char *trim(char *);
void output_row(char *row, char *field_names, char delimiter) {
  int p;
  char field[4096 + 1];
  char column[4096 + 1];
  char *trim_field;
  for (p = 0; piece(field, delimiter, row, p); p++) {
    if (!piece(column, ',', field_names, p))
      return;
    trim_field = trim(field);
    if (strcmp(trim_field, "null") == 0 || strcmp(trim_field, "is_null") == 0) {
      trim_field = "";
    }
    if (*trim_field) {
      printf(" and %s = \'%s\'", column, trim_field);
    } else {
      printf(" and (%s = \'\' or %s = \'null\' or %s is null)", column, column,
             column);
    }
  }
}


x86 assembly (clang, -O0):
<output_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%ecx
movsbl %al,%esi
call   1060 <piece@plt>
cmp    $0x0,%rax
je     126b <output_row+0x12b>
lea    -0x2030(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%ecx
mov    $0x2c,%esi
call   1060 <piece@plt>
cmp    $0x0,%rax
jne    11a9 <output_row+0x69>
jmp    126b <output_row+0x12b>
lea    -0x1020(%rbp),%rdi
call   1040 <trim@plt>
mov    %rax,-0x2038(%rbp)
mov    -0x2038(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11f6 <output_row+0xb6>
mov    -0x2038(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1204 <output_row+0xc4>
lea    0xe19(%rip),%rax
mov    %rax,-0x2038(%rbp)
mov    -0x2038(%rbp),%rax
cmpb   $0x0,(%rax)
je     1235 <output_row+0xf5>
lea    -0x2030(%rbp),%rsi
mov    -0x2038(%rbp),%rdx
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <output_row+0x118>
lea    -0x2030(%rbp),%rsi
lea    -0x2030(%rbp),%rdx
lea    -0x2030(%rbp),%rcx
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <output_row+0x11d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <output_row+0x1f>
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_row>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2028,%rsp
mov    %edx,%ebp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r15
lea    0x10(%rsp),%rdi
mov    %edx,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1060 <piece@plt>
test   %rax,%rax
je     1237 <output_row+0xf7>
lea    0x1020(%rsp),%rbx
lea    0x10(%rsp),%r12
movsbl %bpl,%ebp
xor    %r13d,%r13d
jmp    11c0 <output_row+0x80>
nopl   0x0(%rax,%rax,1)
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r13d
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r13d,%ecx
call   1060 <piece@plt>
test   %rax,%rax
je     1237 <output_row+0xf7>
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    0x8(%rsp),%rdx
mov    %r13d,%ecx
call   1060 <piece@plt>
test   %rax,%rax
je     1237 <output_row+0xf7>
mov    %r12,%rdi
call   1040 <trim@plt>
mov    %rax,%r14
mov    %rax,%rdi
lea    0xe14(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120d <output_row+0xcd>
mov    %r14,%rdi
lea    0xdfd(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1214 <output_row+0xd4>
lea    0xe02(%rip),%r14
cmpb   $0x0,(%r14)
je     1190 <output_row+0x50>
lea    0xde3(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a7 <output_row+0x67>
add    $0x2028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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