#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_ROW;
int /*<<< orphan*/ printf(char *, ...);
int sqlite3_column_count(int /*<<< orphan*/ *);
char *sqlite3_column_text(int /*<<< orphan*/ *, int);
int sqlite3_step(int /*<<< orphan*/ *);
void print_result(sqlite3_stmt *stmt) {
  int rc;
  while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
    int col;
    for (col = 0; col < sqlite3_column_count(stmt) - 1; col++) {
      printf("%s|", sqlite3_column_text(stmt, col));
    }
    printf("%s", sqlite3_column_text(stmt, col));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <sqlite3_step@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%eax
jne    11e8 <print_result+0xa8>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <sqlite3_column_count@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b8 <print_result+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1060 <sqlite3_column_text@plt>
mov    %rax,%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <print_result+0x2e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1060 <sqlite3_column_text@plt>
mov    %rax,%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114c <print_result+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_result>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1050 <sqlite3_step@plt>
mov    0x2e79(%rip),%r12
cmp    (%r12),%eax
jne    120b <print_result+0xbb>
lea    0xe88(%rip),%r14
lea    0xe85(%rip),%r15
jmp    11bf <print_result+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <sqlite3_column_text@plt>
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <sqlite3_step@plt>
cmp    (%r12),%eax
jne    120b <print_result+0xbb>
mov    %rbx,%rdi
call   1060 <sqlite3_column_count@plt>
mov    $0x0,%ebp
cmp    $0x2,%eax
jl     1190 <print_result+0x40>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <sqlite3_column_text@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1060 <sqlite3_column_count@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jl     11e0 <print_result+0x90>
jmp    1190 <print_result+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SQLITE_ROW = global i32 0
@.str = [4 x i8] c"%s|\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_result(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
br label %5
5: ; preds = %25, %1
%6 = load i32*, i32** %2
%7 = call i32 @sqlite3_step(i32* %6)
store i32 %7, i32* %3
%8 = load i32, i32* @SQLITE_ROW
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %31
10: ; preds = %5
store i32 0, i32* %4
br label %11
11: ; preds = %22, %10
%12 = load i32, i32* %4
%13 = load i32*, i32** %2
%14 = call i32 @sqlite3_column_count(i32* %13)
%15 = sub nsw i32 %14, 1
%16 = icmp slt i32 %12, %15
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i32*, i32** %2
%19 = load i32, i32* %4
%20 = call i8* @sqlite3_column_text(i32* %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %11
25: ; preds = %11
%26 = load i32*, i32** %2
%27 = load i32, i32* %4
%28 = call i8* @sqlite3_column_text(i32* %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %5
31: ; preds = %5
ret void
}

LLVM IR (-O2):
@SQLITE_ROW = global i32 0
@.str = [4 x i8] c"%s|\00"
@.str.1 = [3 x i8] c"%s\00"
define void @print_result(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 %24
5: ; preds = %1, %16
%6 = tail call i32 @sqlite3_column_count(i32* %0)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %16
8: ; preds = %5, %8
%9 = phi i32 [ %12, %8 ], [ 0, %5 ]
%10 = tail call i8* @sqlite3_column_text(i32* %0, i32 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = add nuw nsw i32 %9, 1
%13 = tail call i32 @sqlite3_column_count(i32* %0)
%14 = add nsw i32 %13, -1
%15 = icmp slt i32 %12, %14
br i1 %15, label %8, label %16
16: ; preds = %8, %5
%17 = phi i32 [ 0, %5 ], [ %12, %8 ]
%18 = tail call i8* @sqlite3_column_text(i32* %0, i32 %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = tail call i32 @putchar(i32 10)
%21 = tail call i32 @sqlite3_step(i32* %0)
%22 = load i32, i32* @SQLITE_ROW
%23 = icmp eq i32 %21, %22
br i1 %23, label %5, label %24
24: ; preds = %16, %1
ret void
}