#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*/ SQLITE_TRANSIENT;
int /*<<< orphan*/ finishedStmt(int /*<<< orphan*/ *);
int /*<<< orphan*/ *getStmt(char *);
struct Data *runSelect(int /*<<< orphan*/ *);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ sqlite3_bind_text(int /*<<< orphan*/ *, int, char *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
struct Data *calcTotalsForHsAdSince(int ts, char *hs, char *ad) {
  sqlite3_stmt *stmt = getStmt("SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data "
                               "WHERE ts>=? AND hs=? AND ad=?");
  sqlite3_bind_int(stmt, 1, ts);
  sqlite3_bind_text(stmt, 2, hs, strlen(hs), SQLITE_TRANSIENT);
  sqlite3_bind_text(stmt, 3, ad, strlen(ad), SQLITE_TRANSIENT);
  struct Data *data = runSelect(stmt);
  finishedStmt(stmt);
  return data;
}


x86 assembly (clang, -O0):
<calcTotalsForHsAdSince>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe86(%rip),%rdi
call   1060 <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),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e22(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
call   1070 <sqlite3_bind_text@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
mov    0x2deb(%rip),%rax
mov    (%rax),%r8d
mov    $0x3,%esi
call   1070 <sqlite3_bind_text@plt>
mov    -0x20(%rbp),%rdi
call   1050 <runSelect@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <finishedStmt@plt>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcTotalsForHsAdSince>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xe8a(%rip),%rdi
call   1060 <getStmt@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1030 <sqlite3_bind_int@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    0x2e44(%rip),%rbp
mov    0x0(%rbp),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1070 <sqlite3_bind_text@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    0x0(%rbp),%r8d
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1070 <sqlite3_bind_text@plt>
mov    %rbx,%rdi
call   1050 <runSelect@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1080 <finishedStmt@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Data = type { i32 }
@.str = [76 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=? AND hs=? AND ad=?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.Data* @calcTotalsForHsAdSince(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 ([76 x i8], [76 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 = load i8*, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = load i32, i32* @SQLITE_TRANSIENT
%18 = call i32 @sqlite3_bind_text(i32* %13, i32 2, i8* %14, i32 %16, i32 %17)
%19 = load i32*, i32** %7
%20 = load i8*, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
%23 = load i32, i32* @SQLITE_TRANSIENT
%24 = call i32 @sqlite3_bind_text(i32* %19, i32 3, i8* %20, i32 %22, i32 %23)
%25 = load i32*, i32** %7
%26 = call %struct.Data* @runSelect(i32* %25)
store %struct.Data* %26, %struct.Data** %8
%27 = load i32*, i32** %7
%28 = call i32 @finishedStmt(i32* %27)
%29 = load %struct.Data*, %struct.Data** %8
ret %struct.Data* %29
}

LLVM IR (-O2):
%struct.Data = type { i32 }
@.str = [76 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=? AND hs=? AND ad=?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.Data* @calcTotalsForHsAdSince(i32 %0, i8* %1, i8* %2) {
%4 = tail call i32* @getStmt(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @sqlite3_bind_int(i32* %4, i32 1, i32 %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = load i32, i32* @SQLITE_TRANSIENT
%8 = tail call i32 @sqlite3_bind_text(i32* %4, i32 2, i8* %1, i32 %6, i32 %7)
%9 = tail call i32 @strlen(i8* %2)
%10 = load i32, i32* @SQLITE_TRANSIENT
%11 = tail call i32 @sqlite3_bind_text(i32* %4, i32 3, i8* %2, i32 %9, i32 %10)
%12 = tail call %struct.Data* @runSelect(i32* %4)
%13 = tail call i32 @finishedStmt(i32* %4)
ret %struct.Data* %12
}