#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_empty_returns_neg1(int stats[3]) {
  int *coin_buffer;
  int coinval;
  char *message;
  coin_buffer = safe_malloc(sizeof(*coin_buffer) * 8);
  message = "  -Empty string (abort signal)...";
  stats[0]++;
  coinval = take_coin(coin_buffer, "");
  free(coin_buffer);
  if (coinval == -1) {
    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_empty_returns_neg1>:
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    0xed4(%rip),%rsi
call   1060 <take_coin@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11bf <take_coin_empty_returns_neg1+0x7f>
mov    -0x20(%rbp),%rsi
lea    0xe81(%rip),%rdi
lea    0xe82(%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_empty_returns_neg1+0xa3>
mov    -0x20(%rbp),%rsi
lea    0xe58(%rip),%rdi
lea    0xe6c(%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_empty_returns_neg1>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x20,%edi
call   1040 <safe_malloc@plt>
mov    %rax,%rbx
addl   $0x1,(%r14)
lea    0xef0(%rip),%rsi
mov    %rax,%rdi
call   1060 <take_coin@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%ebp
setne  %bl
lea    0xeaa(%rip),%rax
lea    0xeb6(%rip),%rdx
cmove  %rax,%rdx
lea    0xe90(%rip),%rdi
lea    0xe67(%rip),%rsi
call   1050 <printf@plt>
addl   $0x1,0x4(%r14,%rbx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c" -Empty string (abort signal)...\00"
@.str.1 = [1 x i8] zeroinitializer
@.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_empty_returns_neg1(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 ([34 x i8], [34 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 ([1 x i8], [1 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, -1
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 = [34 x i8] c" -Empty string (abort signal)...\00"
@.str.1 = [1 x i8] zeroinitializer
@.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_empty_returns_neg1(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 ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @free(i32* %2)
%7 = icmp eq i32 %5, -1
%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 ([34 x i8], [34 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
}