#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 *calcTsBoundsHostAdapter(char *hs, char *ad) {
  sqlite3_stmt *stmtTsBounds =
      getStmt("SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ? AND ad = ?");
  sqlite3_bind_text(stmtTsBounds, 1, hs, strlen(hs), SQLITE_TRANSIENT);
  sqlite3_bind_text(stmtTsBounds, 2, ad, strlen(ad), SQLITE_TRANSIENT);
  struct ValueBounds *tsBounds = buildTsBounds(stmtTsBounds);
  finishedStmt(stmtTsBounds);
  return tsBounds;
}


x86 assembly (clang, -O0):
<calcTsBoundsHostAdapter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e46(%rip),%rax
mov    (%rax),%r8d
mov    $0x1,%esi
call   1060 <sqlite3_bind_text@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    0x2e0f(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcTsBoundsHostAdapter>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9b(%rip),%rdi
call   1050 <getStmt@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    0x2e64(%rip),%r12
mov    (%r12),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %eax,%ecx
call   1060 <sqlite3_bind_text@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    (%r12),%r8d
mov    %rbx,%rdi
mov    $0x2,%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    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ValueBounds = type { i32 }
@.str = [58 x i8] c"SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ? AND ad = ?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.ValueBounds* @calcTsBoundsHostAdapter(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 ([58 x i8], [58 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 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = load i32, i32* @SQLITE_TRANSIENT
%19 = call i32 @sqlite3_bind_text(i32* %14, i32 2, i8* %15, i32 %17, i32 %18)
%20 = load i32*, i32** %5
%21 = call %struct.ValueBounds* @buildTsBounds(i32* %20)
store %struct.ValueBounds* %21, %struct.ValueBounds** %6
%22 = load i32*, i32** %5
%23 = call i32 @finishedStmt(i32* %22)
%24 = load %struct.ValueBounds*, %struct.ValueBounds** %6
ret %struct.ValueBounds* %24
}

LLVM IR (-O2):
%struct.ValueBounds = type { i32 }
@.str = [58 x i8] c"SELECT MIN(ts), MAX(ts) FROM data WHERE hs = ? AND ad = ?\00"
@SQLITE_TRANSIENT = global i32 0
define %struct.ValueBounds* @calcTsBoundsHostAdapter(i8* %0, i8* %1) {
%3 = tail call i32* @getStmt(i8* getelementptr inbounds ([58 x i8], [58 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 i32 @strlen(i8* %1)
%8 = load i32, i32* @SQLITE_TRANSIENT
%9 = tail call i32 @sqlite3_bind_text(i32* %3, i32 2, i8* %1, i32 %7, i32 %8)
%10 = tail call %struct.ValueBounds* @buildTsBounds(i32* %3)
%11 = tail call i32 @finishedStmt(i32* %3)
ret %struct.ValueBounds* %10
}