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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int SQLITE_DONE;
int SQLITE_ROW;
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sqlite3_column_blob(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sqlite3_column_bytes(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int sqlite3_prepare_v2(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ **,
                       int /*<<< orphan*/ *);
int sqlite3_step(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int rc;
  sqlite3 *db;
  char *str;
  rc = sqlite3_open("bucket.db", &db);
  if (rc) {
    printf("Fehler beim Öffnen\n");
    return EXIT_SUCCESS;
  }
  sqlite3_stmt *stmt;
  rc = sqlite3_prepare_v2(db,
                          "select bin from bin_bucket where id = "
                          "'7511cc9269c1f52e7ed31f0b0bfe742f';",
                          -1, &stmt, NULL);
  while ((rc = sqlite3_step(stmt)) != SQLITE_DONE) {
    if (rc != SQLITE_ROW) {
      printf("Ein Fehler während des Steppens ist aufgetreten!");
      return EXIT_FAILURE;
    } else {
      printf("step\n");
      str = (char *)malloc(sqlite3_column_bytes(stmt, 0) + 1);
      strcpy(str, (char *)sqlite3_column_blob(stmt, 0));
    }
  }
  printf("Data: %s\n", str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe63(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <sqlite3_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d2 <main+0x52>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129e <main+0x11e>
mov    -0x20(%rbp),%rdi
lea    0xe42(%rip),%rsi
mov    $0xffffffff,%edx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10a0 <sqlite3_prepare_v2@plt>
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <sqlite3_step@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%eax
je     128c <main+0x10c>
mov    -0x14(%rbp),%eax
mov    0x2db0(%rip),%rcx
cmp    (%rcx),%eax
je     123f <main+0xbf>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129e <main+0x11e>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1080 <sqlite3_column_bytes@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1030 <sqlite3_column_blob@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
jmp    11f3 <main+0x73>
mov    -0x28(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe5f(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <sqlite3_open@plt>
test   %eax,%eax
je     11c7 <main+0x37>
lea    0xedf(%rip),%rdi
call   1050 <puts@plt>
mov    0x2e0e(%rip),%rax
jmp    1285 <main+0xf5>
mov    0x10(%rsp),%rdi
lea    0xe37(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    $0xffffffff,%edx
xor    %r8d,%r8d
call   10b0 <sqlite3_prepare_v2@plt>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_step@plt>
mov    0x2dd2(%rip),%rbp
lea    0xe93(%rip),%r14
mov    0x2ddc(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    0x0(%rbp),%eax
jne    1270 <main+0xe0>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <sqlite3_column_bytes@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <sqlite3_column_blob@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%rdi
call   1080 <sqlite3_step@plt>
cmp    (%r15),%eax
jne    1210 <main+0x80>
lea    0xe24(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1287 <main+0xf7>
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"bucket.db\00"
@.str.1 = [21 x i8] c"Fehler beim \C3\96ffnen\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [74 x i8] c"select bin from bin_bucket where id = '7511cc9269c1f52e7ed31f0b0bfe742f';\00"
@SQLITE_DONE = global i32 0
@SQLITE_ROW = global i32 0
@.str.3 = [50 x i8] c"Ein Fehler w\C3\A4hrend des Steppens ist aufgetreten!\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [6 x i8] c"step\0A\00"
@.str.5 = [10 x i8] c"Data: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @sqlite3_open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32** %7)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_SUCCESS
store i32 %15, i32* %3
br label %47
16: ; preds = %2
%17 = load i32*, i32** %7
%18 = call i32 @sqlite3_prepare_v2(i32* %17, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i32 -1, i32** %9, i32* null)
store i32 %18, i32* %6
br label %19
19: ; preds = %43, %16
%20 = load i32*, i32** %9
%21 = call i32 @sqlite3_step(i32* %20)
store i32 %21, i32* %6
%22 = load i32, i32* @SQLITE_DONE
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %44
24: ; preds = %19
%25 = load i32, i32* %6
%26 = load i32, i32* @SQLITE_ROW
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %47
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32*, i32** %9
%34 = call i64 @sqlite3_column_bytes(i32* %33, i32 0)
%35 = add nsw i64 %34, 1
%36 = call i64 @malloc(i64 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %8
%38 = load i8*, i8** %8
%39 = load i32*, i32** %9
%40 = call i64 @sqlite3_column_blob(i32* %39, i32 0)
%41 = inttoptr i64 %40 to i8*
%42 = call i32 @strcpy(i8* %38, i8* %41)
br label %43
43: ; preds = %31
br label %19
44: ; preds = %19
%45 = load i8*, i8** %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %28, %13
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [10 x i8] c"bucket.db\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [74 x i8] c"select bin from bin_bucket where id = '7511cc9269c1f52e7ed31f0b0bfe742f';\00"
@SQLITE_DONE = global i32 0
@SQLITE_ROW = global i32 0
@.str.3 = [50 x i8] c"Ein Fehler w\C3\A4hrend des Steppens ist aufgetreten!\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [10 x i8] c"Data: %s\0A\00"
@str = [5 x i8] c"step\00"
@str.6 = [20 x i8] c"Fehler beim \C3\96ffnen\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = bitcast i32** %3 to i8*
%6 = call i32 @sqlite3_open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32** %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%10 = load i32, i32* @EXIT_SUCCESS
br label %46
11: ; preds = %2
%12 = bitcast i32** %4 to i8*
%13 = load i32*, i32** %3
%14 = call i32 @sqlite3_prepare_v2(i32* %13, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i32 -1, i32** %4, i32* null)
%15 = load i32*, i32** %4
%16 = call i32 @sqlite3_step(i32* %15)
%17 = load i32, i32* @SQLITE_DONE
%18 = icmp ne i32 %16, %17
br label %19
19: ; preds = %11, %26
%20 = phi i32 [ %38, %26 ], [ %16, %11 ]
%21 = load i32, i32* @SQLITE_ROW
%22 = icmp eq i32 %20, %21
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
br label %44
26: ; preds = %19
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%28 = load i32*, i32** %4
%29 = call i64 @sqlite3_column_bytes(i32* %28, i32 0)
%30 = add nsw i64 %29, 1
%31 = call i64 @malloc(i64 %30)
%32 = inttoptr i64 %31 to i8*
%33 = load i32*, i32** %4
%34 = call i64 @sqlite3_column_blob(i32* %33, i32 0)
%35 = inttoptr i64 %34 to i8*
%36 = call i32 @strcpy(i8* %32, i8* %35)
%37 = load i32*, i32** %4
%38 = call i32 @sqlite3_step(i32* %37)
%39 = load i32, i32* @SQLITE_DONE
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %19
41: ; preds = %26
%42 = inttoptr i64 %31 to i8*
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %23
%45 = phi i32 [ %25, %23 ], [ 0, %41 ]
br label %46
46: ; preds = %44, %8
%47 = phi i32 [ %10, %8 ], [ %45, %44 ]
ret i32 %47
}