#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*/ Bank_GetAcctByName(char *, int);
char *Bank_GetAcctName(int);
int /*<<< orphan*/ Bank_GetBalance(int);
int /*<<< orphan*/ Log_Info(char *, int, char *, char *, int /*<<< orphan*/,
                            char const *);
int _Transfer(int, int /*<<< orphan*/, int, char const *);
int /*<<< orphan*/ free(char *);
int DispenseDonate(int ActualUser, int User, int Ammount,
                   const char *ReasonGiven) {
  int ret;
  char *srcName, *byName;
  if (Ammount < 0)
    return 2;
  ret = _Transfer(User, Bank_GetAcctByName(">donations", 1), Ammount,
                  ReasonGiven);
  if (ret)
    return 2;
  byName = Bank_GetAcctName(ActualUser);
  srcName = Bank_GetAcctName(User);
  Log_Info("donate %i from %s by %s [balance %i] - %s", Ammount, srcName,
           byName, Bank_GetBalance(User), ReasonGiven);
  free(byName);
  free(srcName);
  return 0;
}


x86 assembly (clang, -O0):
<DispenseDonate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    118b <DispenseDonate+0x2b>
movl   $0x2,-0x4(%rbp)
jmp    1239 <DispenseDonate+0xd9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    0xe68(%rip),%rdi
mov    $0x1,%esi
call   1080 <Bank_GetAcctByName@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1060 <_Transfer@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11cc <DispenseDonate+0x6c>
movl   $0x2,-0x4(%rbp)
jmp    1239 <DispenseDonate+0xd9>
mov    -0x8(%rbp),%edi
call   1040 <Bank_GetAcctName@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <Bank_GetAcctName@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <Bank_GetBalance@plt>
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    %eax,%r8d
mov    -0x18(%rbp),%r9
lea    0xdf0(%rip),%rdi
call   1070 <Log_Info@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DispenseDonate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x2,%ebx
test   %edx,%edx
js     11ea <DispenseDonate+0x8a>
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xe7d(%rip),%rdi
mov    $0x1,%esi
call   1080 <Bank_GetAcctByName@plt>
mov    %r15d,%edi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1060 <_Transfer@plt>
test   %eax,%eax
jne    11ea <DispenseDonate+0x8a>
mov    %r12d,%edi
call   1040 <Bank_GetAcctName@plt>
mov    %rax,%r12
mov    %r15d,%edi
call   1040 <Bank_GetAcctName@plt>
mov    %rax,%rbx
mov    %r15d,%edi
call   1050 <Bank_GetBalance@plt>
lea    0xe46(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %eax,%r8d
mov    %r14,%r9
call   1070 <Log_Info@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c">donations\00"
@.str.1 = [42 x i8] c"donate %i from %s by %s [balance %i] - %s\00"
define i32 @DispenseDonate(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 2, i32* %5
br label %41
16: ; preds = %4
%17 = load i32, i32* %7
%18 = call i32 @Bank_GetAcctByName(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%19 = load i32, i32* %8
%20 = load i8*, i8** %9
%21 = call i32 @_Transfer(i32 %17, i32 %18, i32 %19, i8* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 2, i32* %5
br label %41
25: ; preds = %16
%26 = load i32, i32* %6
%27 = call i8* @Bank_GetAcctName(i32 %26)
store i8* %27, i8** %12
%28 = load i32, i32* %7
%29 = call i8* @Bank_GetAcctName(i32 %28)
store i8* %29, i8** %11
%30 = load i32, i32* %8
%31 = load i8*, i8** %11
%32 = load i8*, i8** %12
%33 = load i32, i32* %7
%34 = call i32 @Bank_GetBalance(i32 %33)
%35 = load i8*, i8** %9
%36 = call i32 @Log_Info(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31, i8* %32, i32 %34, i8* %35)
%37 = load i8*, i8** %12
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %11
%40 = call i32 @free(i8* %39)
store i32 0, i32* %5
br label %41
41: ; preds = %25, %24, %15
%42 = load i32, i32* %5
ret i32 %42
}

LLVM IR (-O2):
@.str = [11 x i8] c">donations\00"
@.str.1 = [42 x i8] c"donate %i from %s by %s [balance %i] - %s\00"
define i32 @DispenseDonate(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = tail call i32 @Bank_GetAcctByName(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = tail call i32 @_Transfer(i32 %1, i32 %7, i32 %2, i8* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = tail call i8* @Bank_GetAcctName(i32 %0)
%12 = tail call i8* @Bank_GetAcctName(i32 %1)
%13 = tail call i32 @Bank_GetBalance(i32 %1)
%14 = tail call i32 @Log_Info(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %12, i8* %11, i32 %13, i8* %3)
%15 = tail call i32 @free(i8* %11)
%16 = tail call i32 @free(i8* %12)
br label %17
17: ; preds = %6, %4, %10
%18 = phi i32 [ 0, %10 ], [ 2, %4 ], [ 2, %6 ]
ret i32 %18
}