#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*/ *stmt;
int /*<<< orphan*/ strlen(char *);
struct Data *getMonitorValuesForHost(int ts, char *hs) {
  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,hs HAVING ts >= ? AND hs = ? ORDER BY ts DESC");
  sqlite3_bind_int(stmt, 1, ts);
  sqlite3_bind_text(stmt, 2, hs, strlen(hs), SQLITE_TRANSIENT);
  struct Data *result = runSelect(stmt);
  finishedStmt(stmt);
  return result;
}


x86 assembly (clang, -O0):
<getMonitorValuesForHost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
call   1060 <getStmt@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0x1,%esi
call   1030 <sqlite3_bind_int@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e22(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
call   1070 <sqlite3_bind_text@plt>
mov    -0x18(%rbp),%rdi
call   1050 <runSelect@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <finishedStmt@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

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