#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*/ free(int *);
int /*<<< orphan*/ printf(char *, char *, char *);
int *safe_malloc(int);
int take_coin(int *, char *);
void take_coin_15_returns_0(int stats[3]) {
  int *coin_buffer;
  int coinval;
  char *message;
  coin_buffer = safe_malloc(sizeof(*coin_buffer) * 8);
  message = "  -Fifteen cent coin...";
  stats[0]++;
  coinval = take_coin(coin_buffer, "15");
  free(coin_buffer);
  if (coinval == 0) {
    printf("%-35s%s", message, "\x1b[32mSuccess\x1b[39m\n");
    stats[1]++;
  } else {
    printf("%-35s%s", message, "\x1b[31mFailure\x1b[39m\n");
    stats[2]++;
    ;
  }
}


x86 assembly (clang, -O0):
<take_coin_15_returns_0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x20,%edi
call   1040 <safe_malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <take_coin@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11bf <take_coin_15_returns_0+0x7f>
mov    -0x20(%rbp),%rsi
lea    0xe7a(%rip),%rdi
lea    0xe7b(%rip),%rdx
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x4(%rax)
jmp    11e3 <take_coin_15_returns_0+0xa3>
mov    -0x20(%rbp),%rsi
lea    0xe51(%rip),%rdi
lea    0xe65(%rip),%rdx
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<take_coin_15_returns_0>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x20,%edi
call   1040 <safe_malloc@plt>
mov    %rax,%rbx
addl   $0x1,(%r14)
lea    0xeb9(%rip),%rsi
mov    %rax,%rdi
call   1060 <take_coin@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
setne  %bl
lea    0xea4(%rip),%rax
lea    0xeb0(%rip),%rdx
cmove  %rax,%rdx
lea    0xe8a(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1050 <printf@plt>
addl   $0x1,0x4(%r14,%rbx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c" -Fifteen cent coin...\00"
@.str.1 = [3 x i8] c"15\00"
@.str.2 = [8 x i8] c"%-35s%s\00"
@.str.3 = [19 x i8] c"\1B[32mSuccess\1B[39m\0A\00"
@.str.4 = [19 x i8] c"\1B[31mFailure\1B[39m\0A\00"
define void @take_coin_15_returns_0(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
store i32* %0, i32** %2
%6 = call i32* @safe_malloc(i32 32)
store i32* %6, i32** %3
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
store i32 %10, i32* %8
%11 = load i32*, i32** %3
%12 = call i32 @take_coin(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %4
%13 = load i32*, i32** %3
%14 = call i32 @free(i32* %13)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %1
%18 = load i8*, i8** %5
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %31
24: ; preds = %1
%25 = load i8*, i8** %5
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32*, i32** %2
%28 = getelementptr inbounds i32, i32* %27, i64 2
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %24, %17
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c" -Fifteen cent coin...\00"
@.str.1 = [3 x i8] c"15\00"
@.str.2 = [8 x i8] c"%-35s%s\00"
@.str.3 = [19 x i8] c"\1B[32mSuccess\1B[39m\0A\00"
@.str.4 = [19 x i8] c"\1B[31mFailure\1B[39m\0A\00"
define void @take_coin_15_returns_0(i32* nocapture %0) {
%2 = tail call i32* @safe_malloc(i32 32)
%3 = load i32, i32* %0
%4 = add nsw i32 %3, 1
store i32 %4, i32* %0
%5 = tail call i32 @take_coin(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @free(i32* %2)
%7 = icmp eq i32 %5, 0
%8 = select i1 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0)
%9 = select i1 %7, i64 1, i64 2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
%11 = getelementptr inbounds i32, i32* %0, i64 %9
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
ret void
}