#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;

/* Variables and functions */
unsigned int sqlite3_column_int(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int,
                                      int /*<<< orphan*/ **,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_reset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_step(int /*<<< orphan*/ *);
unsigned int driver_count(sqlite3 *db) {
  unsigned int res;
  static sqlite3_stmt *q = NULL;
  if (q == NULL)
    sqlite3_prepare_v2(db, "select count(id) from Driver", -1, &q, NULL);
  ;
  sqlite3_step(q);
  res = (sqlite3_column_int(q, 0));
  sqlite3_reset(q);
  return res;
}


x86 assembly (clang, -O0):
<driver_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,0x2ef4(%rip)
jne    117b <driver_count+0x3b>
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0xffffffff,%edx
lea    0x2ed7(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <sqlite3_prepare_v2@plt>
mov    0x2ec6(%rip),%rdi
call   1050 <sqlite3_step@plt>
mov    0x2eba(%rip),%rdi
xor    %esi,%esi
call   1040 <sqlite3_column_int@plt>
mov    %eax,-0xc(%rbp)
mov    0x2ea9(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver_count>:
push   %rbx
mov    0x2f00(%rip),%rax
test   %rax,%rax
jne    116f <driver_count+0x2f>
lea    0xeac(%rip),%rsi
lea    0x2eed(%rip),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   1060 <sqlite3_prepare_v2@plt>
mov    0x2ed9(%rip),%rax
mov    %rax,%rdi
call   1050 <sqlite3_step@plt>
mov    0x2eca(%rip),%rdi
xor    %esi,%esi
call   1040 <sqlite3_column_int@plt>
mov    %eax,%ebx
mov    0x2eba(%rip),%rdi
call   1030 <sqlite3_reset@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@driver_count.q = internal global i32* null
@.str = [29 x i8] c"select count(id) from Driver\00"
define i32 @driver_count(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** @driver_count.q
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32*, i32** %2
%8 = call i32 @sqlite3_prepare_v2(i32* %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 -1, i32** @driver_count.q, i32* null)
br label %9
9: ; preds = %6, %1
%10 = load i32*, i32** @driver_count.q
%11 = call i32 @sqlite3_step(i32* %10)
%12 = load i32*, i32** @driver_count.q
%13 = call i32 @sqlite3_column_int(i32* %12, i32 0)
store i32 %13, i32* %3
%14 = load i32*, i32** @driver_count.q
%15 = call i32 @sqlite3_reset(i32* %14)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@driver_count.q = internal global i32* null
@.str = [29 x i8] c"select count(id) from Driver\00"
define i32 @driver_count(i32* %0) {
%2 = load i32*, i32** @driver_count.q
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @sqlite3_prepare_v2(i32* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 -1, i32** @driver_count.q, i32* null)
%6 = load i32*, i32** @driver_count.q
br label %7
7: ; preds = %4, %1
%8 = phi i32* [ %6, %4 ], [ %2, %1 ]
%9 = tail call i32 @sqlite3_step(i32* %8)
%10 = load i32*, i32** @driver_count.q
%11 = tail call i32 @sqlite3_column_int(i32* %10, i32 0)
%12 = load i32*, i32** @driver_count.q
%13 = tail call i32 @sqlite3_reset(i32* %12)
ret i32 %11
}