#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 */
char *Bank_GetAcctName(int);
int /*<<< orphan*/ Bank_GetBalance(int);
int /*<<< orphan*/ Log_Info(char *, int, char *, char *, char *,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            char const *);
int _Transfer(int, int, int, char const *);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char const *, char *);
int DispenseGive(int ActualUser, int SrcUser, int DestUser, int Ammount,
                 const char *ReasonGiven) {
  int ret;
  char *actualUsername;
  char *srcName, *dstName;
  if (strcmp(ReasonGiven, "dead") == 0)
    return 1;
  if (Ammount < 0)
    return 1;
  ret = _Transfer(SrcUser, DestUser, Ammount, ReasonGiven);
  if (ret)
    return 2;
  actualUsername = Bank_GetAcctName(ActualUser);
  srcName = Bank_GetAcctName(SrcUser);
  dstName = Bank_GetAcctName(DestUser);
  Log_Info("give %i from %s to %s by %s [balances %i, %i] - %s", Ammount,
           srcName, dstName, actualUsername, Bank_GetBalance(SrcUser),
           Bank_GetBalance(DestUser), ReasonGiven);
  free(srcName);
  free(dstName);
  free(actualUsername);
  return 0;
}


x86 assembly (clang, -O0):
<DispenseGive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <DispenseGive+0x41>
movl   $0x1,-0x4(%rbp)
jmp    1288 <DispenseGive+0x128>
cmpl   $0x0,-0x14(%rbp)
jge    11b7 <DispenseGive+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1288 <DispenseGive+0x128>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1070 <_Transfer@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11e2 <DispenseGive+0x82>
movl   $0x2,-0x4(%rbp)
jmp    1288 <DispenseGive+0x128>
mov    -0x8(%rbp),%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <Bank_GetBalance@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <Bank_GetBalance@plt>
mov    -0x64(%rbp),%esi
mov    -0x60(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x44(%rbp),%r9d
mov    %eax,%r10d
mov    -0x20(%rbp),%rax
lea    0xdad(%rip),%rdi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1080 <Log_Info@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DispenseGive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xe80(%rip),%rsi
mov    %r8,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %ebp,%ebp
js     122f <DispenseGive+0xcf>
test   %rcx,%rcx
je     122f <DispenseGive+0xcf>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1070 <_Transfer@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    122f <DispenseGive+0xcf>
mov    %r12d,%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,(%rsp)
mov    %r15d,%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,%r13
mov    %r14d,%edi
call   1050 <Bank_GetAcctName@plt>
mov    %rax,%r12
mov    %r15d,%edi
call   1060 <Bank_GetBalance@plt>
mov    %eax,%r15d
mov    %r14d,%edi
call   1060 <Bank_GetBalance@plt>
lea    0xe0d(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    (%rsp),%rbp
mov    %rbp,%r8
mov    %r15d,%r9d
push   %rbx
push   %rax
call   1080 <Log_Info@plt>
add    $0x10,%rsp
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"dead\00"
@.str.1 = [51 x i8] c"give %i from %s to %s by %s [balances %i, %i] - %s\00"
define i32 @DispenseGive(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%16 = load i8*, i8** %11
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %5
store i32 1, i32* %6
br label %56
20: ; preds = %5
%21 = load i32, i32* %10
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %6
br label %56
24: ; preds = %20
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = load i8*, i8** %11
%29 = call i32 @_Transfer(i32 %25, i32 %26, i32 %27, i8* %28)
store i32 %29, i32* %12
%30 = load i32, i32* %12
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %24
store i32 2, i32* %6
br label %56
33: ; preds = %24
%34 = load i32, i32* %7
%35 = call i8* @Bank_GetAcctName(i32 %34)
store i8* %35, i8** %13
%36 = load i32, i32* %8
%37 = call i8* @Bank_GetAcctName(i32 %36)
store i8* %37, i8** %14
%38 = load i32, i32* %9
%39 = call i8* @Bank_GetAcctName(i32 %38)
store i8* %39, i8** %15
%40 = load i32, i32* %10
%41 = load i8*, i8** %14
%42 = load i8*, i8** %15
%43 = load i8*, i8** %13
%44 = load i32, i32* %8
%45 = call i32 @Bank_GetBalance(i32 %44)
%46 = load i32, i32* %9
%47 = call i32 @Bank_GetBalance(i32 %46)
%48 = load i8*, i8** %11
%49 = call i32 @Log_Info(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %40, i8* %41, i8* %42, i8* %43, i32 %45, i32 %47, i8* %48)
%50 = load i8*, i8** %14
%51 = call i32 @free(i8* %50)
%52 = load i8*, i8** %15
%53 = call i32 @free(i8* %52)
%54 = load i8*, i8** %13
%55 = call i32 @free(i8* %54)
store i32 0, i32* %6
br label %56
56: ; preds = %33, %32, %23, %19
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
@.str = [5 x i8] c"dead\00"
@.str.1 = [51 x i8] c"give %i from %s to %s by %s [balances %i, %i] - %s\00"
define i32 @DispenseGive(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = icmp slt i32 %3, 0
%9 = or i1 %8, %7
br i1 %9, label %23, label %10
10: ; preds = %5
%11 = tail call i32 @_Transfer(i32 %1, i32 %2, i32 %3, i8* %4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = tail call i8* @Bank_GetAcctName(i32 %0)
%15 = tail call i8* @Bank_GetAcctName(i32 %1)
%16 = tail call i8* @Bank_GetAcctName(i32 %2)
%17 = tail call i32 @Bank_GetBalance(i32 %1)
%18 = tail call i32 @Bank_GetBalance(i32 %2)
%19 = tail call i32 @Log_Info(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %3, i8* %15, i8* %16, i8* %14, i32 %17, i32 %18, i8* %4)
%20 = tail call i32 @free(i8* %15)
%21 = tail call i32 @free(i8* %16)
%22 = tail call i32 @free(i8* %14)
br label %23
23: ; preds = %10, %5, %13
%24 = phi i32 [ 0, %13 ], [ 1, %5 ], [ 2, %10 ]
ret i32 %24
}