int main(int argc, char **argv) {
  int rc;
  int childc;
  char **childv;
  char *parent;
  int i;
  if (argc != 4) {
    printf("Usage %s (add,get) parent child (remove) child", argv[0]);
    return -1;
  }
  rc = sql_open();
  if (rc) {
    sql_close();
    return -1;
  }
  rc = sql_init_db();
  printf("ADDING: %s, %s\n", argv[1], argv[2]);
  rc = sql_add(argv[1], argv[2], 100);
  printf("GET Children of Parent %s\n", argv[1]);
  rc = sql_get_children(argv[1], &childc, &childv);
  for (i = 0; i < childc; ++i) {
    printf("Child = %s\n", childv[i]);
    free(childv[i]);
  }
  free(childv);
  printf("GET Parent of Child %s\n", argv[2]);
  rc = sql_get_parent(argv[2], &parent);
  printf("Parent = %s\n", parent);
  free(parent);
  printf("Remove Child %s\n", argv[3]);
  rc = sql_remove_child(argv[3]);
  sql_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11d1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1b1>
mov    $0x0,%al
call   1070 <sql_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f8 <main+0x68>
mov    $0x0,%al
call   10b0 <sql_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1341 <main+0x1b1>
mov    $0x0,%al
call   1090 <sql_init_db@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x64,%edx
mov    $0x0,%al
call   1060 <sql_add@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <sql_get_children@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12bb <main+0x12b>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1276 <main+0xe6>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   10a0 <sql_get_parent@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    $0x0,%al
call   1080 <sql_remove_child@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   10b0 <sql_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
cmp    $0x4,%edi
jne    11bf <main+0x2f>
xor    %eax,%eax
call   1070 <sql_open@plt>
test   %eax,%eax
je     11db <main+0x4b>
xor    %eax,%eax
call   10b0 <sql_close@plt>
mov    $0xffffffff,%r14d
jmp    12ec <main+0x15c>
mov    (%r15),%rsi
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
jmp    12ec <main+0x15c>
xor    %r14d,%r14d
xor    %eax,%eax
call   1090 <sql_init_db@plt>
mov    0x8(%r15),%rsi
mov    0x10(%r15),%rdx
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r15),%rdi
mov    0x10(%r15),%rsi
mov    $0x64,%edx
xor    %eax,%eax
call   1060 <sql_add@plt>
mov    0x8(%r15),%rsi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r15),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sql_get_children@plt>
cmpl   $0x0,0x4(%rsp)
jle    127f <main+0xef>
lea    0xe16(%rip),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1250 <main+0xc0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%r15),%rsi
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%r15),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   10a0 <sql_get_parent@plt>
mov    0x10(%rsp),%rsi
lea    0xdc7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%r15),%rsi
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%r15),%rdi
xor    %eax,%eax
call   1080 <sql_remove_child@plt>
xor    %eax,%eax
call   10b0 <sql_close@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Usage %s (add,get) parent child (remove) child\00"
@.str.1 = [16 x i8] c"ADDING: %s, %s\0A\00"
@.str.2 = [27 x i8] c"GET Children of Parent %s\0A\00"
@.str.3 = [12 x i8] c"Child = %s\0A\00"
@.str.4 = [24 x i8] c"GET Parent of Child %s\0A\00"
@.str.5 = [13 x i8] c"Parent = %s\0A\00"
@.str.6 = [17 x i8] c"Remove Child %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 -1, i32* %3
br label %90
18: ; preds = %2
%19 = call i32 (...) @sql_open()
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (...) @sql_close()
store i32 -1, i32* %3
br label %90
24: ; preds = %18
%25 = call i32 (...) @sql_init_db()
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %31)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @sql_add to i32 (i8*, i8*, i32, ...)*)(i8* %35, i8* %38, i32 100)
store i32 %39, i32* %6
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 (i8*, i32*, i8***, ...) bitcast (i32 (...)* @sql_get_children to i32 (i8*, i32*, i8***, ...)*)(i8* %46, i32* %7, i8*** %8)
store i32 %47, i32* %6
store i32 0, i32* %10
br label %48
48: ; preds = %64, %24
%49 = load i32, i32* %10
%50 = load i32, i32* %7
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %67
52: ; preds = %48
%53 = load i8**, i8*** %8
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %57)
%59 = load i8**, i8*** %8
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
br label %64
64: ; preds = %52
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %48
67: ; preds = %48
%68 = load i8**, i8*** %8
%69 = bitcast i8** %68 to i8*
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 2
%72 = load i8*, i8** %71
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 2
%76 = load i8*, i8** %75
%77 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @sql_get_parent to i32 (i8*, i8**, ...)*)(i8* %76, i8** %9)
store i32 %77, i32* %6
%78 = load i8*, i8** %9
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %78)
%80 = load i8*, i8** %9
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 3
%83 = load i8*, i8** %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %83)
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 3
%87 = load i8*, i8** %86
%88 = call i32 (i8*, ...) bitcast (i32 (...)* @sql_remove_child to i32 (i8*, ...)*)(i8* %87)
store i32 %88, i32* %6
%89 = call i32 (...) @sql_close()
store i32 0, i32* %3
br label %90
90: ; preds = %67, %22, %13
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [47 x i8] c"Usage %s (add,get) parent child (remove) child\00"
@.str.1 = [16 x i8] c"ADDING: %s, %s\0A\00"
@.str.2 = [27 x i8] c"GET Children of Parent %s\0A\00"
@.str.3 = [12 x i8] c"Child = %s\0A\00"
@.str.4 = [24 x i8] c"GET Parent of Child %s\0A\00"
@.str.5 = [13 x i8] c"Parent = %s\0A\00"
@.str.6 = [17 x i8] c"Remove Child %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i8*** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = icmp eq i32 %0, 4
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %63
13: ; preds = %2
%14 = tail call i32 (...) @sql_open()
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 (...) @sql_close()
br label %63
18: ; preds = %13
%19 = tail call i32 (...) @sql_init_db()
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %23)
%25 = load i8*, i8** %20
%26 = load i8*, i8** %22
%27 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @sql_add to i32 (i8*, i8*, i32, ...)*)(i8* %25, i8* %26, i32 100)
%28 = load i8*, i8** %20
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %20
%31 = call i32 (i8*, i32*, i8***, ...) bitcast (i32 (...)* @sql_get_children to i32 (i8*, i32*, i8***, ...)*)(i8* %30, i32* %3, i8*** %4)
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %47
34: ; preds = %18, %34
%35 = phi i64 [ %43, %34 ], [ 0, %18 ]
%36 = load i8**, i8*** %4
%37 = getelementptr inbounds i8*, i8** %36, i64 %35
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 %35
%42 = load i8*, i8** %41
%43 = add nuw nsw i64 %35, 1
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %43, %45
br i1 %46, label %34, label %47
47: ; preds = %34, %18
%48 = bitcast i8*** %4 to i8**
%49 = load i8*, i8** %48
%50 = load i8*, i8** %22
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = load i8*, i8** %22
%53 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @sql_get_parent to i32 (i8*, i8**, ...)*)(i8* %52, i8** %5)
%54 = load i8*, i8** %5
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8*, i8** %1, i64 3
%58 = load i8*, i8** %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %58)
%60 = load i8*, i8** %57
%61 = call i32 (i8*, ...) bitcast (i32 (...)* @sql_remove_child to i32 (i8*, ...)*)(i8* %60)
%62 = call i32 (...) @sql_close()
br label %63
63: ; preds = %47, %16, %10
%64 = phi i32 [ -1, %10 ], [ -1, %16 ], [ 0, %47 ]
ret i32 %64
}