#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 csvcut_sed(const char *restrict buffer, size_t buffer_size,
                unsigned int buffer_copy, unsigned int repeats,
                unsigned int columns) {
  fprintf(stderr, "Running gnu sed\n");
  print_run("sed csvcut", "first column",
            "LC_ALL='C' sed 's/^[^,]*,//' > /dev/null", buffer, buffer_size,
            buffer_copy, repeats);
  char command[255];
  sprintf(command, "LC_ALL='C' sed 's/[^,]*,//%u' > /dev/null", columns / 2);
  print_run("sed csvcut", "middle column", command, buffer, buffer_size,
            buffer_copy, repeats);
  sprintf(command, "LC_ALL='C' sed 's/[^,]*,//%u' > /dev/null", columns - 1);
  print_run("sed csvcut", "last column", command, buffer, buffer_size,
            buffer_copy, repeats);
  sprintf(command,
          "LC_ALL='C' sed -e 's/[^,]*,//%u' -e 's/[^,]*,//%u' > /dev/null",
          columns - 2, columns - 3);
  print_run("sed csvcut", "two adjoining column", command, buffer, buffer_size,
            buffer_copy, repeats);
  sprintf(command,
          "LC_ALL='C' sed -e 's/[^,]*,//%u' -e 's/[^,]*,//%u' > /dev/null",
          columns - 1, columns / 2);
  print_run("sed csvcut", "two distinct column", command, buffer, buffer_size,
            buffer_copy, repeats);
}


x86 assembly (clang, -O0):
<csvcut_sed>:
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    0xe99(%rip),%rdi
lea    0xe9d(%rip),%rsi
lea    0xea3(%rip),%rdx
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
shr    $0x1,%edx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
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    0xe4b(%rip),%rdi
lea    0xeaf(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
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    0xe04(%rip),%rdi
lea    0xe76(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x2,%edx
mov    -0x1c(%rbp),%ecx
sub    $0x3,%ecx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
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    0xdb7(%rip),%rdi
lea    0xe74(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
lea    -0x120(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    -0x1c(%rbp),%ecx
shr    $0x1,%ecx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
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    0xd6a(%rip),%rdi
lea    0xe3c(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <print_run@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csvcut_sed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8d,%ebp
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r13
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1030 <fprintf@plt>
mov    %r15d,(%rsp)
lea    0xea1(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    0xeab(%rip),%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
call   1040 <print_run@plt>
mov    %ebp,%r12d
shr    %r12d
lea    0xeb9(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15d,(%rsp)
lea    0xec9(%rip),%rsi
lea    0xe57(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %r14d,0x8(%rsp)
mov    %r14d,%r9d
call   1040 <print_run@plt>
lea    -0x1(%rbp),%edx
mov    %edx,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe6d(%rip),%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15d,(%rsp)
lea    0xe93(%rip),%rsi
lea    0xe13(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
call   1040 <print_run@plt>
lea    -0x2(%rbp),%edx
add    $0xfffffffd,%ebp
lea    0xe78(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15d,(%rsp)
lea    0xe9b(%rip),%rsi
lea    0xdd0(%rip),%rdi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    0x8(%rsp),%ebp
mov    %ebp,%r9d
call   1040 <print_run@plt>
mov    %r14,%rdi
lea    0xe36(%rip),%rsi
mov    0xc(%rsp),%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r15d,(%rsp)
lea    0xe71(%rip),%rsi
lea    0xd91(%rip),%rdi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %ebp,%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 = [17 x i8] c"Running gnu sed\0A\00"
@.str.1 = [11 x i8] c"sed csvcut\00"
@.str.2 = [13 x i8] c"first column\00"
@.str.3 = [41 x i8] c"LC_ALL='C' sed 's/^[^,]*,//' > /dev/null\00"
@.str.4 = [42 x i8] c"LC_ALL='C' sed 's/[^,]*,//%u' > /dev/null\00"
@.str.5 = [14 x i8] c"middle column\00"
@.str.6 = [12 x i8] c"last column\00"
@.str.7 = [63 x i8] c"LC_ALL='C' sed -e 's/[^,]*,//%u' -e 's/[^,]*,//%u' > /dev/null\00"
@.str.8 = [21 x i8] c"two adjoining column\00"
@.str.9 = [20 x i8] c"two distinct column\00"
define void @csvcut_sed(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 ([17 x i8], [17 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 ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 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 (i8*, i8*, i32, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([42 x i8], [42 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 ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 = sub i32 %30, 1
%32 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%34 = load i8*, i8** %6
%35 = load i64, i64* %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %33, i8* %34, i64 %35, i32 %36, i32 %37)
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%40 = load i32, i32* %10
%41 = sub i32 %40, 2
%42 = load i32, i32* %10
%43 = sub i32 %42, 3
%44 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %41, i32 %43)
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%46 = load i8*, i8** %6
%47 = load i64, i64* %7
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %45, i8* %46, i64 %47, i32 %48, i32 %49)
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%52 = load i32, i32* %10
%53 = sub i32 %52, 1
%54 = load i32, i32* %10
%55 = udiv i32 %54, 2
%56 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %53, i32 %55)
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%58 = load i8*, i8** %6
%59 = load i64, i64* %7
%60 = load i32, i32* %8
%61 = load i32, i32* %9
%62 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %57, i8* %58, i64 %59, i32 %60, i32 %61)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Running gnu sed\0A\00"
@.str.1 = [11 x i8] c"sed csvcut\00"
@.str.2 = [13 x i8] c"first column\00"
@.str.3 = [41 x i8] c"LC_ALL='C' sed 's/^[^,]*,//' > /dev/null\00"
@.str.4 = [42 x i8] c"LC_ALL='C' sed 's/[^,]*,//%u' > /dev/null\00"
@.str.5 = [14 x i8] c"middle column\00"
@.str.6 = [12 x i8] c"last column\00"
@.str.7 = [63 x i8] c"LC_ALL='C' sed -e 's/[^,]*,//%u' -e 's/[^,]*,//%u' > /dev/null\00"
@.str.8 = [21 x i8] c"two adjoining column\00"
@.str.9 = [20 x i8] c"two distinct column\00"
define void @csvcut_sed(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 ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 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 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 %2, i32 %3)
%14 = add i32 %4, -1
%15 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 %2, i32 %3)
%17 = add i32 %4, -2
%18 = add i32 %4, -3
%19 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 %2, i32 %3)
%21 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %14, i32 %11)
%22 = call i32 @print_run(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* %10, i8* %0, i64 %1, i32 %2, i32 %3)
ret void
}