#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,
                             unsigned int, unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ stderr;
void csvawk_csvtools(const char *restrict buffer, size_t buffer_size,
                     unsigned int buffer_copy, unsigned int repeats,
                     unsigned int columns) {
  fprintf(stderr, "Running csvtools csvawk\n");
  print_run("csvtools csvawk", "print second columnd",
            "LC_ALL='C' bin/csvawk  '{ print $2; }' > /dev/null", buffer,
            buffer_size, buffer_copy, repeats);
  char command[255];
  sprintf(command,
          "LC_ALL='C' bin/csvawk 'BEGIN { s = 0; } { s += $%u; } END { print "
          "s; }' > /dev/null",
          columns / 2);
  print_run("csvtools csvawk", "sum middle column", command, buffer,
            buffer_size, buffer_copy, repeats);
  sprintf(command,
          "LC_ALL='C' bin/csvawk 'BEGIN { s = 0; } { s += $%u; } END { print "
          "s; }' > /dev/null",
          columns);
  print_run("csvtools csvawk", "sum last column", command, buffer, buffer_size,
            buffer_copy, repeats);
}


x86 assembly (clang, -O0):
<csvawk_csvtools>:
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    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xea1(%rip),%rdi
lea    0xeaa(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
shr    $0x1,%edx
lea    0xecf(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xe55(%rip),%rdi
lea    0xefa(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xe13(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csvawk_csvtools>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8d,%r12d
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebx,(%rsp)
lea    0xeab(%rip),%rdi
lea    0xeb4(%rip),%rsi
lea    0xec2(%rip),%rdx
mov    %rbp,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
call   1040 <print_run@plt>
mov    %r12d,%edx
shr    %edx
lea    0xedb(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdi
call   1050 <sprintf@plt>
mov    %ebx,(%rsp)
lea    0xf18(%rip),%rsi
lea    0xe65(%rip),%rdi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
call   1040 <print_run@plt>
mov    %r13,%rdi
lea    0xea2(%rip),%rsi
mov    %r12d,%edx
call   1050 <sprintf@plt>
mov    %ebx,(%rsp)
lea    0xef6(%rip),%rsi
lea    0xe31(%rip),%rdi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %r15,%r8
mov    %r14d,%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 = [25 x i8] c"Running csvtools csvawk\0A\00"
@.str.1 = [16 x i8] c"csvtools csvawk\00"
@.str.2 = [21 x i8] c"print second columnd\00"
@.str.3 = [51 x i8] c"LC_ALL='C' bin/csvawk '{ print $2; }' > /dev/null\00"
@.str.4 = [84 x i8] c"LC_ALL='C' bin/csvawk 'BEGIN { s = 0; } { s += $%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_csvtools(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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = load i32, i32* %8
%17 = load i32, i32* %9
%18 = call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %14, i64 %15, i32 %16, i32 %17)
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%20 = load i32, i32* %10
%21 = udiv i32 %20, 2
%22 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([84 x i8], [84 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* %8
%27 = load i32, i32* %9
%28 = call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 %26, i32 %27)
%29 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%30 = load i32, i32* %10
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([84 x i8], [84 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* %8
%36 = load i32, i32* %9
%37 = call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 %35, i32 %36)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Running csvtools csvawk\0A\00"
@.str.1 = [16 x i8] c"csvtools csvawk\00"
@.str.2 = [21 x i8] c"print second columnd\00"
@.str.3 = [51 x i8] c"LC_ALL='C' bin/csvawk '{ print $2; }' > /dev/null\00"
@.str.4 = [84 x i8] c"LC_ALL='C' bin/csvawk 'BEGIN { s = 0; } { s += $%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_csvtools(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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %0, i64 %1, i32 %2, i32 %3)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%11 = lshr i32 %4, 1
%12 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 %2, i32 %3)
%14 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @.str.4, i64 0, i64 0), i32 %4)
%15 = call i32 @print_run(i8* getelementptr inbounds ([16 x i8], [16 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 %2, i32 %3)
ret void
}