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

/* Variables and functions */
int SQLITE_DONE;
int SQLITE_ROW;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ sqlite3_column_text(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *sqlite3_errstr(int);
int /*<<< orphan*/ sqlite3_finalize(int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
char *sql_step_single_row(sqlite3_stmt *stmt) {
  int status;
  char *column = NULL;
  status = sqlite3_step(stmt);
  if (status == SQLITE_ROW)
    column = strdup((char *)sqlite3_column_text(stmt, 0));
  else if (status == SQLITE_DONE)
    fprintf(stderr, "no rows returned\n");
  else
    fprintf(stderr, "%s\n", sqlite3_errstr(status));
  sqlite3_finalize(stmt);
  return column;
}


x86 assembly (clang, -O0):
<sql_step_single_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <sqlite3_step@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%eax
jne    11ae <sql_step_single_row+0x4e>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <sqlite3_column_text@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    1209 <sql_step_single_row+0xa9>
mov    -0xc(%rbp),%eax
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%eax
jne    11dc <sql_step_single_row+0x7c>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1204 <sql_step_single_row+0xa4>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <sqlite3_errstr@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1209 <sql_step_single_row+0xa9>
mov    -0x8(%rbp),%rdi
call   1070 <sqlite3_finalize@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sql_step_single_row>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <sqlite3_step@plt>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
jne    118e <sql_step_single_row+0x2e>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <sqlite3_column_text@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r14
jmp    11d4 <sql_step_single_row+0x74>
mov    0x2e43(%rip),%rcx
mov    0x2e44(%rip),%rdx
mov    (%rdx),%ebp
cmp    (%rcx),%eax
jne    11b7 <sql_step_single_row+0x57>
lea    0xe57(%rip),%rsi
xor    %r14d,%r14d
mov    %ebp,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11d4 <sql_step_single_row+0x74>
mov    %eax,%edi
call   1060 <sqlite3_errstr@plt>
lea    0xe4d(%rip),%rsi
xor    %r14d,%r14d
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <sqlite3_finalize@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"no rows returned\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i8* @sql_step_single_row(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
store i32* %0, i32** %2
store i8* null, i8** %4
%5 = load i32*, i32** %2
%6 = call i32 @sqlite3_step(i32* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @SQLITE_ROW
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32*, i32** %2
%12 = call i64 @sqlite3_column_text(i32* %11, i32 0)
%13 = inttoptr i64 %12 to i8*
%14 = call i8* @strdup(i8* %13)
store i8* %14, i8** %4
br label %28
15: ; preds = %1
%16 = load i32, i32* %3
%17 = load i32, i32* @SQLITE_DONE
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %27
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i32, i32* %3
%25 = call i8* @sqlite3_errstr(i32 %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %19
br label %28
28: ; preds = %27, %10
%29 = load i32*, i32** %2
%30 = call i32 @sqlite3_finalize(i32* %29)
%31 = load i8*, i8** %4
ret i8* %31
}

LLVM IR (-O2):
@SQLITE_ROW = global i32 0
@SQLITE_DONE = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"no rows returned\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define noalias i8* @sql_step_single_row(i32* %0) {
%2 = tail call i32 @sqlite3_step(i32* %0)
%3 = load i32, i32* @SQLITE_ROW
%4 = icmp eq i32 %2, %3
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i64 @sqlite3_column_text(i32* %0, i32 0)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i8* @strdup(i8* %7)
br label %18
9: ; preds = %1
%10 = load i32, i32* @SQLITE_DONE
%11 = icmp eq i32 %2, %10
%12 = load i32, i32* @stderr
br i1 %11, label %13, label %15
13: ; preds = %9
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %18
15: ; preds = %9
%16 = tail call i8* @sqlite3_errstr(i32 %2)
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %13, %15, %5
%19 = phi i8* [ %8, %5 ], [ null, %13 ], [ null, %15 ]
%20 = tail call i32 @sqlite3_finalize(i32* %0)
ret i8* %19
}