#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 atoi(char *);
void *importBegin(char *, char *, char *, char *, int, char **, char **);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  int ret;
  char *apikey = NULL;
  char *database = NULL;
  char *table = NULL;
  int colsize = 0;
  char *coltypes = NULL;
  char *colnames = NULL;
  char *endpoint = NULL;
  char **column_types = NULL;
  char **column_names = NULL;
  void *td_import_state = NULL;
  int i;
  char *token;
  if (argc < 7) {
    printf("usage: %s apikey database table colsize coltypes colnames "
           "[endpoint]\n",
           argv[0]);
    return 1;
  }
  apikey = argv[1];
  database = argv[2];
  table = argv[3];
  colsize = atoi(argv[4]);
  coltypes = argv[5];
  colnames = argv[6];
  if (argc >= 8) {
    endpoint = argv[7];
  }
  column_types = (char **)malloc(sizeof(char *) * colsize);
  i = 0;
  token = strtok(coltypes, ",");
  while (token != NULL) {
    column_types[i] = malloc(64);
    strcpy(column_types[i], token);
    i++;
    token = strtok(NULL, ",");
  }
  column_names = (char **)malloc(sizeof(char *) * colsize);
  i = 0;
  token = strtok(colnames, ",");
  while (token != NULL) {
    column_names[i] = malloc(64);
    strcpy(column_names[i], token);
    i++;
    token = strtok(NULL, ",");
  }
  td_import_state = importBegin(apikey, endpoint, database, table, colsize,
                                column_types, column_names);
  if (td_import_state == NULL) {
    printf("Failed to begin import\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    11f3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bc <main+0x25c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x8,-0x8(%rbp)
jl     1255 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x50(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     12de <main+0x17e>
mov    $0x40,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x58(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x58(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x78(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd76(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x78(%rbp)
jmp    1283 <main+0x123>
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xd43(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1367 <main+0x207>
mov    $0x40,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x60(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x78(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xced(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x78(%rbp)
jmp    130c <main+0x1ac>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%rax
mov    %rax,(%rsp)
call   1080 <importBegin@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    13b5 <main+0x255>
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bc <main+0x25c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
cmp    $0x6,%edi
jg     119c <main+0x2c>
mov    (%rbx),%rsi
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ea <main+0x17a>
mov    %edi,%ebp
mov    0x8(%rbx),%r13
mov    0x10(%rbx),%r14
mov    0x18(%rbx),%r15
mov    0x20(%rbx),%rdi
call   1080 <atoi@plt>
mov    0x28(%rbx),%r12
cmp    $0x7,%ebp
mov    %r14,0x30(%rsp)
mov    %r15,0x28(%rsp)
mov    %r13,0x20(%rsp)
jne    11cf <main+0x5f>
xor    %ecx,%ecx
jmp    11d3 <main+0x63>
mov    0x38(%rbx),%rcx
mov    %rcx,0x10(%rsp)
mov    0x30(%rbx),%r14
mov    %rax,0x18(%rsp)
lea    0x0(,%rax,8),%r15d
mov    %r15d,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
lea    0xe4b(%rip),%rsi
mov    %r12,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     124e <main+0xde>
mov    %rax,%rbp
lea    0xe34(%rip),%r12
mov    %r13,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,(%rbx)
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbp
add    $0x8,%rbx
test   %rax,%rax
jne    1220 <main+0xb0>
mov    %r15d,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0xde6(%rip),%rsi
mov    %r14,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     12af <main+0x13f>
mov    %rax,%rbx
lea    0xdcf(%rip),%r14
mov    %r15,%rbp
nopw   0x0(%rax,%rax,1)
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,0x0(%rbp)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
add    $0x8,%rbp
test   %rax,%rax
jne    1280 <main+0x110>
mov    %r15,(%rsp)
mov    0x20(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x30(%rsp),%rdx
mov    0x28(%rsp),%rcx
mov    0x18(%rsp),%r8
mov    %r13,%r9
call   1090 <importBegin@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    12ef <main+0x17f>
lea    0xd63(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [70 x i8] c"usage: %s apikey database table colsize coltypes colnames [endpoint]\0A\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [24 x i8] c"Failed to begin import\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8**
%15 = alloca i8**
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i32 0, i32* %10
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i8** null, i8*** %14
store i8** null, i8*** %15
store i8* null, i8** %16
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 7
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %122
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
store i8* %32, i8** %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
store i8* %35, i8** %9
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %10
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 5
%42 = load i8*, i8** %41
store i8* %42, i8** %11
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 6
%45 = load i8*, i8** %44
store i8* %45, i8** %12
%46 = load i32, i32* %4
%47 = icmp sge i32 %46, 8
br i1 %47, label %48, label %52
48: ; preds = %26
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 7
%51 = load i8*, i8** %50
store i8* %51, i8** %13
br label %52
52: ; preds = %48, %26
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = mul i64 8, %54
%56 = trunc i64 %55 to i32
%57 = call i8* @malloc(i32 %56)
%58 = bitcast i8* %57 to i8**
store i8** %58, i8*** %14
store i32 0, i32* %17
%59 = load i8*, i8** %11
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %60, i8** %18
br label %61
61: ; preds = %64, %52
%62 = load i8*, i8** %18
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %80
64: ; preds = %61
%65 = call i8* @malloc(i32 64)
%66 = load i8**, i8*** %14
%67 = load i32, i32* %17
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
store i8* %65, i8** %69
%70 = load i8**, i8*** %14
%71 = load i32, i32* %17
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = load i8*, i8** %18
%76 = call i32 @strcpy(i8* %74, i8* %75)
%77 = load i32, i32* %17
%78 = add nsw i32 %77, 1
store i32 %78, i32* %17
%79 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %79, i8** %18
br label %61
80: ; preds = %61
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = mul i64 8, %82
%84 = trunc i64 %83 to i32
%85 = call i8* @malloc(i32 %84)
%86 = bitcast i8* %85 to i8**
store i8** %86, i8*** %15
store i32 0, i32* %17
%87 = load i8*, i8** %12
%88 = call i8* @strtok(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %88, i8** %18
br label %89
89: ; preds = %92, %80
%90 = load i8*, i8** %18
%91 = icmp ne i8* %90, null
br i1 %91, label %92, label %108
92: ; preds = %89
%93 = call i8* @malloc(i32 64)
%94 = load i8**, i8*** %15
%95 = load i32, i32* %17
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %94, i64 %96
store i8* %93, i8** %97
%98 = load i8**, i8*** %15
%99 = load i32, i32* %17
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %98, i64 %100
%102 = load i8*, i8** %101
%103 = load i8*, i8** %18
%104 = call i32 @strcpy(i8* %102, i8* %103)
%105 = load i32, i32* %17
%106 = add nsw i32 %105, 1
store i32 %106, i32* %17
%107 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %107, i8** %18
br label %89
108: ; preds = %89
%109 = load i8*, i8** %7
%110 = load i8*, i8** %13
%111 = load i8*, i8** %8
%112 = load i8*, i8** %9
%113 = load i32, i32* %10
%114 = load i8**, i8*** %14
%115 = load i8**, i8*** %15
%116 = call i8* @importBegin(i8* %109, i8* %110, i8* %111, i8* %112, i32 %113, i8** %114, i8** %115)
store i8* %116, i8** %16
%117 = load i8*, i8** %16
%118 = icmp eq i8* %117, null
br i1 %118, label %119, label %121
119: ; preds = %108
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %122
121: ; preds = %108
store i32 0, i32* %3
br label %122
122: ; preds = %121, %119, %21
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
@.str = [70 x i8] c"usage: %s apikey database table colsize coltypes colnames [endpoint]\0A\00"
@.str.1 = [2 x i8] c",\00"
@str = [23 x i8] c"Failed to begin import\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 7
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %60
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 4
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 5
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %1, i64 6
%20 = load i8*, i8** %19
%21 = icmp eq i32 %0, 7
br i1 %21, label %25, label %22
22: ; preds = %7
%23 = getelementptr inbounds i8*, i8** %1, i64 7
%24 = load i8*, i8** %23
br label %25
25: ; preds = %22, %7
%26 = phi i8* [ %24, %22 ], [ null, %7 ]
%27 = shl i32 %16, 3
%28 = tail call i8* @malloc(i32 %27)
%29 = bitcast i8* %28 to i8**
%30 = tail call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %41, label %32
32: ; preds = %25, %32
%33 = phi i64 [ %38, %32 ], [ 0, %25 ]
%34 = phi i8* [ %39, %32 ], [ %30, %25 ]
%35 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%36 = getelementptr inbounds i8*, i8** %29, i64 %33
store i8* %35, i8** %36
%37 = tail call i32 @strcpy(i8* %35, i8* %34)
%38 = add nuw i64 %33, 1
%39 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %32
41: ; preds = %32, %25
%42 = tail call i8* @malloc(i32 %27)
%43 = bitcast i8* %42 to i8**
%44 = tail call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i8* %44, null
br i1 %45, label %55, label %46
46: ; preds = %41, %46
%47 = phi i64 [ %52, %46 ], [ 0, %41 ]
%48 = phi i8* [ %53, %46 ], [ %44, %41 ]
%49 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%50 = getelementptr inbounds i8*, i8** %43, i64 %47
store i8* %49, i8** %50
%51 = tail call i32 @strcpy(i8* %49, i8* %48)
%52 = add nuw i64 %47, 1
%53 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %46
55: ; preds = %46, %41
%56 = tail call i8* @importBegin(i8* %9, i8* %26, i8* %11, i8* %13, i32 %16, i8** %29, i8** %43)
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %60
60: ; preds = %55, %58, %4
%61 = phi i32 [ 1, %4 ], [ 1, %58 ], [ 0, %55 ]
ret i32 %61
}