#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 */
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ log_message(char *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ sqlite3_exec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/, char **);
int /*<<< orphan*/ sqlite3_free(char *);
int gpio_dao_init(sqlite3 *db) {
  char *err_msg;
  char *sql = "CREATE TABLE gpio ( 			id  INTEGER PRIMARY "
              "KEY	ASC NOT NULL, 			number INTEGER UNIQUE "
              "NOT NULL, 			name TEXT, 		"
              "	pulsetime INTEGER 			);";
  if (sqlite3_exec(db, sql, NULL, 0, &err_msg) != SQLITE_OK) {
    log_message("[ERROR][%d-%d-%d %d:%d:%d] ",
                "Could not create 'gpio' table\r\n");
    perror(err_msg);
    sqlite3_free(err_msg);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<gpio_dao_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
lea    -0x18(%rbp),%r8
call   1030 <sqlite3_exec@plt>
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
je     11af <gpio_dao_init+0x6f>
lea    0xf04(%rip),%rdi
lea    0xf19(%rip),%rsi
call   1040 <log_message@plt>
mov    -0x18(%rbp),%rdi
call   1050 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1060 <sqlite3_free@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <gpio_dao_init+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_dao_init>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rsi
xor    %ebx,%ebx
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <sqlite3_exec@plt>
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
jne    1170 <gpio_dao_init+0x30>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xf12(%rip),%rdi
lea    0xf27(%rip),%rsi
call   1040 <log_message@plt>
mov    0x8(%rsp),%rdi
call   1050 <perror@plt>
mov    0x8(%rsp),%rdi
call   1060 <sqlite3_free@plt>
mov    $0x1,%ebx
jmp    1168 <gpio_dao_init+0x28>

LLVM IR (-O0):
@.str = [137 x i8] c"CREATE TABLE gpio ( \09\09\09id INTEGER PRIMARY KEY\09ASC NOT NULL, \09\09\09number INTEGER UNIQUE NOT NULL, \09\09\09name TEXT, \09\09\09pulsetime INTEGER \09\09\09);\00"
@SQLITE_OK = global i64 0
@.str.1 = [28 x i8] c"[ERROR][%d-%d-%d %d:%d:%d] \00"
@.str.2 = [32 x i8] c"Could not create 'gpio' table\0D\0A\00"
define i32 @gpio_dao_init(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %3
store i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = load i32*, i32** %3
%7 = load i8*, i8** %5
%8 = call i64 @sqlite3_exec(i32* %6, i8* %7, i32* null, i32 0, i8** %4)
%9 = load i64, i64* @SQLITE_OK
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = call i32 @log_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i32 @perror(i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @sqlite3_free(i8* %15)
store i32 1, i32* %2
br label %18
17: ; preds = %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %11
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [137 x i8] c"CREATE TABLE gpio ( \09\09\09id INTEGER PRIMARY KEY\09ASC NOT NULL, \09\09\09number INTEGER UNIQUE NOT NULL, \09\09\09name TEXT, \09\09\09pulsetime INTEGER \09\09\09);\00"
@SQLITE_OK = global i64 0
@.str.1 = [28 x i8] c"[ERROR][%d-%d-%d %d:%d:%d] \00"
@.str.2 = [32 x i8] c"Could not create 'gpio' table\0D\0A\00"
define i32 @gpio_dao_init(i32* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @sqlite3_exec(i32* %0, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32* null, i32 0, i8** %2)
%5 = load i64, i64* @SQLITE_OK
%6 = icmp eq i64 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = call i32 @log_message(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = call i32 @perror(i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @sqlite3_free(i8* %11)
br label %13
13: ; preds = %1, %7
%14 = phi i32 [ 1, %7 ], [ 0, %1 ]
ret i32 %14
}