#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 Bank_Transfer(int /*<<< orphan*/, int, int, char const *);
int /*<<< orphan*/ Log_Info(char *, int, char *, char *, int /*<<< orphan*/,
                            char const *);
int /*<<< orphan*/ free(char *);
int DispenseAdd(int ActualUser, int User, int Ammount,
                const char *ReasonGiven) {
  int ret;
  char *dstName, *byName;
  ret = Bank_Transfer(Bank_GetAcctByName(">additions", 1), User, Ammount,
                      ReasonGiven);
  if (ret)
    return 2;
  byName = Bank_GetAcctName(ActualUser);
  dstName = Bank_GetAcctName(User);
  Log_Info("add %i to %s by %s [balance %i] - %s", Ammount, dstName, byName,
           Bank_GetBalance(User), ReasonGiven);
  free(byName);
  free(dstName);
  return 0;
}


x86 assembly (clang, -O0):
<DispenseAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x1,%esi
call   1080 <Bank_GetAcctByName@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <Bank_Transfer@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b0 <DispenseAdd+0x50>
movl   $0x2,-0x4(%rbp)
jmp    121d <DispenseAdd+0xbd>
mov    -0x8(%rbp),%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <Bank_GetBalance@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    %eax,%r8d
mov    -0x18(%rbp),%r9
lea    0xe0c(%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):
<DispenseAdd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r15d
lea    0xe87(%rip),%rdi
mov    $0x1,%esi
call   1080 <Bank_GetAcctByName@plt>
mov    %eax,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <Bank_Transfer@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    11e4 <DispenseAdd+0x84>
mov    %r15d,%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1060 <Bank_GetBalance@plt>
lea    0xe4c(%rip),%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %eax,%r8d
mov    %r14,%r9
call   1070 <Log_Info@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c">additions\00"
@.str.1 = [37 x i8] c"add %i to %s by %s [balance %i] - %s\00"
define i32 @DispenseAdd(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 = call i32 @Bank_GetAcctByName(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %9
%17 = call i32 @Bank_Transfer(i32 %13, i32 %14, i32 %15, i8* %16)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %4
store i32 2, i32* %5
br label %37
21: ; preds = %4
%22 = load i32, i32* %6
%23 = call i8* @Bank_GetAcctName(i32 %22)
store i8* %23, i8** %12
%24 = load i32, i32* %7
%25 = call i8* @Bank_GetAcctName(i32 %24)
store i8* %25, i8** %11
%26 = load i32, i32* %8
%27 = load i8*, i8** %11
%28 = load i8*, i8** %12
%29 = load i32, i32* %7
%30 = call i32 @Bank_GetBalance(i32 %29)
%31 = load i8*, i8** %9
%32 = call i32 @Log_Info(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27, i8* %28, i32 %30, i8* %31)
%33 = load i8*, i8** %12
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %11
%36 = call i32 @free(i8* %35)
store i32 0, i32* %5
br label %37
37: ; preds = %21, %20
%38 = load i32, i32* %5
ret i32 %38
}

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