#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 Constraint {
  int dummy;
};

/* Variables and functions */
int ConstrntLen(struct Constraint **);
struct Constraint *CopyConstraint(struct Constraint *);
struct Constraint **calloc(int, int);
struct Constraint **CopyConstraintBnds(struct Constraint **Constrnt) {
  int Size = ConstrntLen(Constrnt);
  struct Constraint **New = calloc(Size + 1, sizeof(struct Constraint *));
  int i;
  for (i = 0; i < Size; ++i)
    New[i] = CopyConstraint(Constrnt[i]);
  New[i] = NULL;
  return New;
}


x86 assembly (clang, -O0):
<CopyConstraintBnds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ConstrntLen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <CopyConstraintBnds+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <CopyConstraint@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <CopyConstraintBnds+0x33>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyConstraintBnds>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <ConstrntLen@plt>
mov    %eax,%r15d
lea    0x1(%r15),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    1178 <CopyConstraintBnds+0x48>
mov    %r15d,%r15d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rdi
call   1050 <CopyConstraint@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <CopyConstraintBnds+0x30>
jmp    117b <CopyConstraintBnds+0x4b>
xor    %r15d,%r15d
movq   $0x0,(%r12,%r15,8)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Constraint = type { i32 }
define %struct.Constraint** @CopyConstraintBnds(%struct.Constraint** %0) {
%2 = alloca %struct.Constraint**
%3 = alloca i32
%4 = alloca %struct.Constraint**
%5 = alloca i32
store %struct.Constraint** %0, %struct.Constraint*** %2
%6 = load %struct.Constraint**, %struct.Constraint*** %2
%7 = call i32 @ConstrntLen(%struct.Constraint** %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = call %struct.Constraint** @calloc(i32 %9, i32 8)
store %struct.Constraint** %10, %struct.Constraint*** %4
store i32 0, i32* %5
br label %11
11: ; preds = %26, %1
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load %struct.Constraint**, %struct.Constraint*** %2
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %16, i64 %18
%20 = load %struct.Constraint*, %struct.Constraint** %19
%21 = call %struct.Constraint* @CopyConstraint(%struct.Constraint* %20)
%22 = load %struct.Constraint**, %struct.Constraint*** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %22, i64 %24
store %struct.Constraint* %21, %struct.Constraint** %25
br label %26
26: ; preds = %15
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %11
29: ; preds = %11
%30 = load %struct.Constraint**, %struct.Constraint*** %4
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %30, i64 %32
store %struct.Constraint* null, %struct.Constraint** %33
%34 = load %struct.Constraint**, %struct.Constraint*** %4
ret %struct.Constraint** %34
}

LLVM IR (-O2):
%struct.Constraint = type { i32 }
define noalias %struct.Constraint** @CopyConstraintBnds(%struct.Constraint** %0) {
%2 = tail call i32 @ConstrntLen(%struct.Constraint** %0)
%3 = add nsw i32 %2, 1
%4 = tail call %struct.Constraint** @calloc(i32 %3, i32 8)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %0, i64 %9
%11 = load %struct.Constraint*, %struct.Constraint** %10
%12 = tail call %struct.Constraint* @CopyConstraint(%struct.Constraint* %11)
%13 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %4, i64 %9
store %struct.Constraint* %12, %struct.Constraint** %13
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = zext i32 %2 to i64
br label %18
18: ; preds = %1, %16
%19 = phi i64 [ %17, %16 ], [ 0, %1 ]
%20 = getelementptr inbounds %struct.Constraint*, %struct.Constraint** %4, i64 %19
store %struct.Constraint* null, %struct.Constraint** %20
ret %struct.Constraint** %4
}