#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 */

/* Variables and functions */
int /*<<< orphan*/ bs_xsb_next(char **, char *);
int /*<<< orphan*/ bs_xsb_query_begin(char const *, char **, char *);
int /*<<< orphan*/ bs_xsb_query_end();
int /*<<< orphan*/ printf(char *, char const *);
void do_flora(const char *q) {
  char *x;
  printf("\n\n\n***********************\n %s\n", q);
  bs_xsb_query_begin(q, &x, " ");
  do {
    printf("> %s\n", x);
    bs_xsb_next(&x, " ");
  } while (x);
  bs_xsb_query_end();
}


x86 assembly (clang, -O0):
<do_flora>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdx
call   1040 <bs_xsb_query_begin@plt>
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <bs_xsb_next@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1170 <do_flora+0x30>
mov    $0x0,%al
call   1060 <bs_xsb_query_end@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_flora>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xebe(%rip),%r14
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <bs_xsb_query_begin@plt>
mov    0x8(%rsp),%rsi
lea    0xea1(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <bs_xsb_next@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
jne    1190 <do_flora+0x50>
xor    %eax,%eax
call   1060 <bs_xsb_query_end@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0A\0A\0A***********************\0A %s\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"> %s\0A\00"
define void @do_flora(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %2
%7 = call i32 @bs_xsb_query_begin(i8* %6, i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %12, %1
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = call i32 @bs_xsb_next(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %8, label %15
15: ; preds = %12
%16 = call i32 (...) @bs_xsb_query_end()
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A\0A\0A***********************\0A %s\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"> %s\0A\00"
define void @do_flora(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @bs_xsb_query_begin(i8* %0, i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %2
br label %7
7: ; preds = %7, %1
%8 = phi i8* [ %11, %7 ], [ %6, %1 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i32 @bs_xsb_next(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = call i32 (...) @bs_xsb_query_end()
ret void
}