#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 release_memory_block(void *);
void *request_memory_block();
int /*<<< orphan*/ rtx_dbug_outs(char *);
void mem_test1() {
  rtx_dbug_outs("Entering mem_test1\r\n");
  void *block = request_memory_block();
  rtx_dbug_outs("Requested Block\r\n");
  int success = release_memory_block(block);
  if (success == 0) {
    rtx_dbug_outs("Release Block Failed\r\n");
  } else {
    rtx_dbug_outs("Release Block Success!\r\n");
  }
}


x86 assembly (clang, -O0):
<mem_test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    $0x0,%al
call   1040 <request_memory_block@plt>
mov    %rax,-0x8(%rbp)
lea    0xebf(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    -0x8(%rbp),%rdi
call   1050 <release_memory_block@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1182 <mem_test1+0x52>
lea    0xeaf(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
jmp    118e <mem_test1+0x5e>
lea    0xeb5(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_test1>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
xor    %eax,%eax
call   1040 <request_memory_block@plt>
mov    %rax,%rbx
lea    0xec7(%rip),%rdi
call   1030 <rtx_dbug_outs@plt>
mov    %rbx,%rdi
call   1050 <release_memory_block@plt>
test   %eax,%eax
lea    0xec3(%rip),%rax
lea    0xed3(%rip),%rdi
cmove  %rax,%rdi
pop    %rbx
jmp    1030 <rtx_dbug_outs@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Entering mem_test1\0D\0A\00"
@.str.1 = [18 x i8] c"Requested Block\0D\0A\00"
@.str.2 = [23 x i8] c"Release Block Failed\0D\0A\00"
@.str.3 = [25 x i8] c"Release Block Success!\0D\0A\00"
define void @mem_test1() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i8* (...) @request_memory_block()
store i8* %4, i8** %1
%5 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = call i32 @release_memory_block(i8* %6)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Entering mem_test1\0D\0A\00"
@.str.1 = [18 x i8] c"Requested Block\0D\0A\00"
@.str.2 = [23 x i8] c"Release Block Failed\0D\0A\00"
@.str.3 = [25 x i8] c"Release Block Success!\0D\0A\00"
define void @mem_test1() {
%1 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* (...) @request_memory_block()
%3 = tail call i32 @rtx_dbug_outs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @release_memory_block(i8* %2)
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0)
%7 = tail call i32 @rtx_dbug_outs(i8* %6)
ret void
}