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

/* Variables and functions */
int SQLITE_OK;
int SQLITE_ROW;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_column_text(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ sqlite3_prepare(int /*<<< orphan*/ *, char *, int,
                                   int /*<<< orphan*/ **, int /*<<< orphan*/);
int sqlite3_step(int /*<<< orphan*/ *);
scalar_t__ strcmp(char const *, char *);
int get_control() {
  sqlite3 *db;
  int rc = 0;
  sqlite3_stmt *ppstmt = NULL;
  char sql[256] = {0};
  const char *control = NULL;
  rc = sqlite3_open("/ailvgo/system/domain/domain.db", &db);
  if (rc != SQLITE_OK) {
    printf("open database error");
  }
  memset(sql, 0, sizeof(sql));
  sprintf(sql, "select enable from domain_control");
  sqlite3_prepare(db, sql, -1, &ppstmt, 0);
  rc = sqlite3_step(ppstmt);
  if (rc == SQLITE_ROW) {
    control = sqlite3_column_text(ppstmt, 0);
  }
  sqlite3_finalize(ppstmt);
  sqlite3_close(db);
  if (strcmp(control, "on") == 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<get_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movq   $0x0,-0x128(%rbp)
lea    0xe21(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <sqlite3_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2df3(%rip),%rcx
cmp    (%rcx),%eax
je     1209 <get_control+0x69>
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0xffffffff,%edx
lea    -0x20(%rbp),%rcx
xor    %r8d,%r8d
call   10a0 <sqlite3_prepare@plt>
mov    -0x20(%rbp),%rdi
call   1070 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2d77(%rip),%rcx
cmp    (%rcx),%eax
jne    127b <get_control+0xdb>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_text@plt>
mov    %rax,-0x128(%rbp)
mov    -0x20(%rbp),%rdi
call   10b0 <sqlite3_finalize@plt>
mov    -0x10(%rbp),%rdi
call   1080 <sqlite3_close@plt>
mov    -0x128(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b6 <get_control+0x116>
movl   $0x1,-0x4(%rbp)
jmp    12bd <get_control+0x11d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_control>:
push   %r14
push   %rbx
sub    $0x118,%rsp
movq   $0x0,(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xde9(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <sqlite3_open@plt>
mov    0x2dc0(%rip),%rcx
cmp    (%rcx),%eax
je     1238 <get_control+0xa8>
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movups 0xdde(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xde2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movw   $0x6c,0x30(%rsp)
mov    0x8(%rsp),%rdi
mov    %rsp,%rcx
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10a0 <sqlite3_prepare@plt>
mov    (%rsp),%rdi
call   1070 <sqlite3_step@plt>
mov    0x2d42(%rip),%rcx
cmp    (%rcx),%eax
jne    12a8 <get_control+0x118>
mov    (%rsp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    (%rsp),%rdi
call   10b0 <sqlite3_finalize@plt>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_close@plt>
lea    0xd94(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"/ailvgo/system/domain/domain.db\00"
@SQLITE_OK = global i32 0
@.str.1 = [20 x i8] c"open database error\00"
@.str.2 = [34 x i8] c"select enable from domain_control\00"
@SQLITE_ROW = global i32 0
@.str.3 = [3 x i8] c"on\00"
define i32 @get_control() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca i8*
store i32 0, i32* %3
store i32* null, i32** %4
%7 = bitcast [256 x i8]* %5 to i8*
store i8* null, i8** %6
%8 = call i32 @sqlite3_open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32** %2)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = load i32, i32* @SQLITE_OK
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 256)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32*, i32** %2
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 @sqlite3_prepare(i32* %19, i8* %20, i32 -1, i32** %4, i32 0)
%22 = load i32*, i32** %4
%23 = call i32 @sqlite3_step(i32* %22)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = load i32, i32* @SQLITE_ROW
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %14
%28 = load i32*, i32** %4
%29 = call i8* @sqlite3_column_text(i32* %28, i32 0)
store i8* %29, i8** %6
br label %30
30: ; preds = %27, %14
%31 = load i32*, i32** %4
%32 = call i32 @sqlite3_finalize(i32* %31)
%33 = load i32*, i32** %2
%34 = call i32 @sqlite3_close(i32* %33)
%35 = load i8*, i8** %6
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %30
store i32 1, i32* %1
br label %40
39: ; preds = %30
store i32 0, i32* %1
br label %40
40: ; preds = %39, %38
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [32 x i8] c"/ailvgo/system/domain/domain.db\00"
@SQLITE_OK = global i32 0
@.str.1 = [20 x i8] c"open database error\00"
@.str.2 = [34 x i8] c"select enable from domain_control\00"
@SQLITE_ROW = global i32 0
@.str.3 = [3 x i8] c"on\00"
define i32 @get_control() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = bitcast i32** %1 to i8*
%5 = bitcast i32** %2 to i8*
store i32* null, i32** %2
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @sqlite3_open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32** %1)
%8 = load i32, i32* @SQLITE_OK
%9 = icmp eq i32 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call i32 @memset(i8* %6, i32 0, i32 256)
%14 = load i32*, i32** %1
%15 = call i32 @sqlite3_prepare(i32* %14, i8* %6, i32 -1, i32** %2, i32 0)
%16 = load i32*, i32** %2
%17 = call i32 @sqlite3_step(i32* %16)
%18 = load i32, i32* @SQLITE_ROW
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32*, i32** %2
%22 = call i8* @sqlite3_column_text(i32* %21, i32 0)
br label %23
23: ; preds = %20, %12
%24 = phi i8* [ %22, %20 ], [ null, %12 ]
%25 = load i32*, i32** %2
%26 = call i32 @sqlite3_finalize(i32* %25)
%27 = load i32*, i32** %1
%28 = call i32 @sqlite3_close(i32* %27)
%29 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
ret i32 %31
}