#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int length;
  scalar_t__ data;
};
typedef scalar_t__ CARD32Ptr;
typedef int /*<<< orphan*/ CARD32;
typedef TYPE_1__ *ARRAY32Ptr;

/* Variables and functions */
int FALSE;
int TRUE;
scalar_t__ Xalloc(int);
int XdmcpAllocARRAY32(ARRAY32Ptr array, int length) {
  CARD32Ptr newData;
  newData = (CARD32Ptr)Xalloc(length * sizeof(CARD32));
  if (!newData)
    return FALSE;
  array->length = length;
  array->data = newData;
  return TRUE;
}


x86 assembly (clang, -O0):
<XdmcpAllocARRAY32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <Xalloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    114e <XdmcpAllocARRAY32+0x3e>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    116f <XdmcpAllocARRAY32+0x5f>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XdmcpAllocARRAY32>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x0(,%rbx,4),%edi
call   1030 <Xalloc@plt>
test   %rax,%rax
je     113a <XdmcpAllocARRAY32+0x2a>
mov    %ebx,(%r14)
mov    %rax,0x8(%r14)
mov    0x2eb0(%rip),%rax
jmp    1141 <XdmcpAllocARRAY32+0x31>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpAllocARRAY32(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
%6 = alloca i64
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 4
%10 = trunc i64 %9 to i32
%11 = call i64 @Xalloc(i32 %10)
store i64 %11, i64* %6
%12 = load i64, i64* %6
%13 = icmp ne i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = load i32, i32* @FALSE
store i32 %15, i32* %3
br label %24
16: ; preds = %2
%17 = load i32, i32* %5
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
store i32 %17, i32* %19
%20 = load i64, i64* %6
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 1
store i64 %20, i64* %22
%23 = load i32, i32* @TRUE
store i32 %23, i32* %3
br label %24
24: ; preds = %16, %14
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64 }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpAllocARRAY32(%struct.TYPE_3__* nocapture writeonly %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = tail call i64 @Xalloc(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i32 %1, i32* %7
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
store i64 %4, i64* %8
br label %9
9: ; preds = %2, %6
%10 = phi i32* [ @TRUE, %6 ], [ @FALSE, %2 ]
%11 = load i32, i32* %10
ret i32 %11
}