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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int sqlite_get_delegated_addresses(int /*<<< orphan*/ *, char const *);
int sqlite_get_delegated_users(int /*<<< orphan*/ *, char const *);
int sqlite_get_delegated(sqlite3 *db, const char *username) {
  printf("Delegated users:\n");
  int status = sqlite_get_delegated_users(db, username);
  if (status > 0) {
    return status;
  }
  printf("\nDelegated address space:\n");
  return sqlite_get_delegated_addresses(db, username);
}


x86 assembly (clang, -O0):
<sqlite_get_delegated>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <sqlite_get_delegated_users@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1171 <sqlite_get_delegated+0x41>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118d <sqlite_get_delegated+0x5d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <sqlite_get_delegated_addresses@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlite_get_delegated>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <sqlite_get_delegated_users@plt>
test   %eax,%eax
jle    115d <sqlite_get_delegated+0x2d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sqlite_get_delegated_addresses@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Delegated users:\0A\00"
@.str.1 = [27 x i8] c"\0ADelegated address space:\0A\00"
define i32 @sqlite_get_delegated(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = load i32*, i32** %4
%9 = load i8*, i8** %5
%10 = call i32 @sqlite_get_delegated_users(i32* %8, i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* %6
store i32 %14, i32* %3
br label %20
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32*, i32** %4
%18 = load i8*, i8** %5
%19 = call i32 @sqlite_get_delegated_addresses(i32* %17, i8* %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %15, %13
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@str = [17 x i8] c"Delegated users:\00"
@str.2 = [26 x i8] c"\0ADelegated address space:\00"
define i32 @sqlite_get_delegated(i32* %0, i8* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @sqlite_get_delegated_users(i32* %0, i8* %1)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.2, i64 0, i64 0))
%8 = tail call i32 @sqlite_get_delegated_addresses(i32* %0, i8* %1)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ %8, %6 ], [ %4, %2 ]
ret i32 %10
}