#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*/ appaserver_error_starting_argv_append_file(int, char **,
                                                              char *);
int atoi(char *);
char *environ_exit_application_name(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int insert_mysql(char *, int, char *, char *, char *);
char *pipe2string(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *application_name;
  char *folder_name;
  char *attribute_comma_string;
  char *carrot_delimited_row_filename;
  int rows_to_insert;
  char buffer[1024];
  char *results;
  application_name = environ_exit_application_name(argv[0]);
  appaserver_error_starting_argv_append_file(argc, argv, application_name);
  if (argc != 5) {
    fprintf(stderr,
            "Usage: %s ignored folder attribute_comma_list "
            "carrot_delimited_row_filename\n",
            argv[0]);
    exit(1);
  }
  folder_name = argv[2];
  attribute_comma_string = argv[3];
  carrot_delimited_row_filename = argv[4];
  sprintf(buffer, "wc -l %s | awk '{print $1}'", carrot_delimited_row_filename);
  results = pipe2string(buffer);
  if (!results)
    rows_to_insert = 0;
  else
    rows_to_insert = atoi(results);
  if (!rows_to_insert) {
    printf("0\n");
    exit(0);
  }
  rows_to_insert =
      insert_mysql(application_name, rows_to_insert, folder_name,
                   attribute_comma_string, carrot_delimited_row_filename);
  printf("%d\n", rows_to_insert);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <environ_exit_application_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10b0 <appaserver_error_starting_argv_append_file@plt>
cmpl   $0x5,-0x8(%rbp)
je     11f9 <main+0x69>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe16(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe1e(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x440(%rbp),%rdi
call   1070 <pipe2string@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
jne    1261 <main+0xd1>
movl   $0x0,-0x34(%rbp)
jmp    1270 <main+0xe0>
mov    -0x448(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    128f <main+0xff>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <insert_mysql@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1060 <environ_exit_application_name@plt>
mov    %rax,%r12
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10c0 <appaserver_error_starting_argv_append_file@plt>
cmp    $0x5,%ebp
jne    1257 <main+0xb7>
mov    0x10(%rbx),%r14
mov    0x18(%rbx),%r15
mov    0x20(%rbx),%rbx
lea    0xe65(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <pipe2string@plt>
test   %rax,%rax
je     1244 <main+0xa4>
mov    %rax,%rdi
call   1090 <atoi@plt>
test   %eax,%eax
je     1244 <main+0xa4>
mov    %r12,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   1040 <insert_mysql@plt>
lea    0xe40(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd96(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [77 x i8] c"Usage: %s ignored folder attribute_comma_list carrot_delimited_row_filename\0A\00"
@.str.1 = [28 x i8] c"wc -l %s | awk '{print $1}'\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i8* @environ_exit_application_name(i8* %15)
store i8* %16, i8** %6
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %6
%20 = call i32 @appaserver_error_starting_argv_append_file(i32 %17, i8** %18, i8* %19)
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 5
br i1 %22, label %23, label %30
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
store i8* %33, i8** %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
store i8* %36, i8** %8
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 4
%39 = load i8*, i8** %38
store i8* %39, i8** %9
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%41 = load i8*, i8** %9
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%44 = call i8* @pipe2string(i8* %43)
store i8* %44, i8** %12
%45 = load i8*, i8** %12
%46 = icmp ne i8* %45, null
br i1 %46, label %48, label %47
47: ; preds = %30
store i32 0, i32* %10
br label %51
48: ; preds = %30
%49 = load i8*, i8** %12
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %10
br label %51
51: ; preds = %48, %47
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %51
%58 = load i8*, i8** %6
%59 = load i32, i32* %10
%60 = load i8*, i8** %7
%61 = load i8*, i8** %8
%62 = load i8*, i8** %9
%63 = call i32 @insert_mysql(i8* %58, i32 %59, i8* %60, i8* %61, i8* %62)
store i32 %63, i32* %10
%64 = load i32, i32* %10
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %64)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [77 x i8] c"Usage: %s ignored folder attribute_comma_list carrot_delimited_row_filename\0A\00"
@.str.1 = [28 x i8] c"wc -l %s | awk '{print $1}'\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = tail call i8* @environ_exit_application_name(i8* %5)
%7 = tail call i32 @appaserver_error_starting_argv_append_file(i32 %0, i8** %1, i8* %6)
%8 = icmp eq i32 %0, 5
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %1, i64 4
%20 = load i8*, i8** %19
%21 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i8* @pipe2string(i8* %4)
%23 = icmp eq i8* %22, null
br i1 %23, label %27, label %24
24: ; preds = %14
%25 = call i32 @atoi(i8* %22)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %14, %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %24
%31 = call i32 @insert_mysql(i8* %6, i32 %25, i8* %16, i8* %18, i8* %20)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}