#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_vfs;

/* Variables and functions */
scalar_t__ SQLITE_OK;
int /*<<< orphan*/ bzzvfs_debug(int);
int bzzvfs_open(char *);
scalar_t__ bzzvfs_register();
int /*<<< orphan*/ *sqlite3_vfs_find(char *);
int main(int argc, char **argv) {
  if (bzzvfs_register() != SQLITE_OK) {
    return 1;
  }
  bzzvfs_debug(1);
  sqlite3_vfs *thevfs = sqlite3_vfs_find("bzz");
  if (thevfs == 0) {
    return 1;
  }
  return bzzvfs_open(
      "abcdef0123456789abcdef1234567890abcdef1234567890abcdef1234568790");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <bzzvfs_register@plt>
mov    0x2e84(%rip),%rcx
cmp    (%rcx),%rax
je     1179 <main+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <main+0x79>
mov    $0x1,%edi
call   1060 <bzzvfs_debug@plt>
lea    0xe76(%rip),%rdi
call   1030 <sqlite3_vfs_find@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11aa <main+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <main+0x79>
lea    0xe53(%rip),%rdi
call   1050 <bzzvfs_open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <bzzvfs_register@plt>
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%rax
jne    117c <main+0x3c>
mov    $0x1,%edi
call   1060 <bzzvfs_debug@plt>
lea    0xe9b(%rip),%rdi
call   1030 <sqlite3_vfs_find@plt>
test   %rax,%rax
je     117c <main+0x3c>
lea    0xe8e(%rip),%rdi
pop    %rax
jmp    1050 <bzzvfs_open@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@SQLITE_OK = global i64 0
@.str = [4 x i8] c"bzz\00"
@.str.1 = [65 x i8] c"abcdef0123456789abcdef1234567890abcdef1234567890abcdef1234568790\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 (...) @bzzvfs_register()
%8 = load i64, i64* @SQLITE_OK
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %19
11: ; preds = %2
%12 = call i32 @bzzvfs_debug(i32 1)
%13 = call i32* @sqlite3_vfs_find(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %3
br label %19
17: ; preds = %11
%18 = call i32 @bzzvfs_open(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %3
br label %19
19: ; preds = %17, %16, %10
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@SQLITE_OK = global i64 0
@.str = [4 x i8] c"bzz\00"
@.str.1 = [65 x i8] c"abcdef0123456789abcdef1234567890abcdef1234567890abcdef1234568790\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @bzzvfs_register()
%4 = load i64, i64* @SQLITE_OK
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = tail call i32 @bzzvfs_debug(i32 1)
%8 = tail call i32* @sqlite3_vfs_find(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @bzzvfs_open(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6, %2
%13 = phi i32 [ 1, %2 ], [ %11, %10 ], [ 1, %6 ]
ret i32 %13
}