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

/* Variables and functions */
int SQLITE_DONE;
int SQLITE_ROW;
int /*<<< orphan*/ logMsg(int, char *, int);
struct DateCriteria *makeDateCriteria(char *, char *, char *, char *, char *);
int /*<<< orphan*/ sqlite3_bind_int(int /*<<< orphan*/ *, int, int);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sqlite3_reset(int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
struct DateCriteria *getIntervalForId(sqlite3_stmt *stmtSelectInterval,
                                      int id) {
  sqlite3_bind_int(stmtSelectInterval, 1, id);
  int rc = sqlite3_step(stmtSelectInterval);
  char *yearTxt;
  char *monthTxt;
  char *dayTxt;
  char *weekdayTxt;
  char *hourTxt;
  struct DateCriteria *result = NULL;
  if (rc == SQLITE_ROW) {
    yearTxt = sqlite3_column_text(stmtSelectInterval, 0);
    monthTxt = sqlite3_column_text(stmtSelectInterval, 1);
    dayTxt = sqlite3_column_text(stmtSelectInterval, 2);
    weekdayTxt = sqlite3_column_text(stmtSelectInterval, 3);
    hourTxt = sqlite3_column_text(stmtSelectInterval, 4);
    result = makeDateCriteria(yearTxt, monthTxt, dayTxt, weekdayTxt, hourTxt);
  } else if (rc != SQLITE_DONE) {
    logMsg(4, "stmtSelectInterval failed: %d", rc);
  }
  sqlite3_reset(stmtSelectInterval);
  return result;
}


x86 assembly (clang, -O0):
<getIntervalForId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1040 <sqlite3_bind_int@plt>
mov    -0x8(%rbp),%rdi
call   1060 <sqlite3_step@plt>
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%eax
jne    121f <getIntervalForId+0xbf>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1080 <makeDateCriteria@plt>
mov    %rax,-0x40(%rbp)
jmp    124a <getIntervalForId+0xea>
mov    -0x10(%rbp),%eax
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%eax
je     1245 <getIntervalForId+0xe5>
mov    -0x10(%rbp),%edx
mov    $0x4,%edi
lea    0xdc0(%rip),%rsi
call   1050 <logMsg@plt>
jmp    124a <getIntervalForId+0xea>
mov    -0x8(%rbp),%rdi
call   1030 <sqlite3_reset@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntervalForId>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%edx
mov    %rdi,%rbx
mov    $0x1,%esi
call   1040 <sqlite3_bind_int@plt>
mov    %rbx,%rdi
call   1060 <sqlite3_step@plt>
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%eax
jne    11ee <getIntervalForId+0x8e>
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <sqlite3_column_text@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <sqlite3_column_text@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rax,%r8
call   1080 <makeDateCriteria@plt>
mov    %rax,%r14
jmp    120f <getIntervalForId+0xaf>
mov    0x2deb(%rip),%rcx
cmp    (%rcx),%eax
je     120c <getIntervalForId+0xac>
lea    0xe00(%rip),%rsi
mov    $0x4,%edi
mov    %eax,%edx
call   1050 <logMsg@plt>
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1030 <sqlite3_reset@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.DateCriteria = type { i32 }
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@.str = [30 x i8] c"stmtSelectInterval failed: %d\00"
define %struct.DateCriteria* @getIntervalForId(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.DateCriteria*
store i32* %0, i32** %3
store i32 %1, i32* %4
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = call i32 @sqlite3_bind_int(i32* %12, i32 1, i32 %13)
%15 = load i32*, i32** %3
%16 = call i32 @sqlite3_step(i32* %15)
store i32 %16, i32* %5
store %struct.DateCriteria* null, %struct.DateCriteria** %11
%17 = load i32, i32* %5
%18 = load i32, i32* @SQLITE_ROW
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %37
20: ; preds = %2
%21 = load i32*, i32** %3
%22 = call i8* @sqlite3_column_text(i32* %21, i32 0)
store i8* %22, i8** %6
%23 = load i32*, i32** %3
%24 = call i8* @sqlite3_column_text(i32* %23, i32 1)
store i8* %24, i8** %7
%25 = load i32*, i32** %3
%26 = call i8* @sqlite3_column_text(i32* %25, i32 2)
store i8* %26, i8** %8
%27 = load i32*, i32** %3
%28 = call i8* @sqlite3_column_text(i32* %27, i32 3)
store i8* %28, i8** %9
%29 = load i32*, i32** %3
%30 = call i8* @sqlite3_column_text(i32* %29, i32 4)
store i8* %30, i8** %10
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = load i8*, i8** %10
%36 = call %struct.DateCriteria* @makeDateCriteria(i8* %31, i8* %32, i8* %33, i8* %34, i8* %35)
store %struct.DateCriteria* %36, %struct.DateCriteria** %11
br label %45
37: ; preds = %2
%38 = load i32, i32* %5
%39 = load i32, i32* @SQLITE_DONE
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %5
%43 = call i32 @logMsg(i32 4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %37
br label %45
45: ; preds = %44, %20
%46 = load i32*, i32** %3
%47 = call i32 @sqlite3_reset(i32* %46)
%48 = load %struct.DateCriteria*, %struct.DateCriteria** %11
ret %struct.DateCriteria* %48
}

LLVM IR (-O2):
%struct.DateCriteria = type { i32 }
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@.str = [30 x i8] c"stmtSelectInterval failed: %d\00"
define %struct.DateCriteria* @getIntervalForId(i32* %0, i32 %1) {
%3 = tail call i32 @sqlite3_bind_int(i32* %0, i32 1, i32 %1)
%4 = tail call i32 @sqlite3_step(i32* %0)
%5 = load i32, i32* @SQLITE_ROW
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = tail call i8* @sqlite3_column_text(i32* %0, i32 0)
%9 = tail call i8* @sqlite3_column_text(i32* %0, i32 1)
%10 = tail call i8* @sqlite3_column_text(i32* %0, i32 2)
%11 = tail call i8* @sqlite3_column_text(i32* %0, i32 3)
%12 = tail call i8* @sqlite3_column_text(i32* %0, i32 4)
%13 = tail call %struct.DateCriteria* @makeDateCriteria(i8* %8, i8* %9, i8* %10, i8* %11, i8* %12)
br label %19
14: ; preds = %2
%15 = load i32, i32* @SQLITE_DONE
%16 = icmp eq i32 %4, %15
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @logMsg(i32 4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %19
19: ; preds = %14, %17, %7
%20 = phi %struct.DateCriteria* [ %13, %7 ], [ null, %17 ], [ null, %14 ]
%21 = tail call i32 @sqlite3_reset(i32* %0)
ret %struct.DateCriteria* %20
}