#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 */
struct BoolExpr {
  int dummy;
};
struct BX_Array {
  int dummy;
};

/* Variables and functions */
struct BX_Array *_bx_array_from(size_t, struct BoolExpr **);
struct BoolExpr **malloc(size_t);
struct BX_Array *BX_Array_New(size_t length, struct BoolExpr **exprs) {
  struct BoolExpr **exprs_copy;
  exprs_copy = malloc(length * sizeof(struct BoolExpr *));
  if (exprs_copy == NULL)
    return NULL;
  for (size_t i = 0; i < length; ++i)
    exprs_copy[i] = exprs[i];
  return _bx_array_from(length, exprs_copy);
}


x86 assembly (clang, -O0):
<BX_Array_New>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1159 <BX_Array_New+0x39>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <BX_Array_New+0x89>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1198 <BX_Array_New+0x78>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1161 <BX_Array_New+0x41>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <_bx_array_from@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BX_Array_New>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x0(,%rdi,8),%r15
mov    %r15,%rdi
call   1050 <malloc@plt>
test   %rax,%rax
je     117f <BX_Array_New+0x4f>
mov    %rax,%rbx
test   %r12,%r12
je     1169 <BX_Array_New+0x39>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <memcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <_bx_array_from@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.BX_Array = type { i32 }
%struct.BoolExpr = type { i32 }
define %struct.BX_Array* @BX_Array_New(i64 %0, %struct.BoolExpr** %1) {
%3 = alloca %struct.BX_Array*
%4 = alloca i64
%5 = alloca %struct.BoolExpr**
%6 = alloca %struct.BoolExpr**
%7 = alloca i64
store i64 %0, i64* %4
store %struct.BoolExpr** %1, %struct.BoolExpr*** %5
%8 = load i64, i64* %4
%9 = mul i64 %8, 8
%10 = call %struct.BoolExpr** @malloc(i64 %9)
store %struct.BoolExpr** %10, %struct.BoolExpr*** %6
%11 = load %struct.BoolExpr**, %struct.BoolExpr*** %6
%12 = icmp eq %struct.BoolExpr** %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store %struct.BX_Array* null, %struct.BX_Array** %3
br label %34
14: ; preds = %2
store i64 0, i64* %7
br label %15
15: ; preds = %27, %14
%16 = load i64, i64* %7
%17 = load i64, i64* %4
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load %struct.BoolExpr**, %struct.BoolExpr*** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds %struct.BoolExpr*, %struct.BoolExpr** %20, i64 %21
%23 = load %struct.BoolExpr*, %struct.BoolExpr** %22
%24 = load %struct.BoolExpr**, %struct.BoolExpr*** %6
%25 = load i64, i64* %7
%26 = getelementptr inbounds %struct.BoolExpr*, %struct.BoolExpr** %24, i64 %25
store %struct.BoolExpr* %23, %struct.BoolExpr** %26
br label %27
27: ; preds = %19
%28 = load i64, i64* %7
%29 = add i64 %28, 1
store i64 %29, i64* %7
br label %15
30: ; preds = %15
%31 = load i64, i64* %4
%32 = load %struct.BoolExpr**, %struct.BoolExpr*** %6
%33 = call %struct.BX_Array* @_bx_array_from(i64 %31, %struct.BoolExpr** %32)
store %struct.BX_Array* %33, %struct.BX_Array** %3
br label %34
34: ; preds = %30, %13
%35 = load %struct.BX_Array*, %struct.BX_Array** %3
ret %struct.BX_Array* %35
}

LLVM IR (-O2):
%struct.BX_Array = type { i32 }
%struct.BoolExpr = type { i32 }
define %struct.BX_Array* @BX_Array_New(i64 %0, %struct.BoolExpr** nocapture %1) {
%3 = bitcast %struct.BoolExpr** %1 to i8*
%4 = shl i64 %0, 3
%5 = tail call %struct.BoolExpr** @malloc(i64 %4)
%6 = bitcast %struct.BoolExpr** %5 to i8*
%7 = icmp eq %struct.BoolExpr** %5, null
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = icmp eq i64 %0, 0
br i1 %9, label %11, label %10
10: ; preds = %8
br label %11
11: ; preds = %10, %8
%12 = tail call %struct.BX_Array* @_bx_array_from(i64 %0, %struct.BoolExpr** %5)
br label %13
13: ; preds = %2, %11
%14 = phi %struct.BX_Array* [ %12, %11 ], [ null, %2 ]
ret %struct.BX_Array* %14
}