#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 */
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
int /*<<< orphan*/ logprintf(int /*<<< orphan*/, char *);
int sqlite_add_msa(int /*<<< orphan*/ *, char *, char *, char *);
int mode_add(sqlite3 *db, int argc, char **argv) {
  if (argc < 2) {
    logprintf(0, "Missing arguments\n");
    return -1;
  }
  return sqlite_add_msa(db, argv[1], (argc > 2) ? argv[2] : NULL,
                        (argc > 3) ? argv[3] : NULL);
}


x86 assembly (clang, -O0):
<mode_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1157 <mode_add+0x37>
xor    %edi,%edi
lea    0xeba(%rip),%rsi
call   1040 <logprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <mode_add+0xb7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x14(%rbp)
jle    1186 <mode_add+0x66>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1191 <mode_add+0x71>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    1191 <mode_add+0x71>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x3,-0x14(%rbp)
jle    11b4 <mode_add+0x94>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    11bf <mode_add+0x9f>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    11bf <mode_add+0x9f>
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rcx
call   1030 <sqlite_add_msa@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_add>:
push   %rax
cmp    $0x1,%esi
jg     113b <mode_add+0x1b>
lea    0xed3(%rip),%rsi
xor    %edi,%edi
call   1040 <logprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    %rdx,%rax
mov    %esi,%ecx
mov    0x8(%rdx),%rsi
cmp    $0x2,%ecx
jne    114d <mode_add+0x2d>
xor    %edx,%edx
jmp    1160 <mode_add+0x40>
mov    0x10(%rax),%rdx
cmp    $0x4,%ecx
jb     1160 <mode_add+0x40>
mov    0x18(%rax),%rcx
pop    %rax
jmp    1030 <sqlite_add_msa@plt>
xor    %ecx,%ecx
pop    %rax
jmp    1030 <sqlite_add_msa@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Missing arguments\0A\00"
define i32 @mode_add(i32* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8**
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @logprintf(i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %36
12: ; preds = %3
%13 = load i32*, i32** %5
%14 = load i8**, i8*** %7
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i8**, i8*** %7
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
br label %24
23: ; preds = %12
br label %24
24: ; preds = %23, %19
%25 = phi i8* [ %22, %19 ], [ null, %23 ]
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, 3
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8**, i8*** %7
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
br label %33
32: ; preds = %24
br label %33
33: ; preds = %32, %28
%34 = phi i8* [ %31, %28 ], [ null, %32 ]
%35 = call i32 @sqlite_add_msa(i32* %13, i8* %16, i8* %25, i8* %34)
store i32 %35, i32* %4
br label %36
36: ; preds = %33, %10
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [19 x i8] c"Missing arguments\0A\00"
define i32 @mode_add(i32* %0, i32 %1, i8** nocapture %2) {
%4 = icmp slt i32 %1, 2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @logprintf(i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %22
7: ; preds = %3
%8 = getelementptr inbounds i8*, i8** %2, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i32 %1, 2
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8*, i8** %2, i64 2
%13 = load i8*, i8** %12
%14 = icmp ugt i32 %1, 3
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %2, i64 3
%17 = load i8*, i8** %16
br label %18
18: ; preds = %7, %11, %15
%19 = phi i8* [ %13, %15 ], [ %13, %11 ], [ null, %7 ]
%20 = phi i8* [ %17, %15 ], [ null, %11 ], [ null, %7 ]
%21 = tail call i32 @sqlite_add_msa(i32* %0, i8* %9, i8* %19, i8* %20)
br label %22
22: ; preds = %18, %5
%23 = phi i32 [ -1, %5 ], [ %21, %18 ]
ret i32 %23
}