#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 */
struct Data {
  int dummy;
};
typedef int /*<<< orphan*/ sqlite3_stmt;

/* Variables and functions */
int /*<<< orphan*/ finishedStmt(int /*<<< orphan*/ *);
int /*<<< orphan*/ *getStmt(char *);
struct Data *runSelect(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
struct Data *calcTotalsForAllSince(int ts, char *hs, char *ad) {
  sqlite3_stmt *stmt =
      getStmt("SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=?");
  sqlite3_bind_int(stmt, 1, ts);
  struct Data *result = runSelect(stmt);
  finishedStmt(stmt);
  return result;
}


x86 assembly (clang, -O0):
<calcTotalsForAllSince>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea6(%rip),%rdi
call   1050 <getStmt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0x1,%esi
call   1030 <sqlite3_bind_int@plt>
mov    -0x20(%rbp),%rdi
call   1040 <runSelect@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <finishedStmt@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcTotalsForAllSince>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xeb4(%rip),%rdi
call   1050 <getStmt@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1040 <runSelect@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1060 <finishedStmt@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.Data = type { i32 }
@.str = [58 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=?\00"
define %struct.Data* @calcTotalsForAllSince(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.Data*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = call i32* @getStmt(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = load i32, i32* %4
%12 = call i32 @sqlite3_bind_int(i32* %10, i32 1, i32 %11)
%13 = load i32*, i32** %7
%14 = call %struct.Data* @runSelect(i32* %13)
store %struct.Data* %14, %struct.Data** %8
%15 = load i32*, i32** %7
%16 = call i32 @finishedStmt(i32* %15)
%17 = load %struct.Data*, %struct.Data** %8
ret %struct.Data* %17
}

LLVM IR (-O2):
%struct.Data = type { i32 }
@.str = [58 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=?\00"
define %struct.Data* @calcTotalsForAllSince(i32 %0, i8* nocapture readnone %1, i8* nocapture readnone %2) {
%4 = tail call i32* @getStmt(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @sqlite3_bind_int(i32* %4, i32 1, i32 %0)
%6 = tail call %struct.Data* @runSelect(i32* %4)
%7 = tail call i32 @finishedStmt(i32* %4)
ret %struct.Data* %6
}