#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 dcAllocWX(int, void **);
int /*<<< orphan*/ dcFreeWX(void *, int);
int /*<<< orphan*/ dcTest_deInitPlatform();
int /*<<< orphan*/ dcTest_initPlatform();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int err;
  void *ptr;
  dcTest_initPlatform();
  err = dcAllocWX(23, &ptr);
  if (!err)
    dcFreeWX(ptr, 23);
  printf("result: test_alloc_wx: %d\n", (!err) ? 1 : 0);
  dcTest_deInitPlatform();
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <dcTest_initPlatform@plt>
mov    $0x17,%edi
lea    -0x10(%rbp),%rsi
call   1030 <dcAllocWX@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118f <main+0x3f>
mov    -0x10(%rbp),%rdi
mov    $0x17,%esi
call   1060 <dcFreeWX@plt>
cmpl   $0x0,-0x8(%rbp)
setne  %cl
xor    $0xff,%cl
xor    %esi,%esi
mov    $0x1,%eax
test   $0x1,%cl
cmovne %eax,%esi
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <dcTest_deInitPlatform@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <dcTest_initPlatform@plt>
lea    0x8(%rsp),%rsi
mov    $0x17,%edi
call   1030 <dcAllocWX@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    1180 <main+0x30>
mov    0x8(%rsp),%rdi
mov    $0x17,%esi
call   1060 <dcFreeWX@plt>
xor    %esi,%esi
test   %ebx,%ebx
sete   %sil
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <dcTest_deInitPlatform@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"result: test_alloc_wx: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 (...) @dcTest_initPlatform()
%5 = call i32 @dcAllocWX(i32 23, i8** %3)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i8*, i8** %3
%10 = call i32 @dcFreeWX(i8* %9, i32 23)
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 1, i32 0
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @dcTest_deInitPlatform()
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [27 x i8] c"result: test_alloc_wx: %d\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (...) @dcTest_initPlatform()
%4 = call i32 @dcAllocWX(i32 23, i8** %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i8*, i8** %1
%8 = call i32 @dcFreeWX(i8* %7, i32 23)
br label %9
9: ; preds = %6, %0
%10 = zext i1 %5 to i32
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (...) @dcTest_deInitPlatform()
ret i32 %4
}