#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*/ repeat(char *, char *, char, unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ stderr;
void csvgrep_gnugrep(const char *restrict buffer, size_t buffer_size,
                     unsigned int buffer_copy, unsigned int repeats,
                     unsigned int columns) {
  fprintf(stderr, "Running gnu grep\n");
  print_run("gnutools grep", "first column",
            "LC_ALL='C' grep \"^[^,a-e]*[a-e][a-e]*\" > /dev/null", buffer,
            buffer_size, buffer_copy, repeats);
  char skip_commands[1024];
  repeat(skip_commands, "[^,]*", ',', columns / 2);
  char command[255];
  sprintf(command, "LC_ALL='C' grep \"^%s,[^,a-e]*[a-e][a-e]*\" > /dev/null",
          skip_commands);
  print_run("gnutools grep", "middle column", command, buffer, buffer_size,
            buffer_copy, repeats);
  print_run("gnutools grep", "last column",
            "LC_ALL='C' grep \"[a-e][a-e]*[^,a-e]*$\" > /dev/null", buffer,
            buffer_size, buffer_copy, repeats);
  char skip_commands2[1024];
  repeat(skip_commands2, "[^,]*", ',', (columns - 1) - (columns / 2));
  sprintf(command,
          "LC_ALL='C' grep "
          "\"^%s,[^,a-e]*[a-e][a-e]*[^,]*,%s,[^,F-L][F-L][F-L]*\" > /dev/null",
          skip_commands, skip_commands2);
  print_run("gnutools grep", "two columns", command, buffer, buffer_size,
            buffer_copy, repeats);
}


x86 assembly (clang, -O0):
<csvgrep_gnugrep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x930,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xe8a(%rip),%rdi
lea    0xe91(%rip),%rsi
lea    0xe97(%rip),%rdx
mov    %eax,(%rsp)
call   1050 <print_run@plt>
lea    -0x420(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
shr    $0x1,%ecx
lea    0xeae(%rip),%rsi
mov    $0x2c,%edx
call   1030 <repeat@plt>
lea    -0x520(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x520(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xe1d(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    %eax,(%rsp)
call   1050 <print_run@plt>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xdf8(%rip),%rdi
lea    0xe89(%rip),%rsi
lea    0xe8e(%rip),%rdx
mov    %eax,(%rsp)
call   1050 <print_run@plt>
lea    -0x920(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x1c(%rbp),%eax
shr    $0x1,%eax
sub    %eax,%ecx
lea    0xe14(%rip),%rsi
mov    $0x2c,%edx
call   1030 <repeat@plt>
lea    -0x520(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    -0x920(%rbp),%rcx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x520(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xd7c(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    %eax,(%rsp)
call   1050 <print_run@plt>
add    $0x930,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csvgrep_gnugrep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x918,%rsp
mov    %r8d,%r13d
mov    %r8d,0xc(%rsp)
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %edx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,(%rsp)
lea    0xe8c(%rip),%rdi
lea    0xe93(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %ebp,%r9d
call   1050 <print_run@plt>
shr    %r13d
lea    0xeb4(%rip),%rsi
lea    0x110(%rsp),%r12
mov    %r12,%rdi
mov    $0x2c,%edx
mov    %r13d,%ecx
call   1030 <repeat@plt>
lea    0xe9b(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %ebx,(%rsp)
lea    0xeb5(%rip),%rsi
lea    0xe24(%rip),%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    0x8(%rsp),%ebp
mov    %ebp,%r9d
call   1050 <print_run@plt>
mov    %ebx,(%rsp)
lea    0xe9d(%rip),%rsi
lea    0xea2(%rip),%rdx
lea    0xdf7(%rip),%rdi
mov    %r14,%rcx
mov    %r15,%r8
mov    %ebp,%r9d
call   1050 <print_run@plt>
not    %r13d
add    0xc(%rsp),%r13d
lea    0x510(%rsp),%r12
mov    %r12,%rdi
lea    0xe1d(%rip),%rsi
mov    $0x2c,%edx
mov    %r13d,%ecx
call   1030 <repeat@plt>
lea    0xe92(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
lea    0x110(%rsp),%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %ebx,(%rsp)
lea    0xebf(%rip),%rsi
lea    0xd90(%rip),%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    0x8(%rsp),%r9d
call   1050 <print_run@plt>
add    $0x918,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Running gnu grep\0A\00"
@.str.1 = [14 x i8] c"gnutools grep\00"
@.str.2 = [13 x i8] c"first column\00"
@.str.3 = [51 x i8] c"LC_ALL='C' grep \22^[^,a-e]*[a-e][a-e]*\22 > /dev/null\00"
@.str.4 = [6 x i8] c"[^,]*\00"
@.str.5 = [54 x i8] c"LC_ALL='C' grep \22^%s,[^,a-e]*[a-e][a-e]*\22 > /dev/null\00"
@.str.6 = [14 x i8] c"middle column\00"
@.str.7 = [12 x i8] c"last column\00"
@.str.8 = [51 x i8] c"LC_ALL='C' grep \22[a-e][a-e]*[^,a-e]*$\22 > /dev/null\00"
@.str.9 = [81 x i8] c"LC_ALL='C' grep \22^%s,[^,a-e]*[a-e][a-e]*[^,]*,%s,[^,F-L][F-L][F-L]*\22 > /dev/null\00"
@.str.10 = [12 x i8] c"two columns\00"
define void @csvgrep_gnugrep(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 [1024 x i8]
%12 = alloca [255 x i8]
%13 = alloca [1024 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
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %6
%17 = load i64, i64* %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 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 ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %16, i64 %17, i32 %18, i32 %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%22 = load i32, i32* %10
%23 = udiv i32 %22, 2
%24 = call i32 @repeat(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 signext 44, i32 %23)
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%29 = load i8*, i8** %6
%30 = load i64, i64* %7
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %28, i8* %29, i64 %30, i32 %31, i32 %32)
%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 ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0), i8* %34, i64 %35, i32 %36, i32 %37)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%40 = load i32, i32* %10
%41 = sub i32 %40, 1
%42 = load i32, i32* %10
%43 = udiv i32 %42, 2
%44 = sub i32 %41, %43
%45 = call i32 @repeat(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 signext 44, i32 %44)
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%49 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.9, i64 0, i64 0), i8* %47, i8* %48)
%50 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%51 = load i8*, i8** %6
%52 = load i64, i64* %7
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %50, i8* %51, i64 %52, i32 %53, i32 %54)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Running gnu grep\0A\00"
@.str.1 = [14 x i8] c"gnutools grep\00"
@.str.2 = [13 x i8] c"first column\00"
@.str.3 = [51 x i8] c"LC_ALL='C' grep \22^[^,a-e]*[a-e][a-e]*\22 > /dev/null\00"
@.str.4 = [6 x i8] c"[^,]*\00"
@.str.5 = [54 x i8] c"LC_ALL='C' grep \22^%s,[^,a-e]*[a-e][a-e]*\22 > /dev/null\00"
@.str.6 = [14 x i8] c"middle column\00"
@.str.7 = [12 x i8] c"last column\00"
@.str.8 = [51 x i8] c"LC_ALL='C' grep \22[a-e][a-e]*[^,a-e]*$\22 > /dev/null\00"
@.str.9 = [81 x i8] c"LC_ALL='C' grep \22^%s,[^,a-e]*[a-e][a-e]*[^,]*,%s,[^,F-L][F-L][F-L]*\22 > /dev/null\00"
@.str.10 = [12 x i8] c"two columns\00"
define void @csvgrep_gnugrep(i8* noalias %0, i64 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [1024 x i8]
%7 = alloca [255 x i8]
%8 = alloca [1024 x i8]
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 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 ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %0, i64 %1, i32 %2, i32 %3)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = lshr i32 %4, 1
%14 = call i32 @repeat(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 signext 44, i32 %13)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%17 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %15, i8* %0, i64 %1, i32 %2, i32 %3)
%18 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0), i8* %0, i64 %1, i32 %2, i32 %3)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = xor i32 %13, -1
%21 = add i32 %20, %4
%22 = call i32 @repeat(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 signext 44, i32 %21)
%23 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.9, i64 0, i64 0), i8* %12, i8* %19)
%24 = call i32 @print_run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %15, i8* %0, i64 %1, i32 %2, i32 %3)
ret void
}