#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);
int /*<<< orphan*/ *stmt;
struct Data *getMonitorValuesForAll(int ts) {
  sqlite3_stmt *stmt = stmt =
      getStmt("SELECT ts AS ts, dr AS dr, SUM(dl) AS dl, SUM(ul) AS ul FROM "
              "data GROUP BY ts HAVING ts >= ? ORDER BY ts DESC");
  sqlite3_bind_int(stmt, 1, ts);
  struct Data *result = runSelect(stmt);
  finishedStmt(stmt);
  return result;
}


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

x86 assembly (clang, -O2):
<getMonitorValuesForAll>:
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 = [110 x i8] c"SELECT ts AS ts, dr AS dr, SUM(dl) AS dl, SUM(ul) AS ul FROM data GROUP BY ts HAVING ts >= ? ORDER BY ts DESC\00"
@stmt = global i32* null
define %struct.Data* @getMonitorValuesForAll(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca %struct.Data*
store i32 %0, i32* %2
%5 = call i32* @getStmt(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = load i32, i32* %2
%8 = call i32 @sqlite3_bind_int(i32* %6, i32 1, i32 %7)
%9 = load i32*, i32** %3
%10 = call %struct.Data* @runSelect(i32* %9)
store %struct.Data* %10, %struct.Data** %4
%11 = load i32*, i32** %3
%12 = call i32 @finishedStmt(i32* %11)
%13 = load %struct.Data*, %struct.Data** %4
ret %struct.Data* %13
}

LLVM IR (-O2):
%struct.Data = type { i32 }
@.str = [110 x i8] c"SELECT ts AS ts, dr AS dr, SUM(dl) AS dl, SUM(ul) AS ul FROM data GROUP BY ts HAVING ts >= ? ORDER BY ts DESC\00"
@stmt = global i32* null
define %struct.Data* @getMonitorValuesForAll(i32 %0) {
%2 = tail call i32* @getStmt(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @sqlite3_bind_int(i32* %2, i32 1, i32 %0)
%4 = tail call %struct.Data* @runSelect(i32* %2)
%5 = tail call i32 @finishedStmt(i32* %2)
ret %struct.Data* %4
}