#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 *calcTotalsForHsSince(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=?");
  sqlite3_bind_int(stmt, 1, ts);
  sqlite3_bind_text(stmt, 2, hs, strlen(hs), SQLITE_TRANSIENT);
  struct Data *data = runSelect(stmt);
  finishedStmt(stmt);
  return data;
}


x86 assembly (clang, -O0):
<calcTotalsForHsSince>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e22(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcTotalsForHsSince>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xe8f(%rip),%rdi
call   1060 <getStmt@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
call   1030 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2e48(%rip),%rcx
mov    (%rcx),%r8d
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1070 <sqlite3_bind_text@plt>
mov    %rbp,%rdi
call   1050 <runSelect@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1080 <finishedStmt@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Data = type { i32 }
@.str = [67 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=? AND hs=?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.Data* @calcTotalsForHsSince(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 ([67 x i8], [67 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 = call %struct.Data* @runSelect(i32* %19)
store %struct.Data* %20, %struct.Data** %8
%21 = load i32*, i32** %7
%22 = call i32 @finishedStmt(i32* %21)
%23 = load %struct.Data*, %struct.Data** %8
ret %struct.Data* %23
}

LLVM IR (-O2):
%struct.Data = type { i32 }
@.str = [67 x i8] c"SELECT SUM(dl) AS dl, SUM(ul) AS ul FROM data WHERE ts>=? AND hs=?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.Data* @calcTotalsForHsSince(i32 %0, i8* %1, i8* nocapture readnone %2) {
%4 = tail call i32* @getStmt(i8* getelementptr inbounds ([67 x i8], [67 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 %struct.Data* @runSelect(i32* %4)
%10 = tail call i32 @finishedStmt(i32* %4)
ret %struct.Data* %9
}