#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_run(char *, char *, char *, char const *, size_t, int,
                             unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ stderr;
void csvawk_awkcsvparser(const char *restrict buffer, size_t buffer_size,
                         unsigned int buffer_copy, unsigned int repeats,
                         unsigned int columns) {
  fprintf(stderr, "Running awk csvparser\n");
  print_run("csvparser awk", "print second columnd",
            "LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v "
            "separator=',' -v enclosure='\"' --source '{ csv_parse_record($0, "
            "separator, enclosure, csv); print csv[1]; }' > /dev/null",
            buffer, buffer_size, 1, repeats);
  char command[255];
  sprintf(command,
          "LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v "
          "separator=',' -v enclosure='\"' --source 'BEGIN {s = 0; }{ "
          "csv_parse_record($0, separator, enclosure, csv); s += csv[%u]; } "
          "END { print s; }' > /dev/null",
          (columns / 2) - 1);
  print_run("csvparser awk", "sum middle column", command, buffer, buffer_size,
            1, repeats);
  sprintf(command,
          "LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v "
          "separator=',' -v enclosure='\"' --source 'BEGIN {s = 0; }{ "
          "csv_parse_record($0, separator, enclosure, csv); s += csv[%u]; } "
          "END { print s; }' > /dev/null",
          columns - 1);
  print_run("csvparser awk", "sum last column", command, buffer, buffer_size, 1,
            repeats);
}


x86 assembly (clang, -O0):
<csvawk_awkcsvparser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%eax
lea    0xea3(%rip),%rdi
lea    0xeaa(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    $0x1,%r9d
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
shr    $0x1,%edx
sub    $0x1,%edx
lea    0xf4e(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%eax
lea    0xe52(%rip),%rdi
lea    0x1004(%rip),%rsi
mov    $0x1,%r9d
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
lea    0xf07(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%eax
lea    0xe0b(%rip),%rdi
lea    0xfcf(%rip),%rsi
mov    $0x1,%r9d
mov    %eax,(%rsp)
call   1040 <print_run@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csvawk_awkcsvparser>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebp,(%rsp)
lea    0xeac(%rip),%rdi
lea    0xeb3(%rip),%rsi
lea    0xec1(%rip),%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    $0x1,%r9d
call   1040 <print_run@plt>
mov    %ebx,%edx
shr    %edx
add    $0xffffffff,%edx
lea    0xf5d(%rip),%r12
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
mov    %ebp,(%rsp)
lea    0x101e(%rip),%rsi
lea    0xe5e(%rip),%rdi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    $0x1,%r9d
call   1040 <print_run@plt>
add    $0xffffffff,%ebx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %ebp,(%rsp)
lea    0xffb(%rip),%rsi
lea    0xe29(%rip),%rdi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    $0x1,%r9d
call   1040 <print_run@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Running awk csvparser\0A\00"
@.str.1 = [14 x i8] c"csvparser awk\00"
@.str.2 = [21 x i8] c"print second columnd\00"
@.str.3 = [187 x i8] c"LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v separator=',' -v enclosure='\22' --source '{ csv_parse_record($0, separator, enclosure, csv); print csv[1]; }' > /dev/null\00"
@.str.4 = [219 x i8] c"LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v separator=',' -v enclosure='\22' --source 'BEGIN {s = 0; }{ csv_parse_record($0, separator, enclosure, csv); s += csv[%u]; } END { print s; }' > /dev/null\00"
@.str.5 = [18 x i8] c"sum middle column\00"
@.str.6 = [16 x i8] c"sum last column\00"
define void @csvawk_awkcsvparser(i8* noalias %0, i64 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [255 x i8]
store i8* %0, i8** %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = load i32, i32* %9
%17 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.3, i64 0, i64 0), i8* %14, i64 %15, i32 1, i32 %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%19 = load i32, i32* %10
%20 = udiv i32 %19, 2
%21 = sub i32 %20, 1
%22 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([219 x i8], [219 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = load i64, i64* %7
%26 = load i32, i32* %9
%27 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %23, i8* %24, i64 %25, i32 1, i32 %26)
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%29 = load i32, i32* %10
%30 = sub i32 %29, 1
%31 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([219 x i8], [219 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %6
%34 = load i64, i64* %7
%35 = load i32, i32* %9
%36 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %32, i8* %33, i64 %34, i32 1, i32 %35)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Running awk csvparser\0A\00"
@.str.1 = [14 x i8] c"csvparser awk\00"
@.str.2 = [21 x i8] c"print second columnd\00"
@.str.3 = [187 x i8] c"LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v separator=',' -v enclosure='\22' --source '{ csv_parse_record($0, separator, enclosure, csv); print csv[1]; }' > /dev/null\00"
@.str.4 = [219 x i8] c"LC_ALL='C' awk -f bench/deps/awk-csv-parser/src/csv-parser.awk -v separator=',' -v enclosure='\22' --source 'BEGIN {s = 0; }{ csv_parse_record($0, separator, enclosure, csv); s += csv[%u]; } END { print s; }' > /dev/null\00"
@.str.5 = [18 x i8] c"sum middle column\00"
@.str.6 = [16 x i8] c"sum last column\00"
define void @csvawk_awkcsvparser(i8* noalias %0, i64 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [255 x i8]
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.3, i64 0, i64 0), i8* %0, i64 %1, i32 1, i32 %3)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%11 = lshr i32 %4, 1
%12 = add nsw i32 %11, -1
%13 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([219 x i8], [219 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 1, i32 %3)
%15 = add i32 %4, -1
%16 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([219 x i8], [219 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 1, i32 %3)
ret void
}