#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*/ Log(int, char *, char *);
int /*<<< orphan*/ assert(char *);
scalar_t__ create_rabbitmq_user(char *);
scalar_t__ create_rabbitmq_vhost(char *);
scalar_t__ grant_rabbitmq_permissions(char *);
int setup_rabbitmq_user(char *username) {
  assert(username);
  if (create_rabbitmq_vhost(username) < 0) {
    Log(1, "Failed to create rabbitmq vhost for amplet2 client %s", username);
    return -1;
  }
  if (create_rabbitmq_user(username) < 0) {
    Log(1, "Failed to create rabbitmq user for amplet2 client %s", username);
    return -1;
  }
  if (grant_rabbitmq_permissions(username) < 0) {
    Log(1, "Failed to grant rabbitmq permissions for amplet2 client %s",
        username);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setup_rabbitmq_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <create_rabbitmq_vhost@plt>
cmp    $0x0,%rax
jge    1199 <setup_rabbitmq_user+0x49>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe78(%rip),%rsi
call   1070 <Log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <setup_rabbitmq_user+0xb8>
mov    -0x10(%rbp),%rdi
call   1040 <create_rabbitmq_user@plt>
cmp    $0x0,%rax
jge    11cd <setup_rabbitmq_user+0x7d>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe7a(%rip),%rsi
call   1070 <Log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <setup_rabbitmq_user+0xb8>
mov    -0x10(%rbp),%rdi
call   1030 <grant_rabbitmq_permissions@plt>
cmp    $0x0,%rax
jge    1201 <setup_rabbitmq_user+0xb1>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe7b(%rip),%rsi
call   1070 <Log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <setup_rabbitmq_user+0xb8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_rabbitmq_user>:
push   %rbx
mov    %rdi,%rbx
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1060 <create_rabbitmq_vhost@plt>
test   %rax,%rax
js     1187 <setup_rabbitmq_user+0x37>
mov    %rbx,%rdi
call   1040 <create_rabbitmq_user@plt>
test   %rax,%rax
js     1190 <setup_rabbitmq_user+0x40>
mov    %rbx,%rdi
call   1030 <grant_rabbitmq_permissions@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1199 <setup_rabbitmq_user+0x49>
pop    %rbx
ret
lea    0xe72(%rip),%rsi
jmp    11a0 <setup_rabbitmq_user+0x50>
lea    0xe9f(%rip),%rsi
jmp    11a0 <setup_rabbitmq_user+0x50>
lea    0xecb(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1070 <Log@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Failed to create rabbitmq vhost for amplet2 client %s\00"
@.str.1 = [53 x i8] c"Failed to create rabbitmq user for amplet2 client %s\00"
@.str.2 = [59 x i8] c"Failed to grant rabbitmq permissions for amplet2 client %s\00"
define i32 @setup_rabbitmq_user(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %3
%7 = call i64 @create_rabbitmq_vhost(i8* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @Log(i32 1, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 -1, i32* %2
br label %27
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @create_rabbitmq_user(i8* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @Log(i32 1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 -1, i32* %2
br label %27
19: ; preds = %12
%20 = load i8*, i8** %3
%21 = call i64 @grant_rabbitmq_permissions(i8* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = call i32 @Log(i32 1, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 -1, i32* %2
br label %27
26: ; preds = %19
store i32 0, i32* %2
br label %27
27: ; preds = %26, %23, %16, %9
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [54 x i8] c"Failed to create rabbitmq vhost for amplet2 client %s\00"
@.str.1 = [53 x i8] c"Failed to create rabbitmq user for amplet2 client %s\00"
@.str.2 = [59 x i8] c"Failed to grant rabbitmq permissions for amplet2 client %s\00"
define i32 @setup_rabbitmq_user(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i64 @create_rabbitmq_vhost(i8* %0)
%4 = icmp slt i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = tail call i64 @create_rabbitmq_user(i8* %0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i64 @grant_rabbitmq_permissions(i8* %0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8, %5, %1
%12 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), %8 ]
%13 = tail call i32 @Log(i32 1, i8* %12, i8* %0)
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ 0, %8 ], [ -1, %11 ]
ret i32 %15
}