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

/* Variables and functions */
int /*<<< orphan*/ SQLITE_TRANSIENT;
struct ValueBounds *buildTsBounds(int /*<<< orphan*/ *);
int /*<<< orphan*/ finishedStmt(int /*<<< orphan*/ *);
int /*<<< orphan*/ *getStmt(char *);
int /*<<< orphan*/ sqlite3_bind_text(int /*<<< orphan*/ *, int, char *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
struct ValueBounds *calcTsBoundsHost(char *hs, char *ad) {
  sqlite3_stmt *stmtTsBounds =
      getStmt("SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ?");
  sqlite3_bind_text(stmtTsBounds, 1, hs, strlen(hs), SQLITE_TRANSIENT);
  struct ValueBounds *tsBounds = buildTsBounds(stmtTsBounds);
  finishedStmt(stmtTsBounds);
  return tsBounds;
}


x86 assembly (clang, -O0):
<calcTsBoundsHost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe99(%rip),%rdi
call   1050 <getStmt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e46(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1060 <sqlite3_bind_text@plt>
mov    -0x18(%rbp),%rdi
call   1040 <buildTsBounds@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <finishedStmt@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcTsBoundsHost>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rdi
call   1050 <getStmt@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    0x2e6b(%rip),%rcx
mov    (%rcx),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <sqlite3_bind_text@plt>
mov    %rbx,%rdi
call   1040 <buildTsBounds@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <finishedStmt@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ValueBounds = type { i32 }
@.str = [47 x i8] c"SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.ValueBounds* @calcTsBoundsHost(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca %struct.ValueBounds*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i32* @getStmt(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = load i32, i32* @SQLITE_TRANSIENT
%13 = call i32 @sqlite3_bind_text(i32* %8, i32 1, i8* %9, i32 %11, i32 %12)
%14 = load i32*, i32** %5
%15 = call %struct.ValueBounds* @buildTsBounds(i32* %14)
store %struct.ValueBounds* %15, %struct.ValueBounds** %6
%16 = load i32*, i32** %5
%17 = call i32 @finishedStmt(i32* %16)
%18 = load %struct.ValueBounds*, %struct.ValueBounds** %6
ret %struct.ValueBounds* %18
}

LLVM IR (-O2):
%struct.ValueBounds = type { i32 }
@.str = [47 x i8] c"SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.ValueBounds* @calcTsBoundsHost(i8* %0, i8* nocapture readnone %1) {
%3 = tail call i32* @getStmt(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %0)
%5 = load i32, i32* @SQLITE_TRANSIENT
%6 = tail call i32 @sqlite3_bind_text(i32* %3, i32 1, i8* %0, i32 %4, i32 %5)
%7 = tail call %struct.ValueBounds* @buildTsBounds(i32* %3)
%8 = tail call i32 @finishedStmt(i32* %3)
ret %struct.ValueBounds* %7
}