#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 /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int *cloneColumns(int *columns) {
  int *cloned = (int *)calloc(sizeof(int), 8);
  if (cloned == NULL) {
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < 8; i++) {
    cloned[i] = columns[i];
  }
  return cloned;
}


x86 assembly (clang, -O0):
<cloneColumns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x4,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <cloneColumns+0x38>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    118d <cloneColumns+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <cloneColumns+0x3f>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cloneColumns>:
push   %rbx
mov    %rdi,%rbx
mov    $0x4,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
test   %rax,%rax
je     1168 <cloneColumns+0x48>
mov    (%rbx),%ecx
mov    %ecx,(%rax)
mov    0x4(%rbx),%ecx
mov    %ecx,0x4(%rax)
mov    0x8(%rbx),%ecx
mov    %ecx,0x8(%rax)
mov    0xc(%rbx),%ecx
mov    %ecx,0xc(%rax)
mov    0x10(%rbx),%ecx
mov    %ecx,0x10(%rax)
mov    0x14(%rbx),%ecx
mov    %ecx,0x14(%rax)
mov    0x18(%rbx),%ecx
mov    %ecx,0x18(%rax)
mov    0x1c(%rbx),%ecx
mov    %ecx,0x1c(%rax)
pop    %rbx
ret
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i32* @cloneColumns(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i64 @calloc(i32 4, i32 8)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
store i32 0, i32* %4
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i32*, i32** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %21, i32* %25
br label %26
26: ; preds = %16
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %13
29: ; preds = %13
%30 = load i32*, i32** %3
ret i32* %30
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define i32* @cloneColumns(i32* nocapture %0) {
%2 = tail call i64 @calloc(i32 4, i32 8)
%3 = inttoptr i64 %2 to i32*
%4 = icmp eq i64 %2, 0
br i1 %4, label %28, label %5
5: ; preds = %1
%6 = load i32, i32* %0
store i32 %6, i32* %3
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %8, i32* %9
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %11, i32* %12
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %14, i32* %15
%16 = getelementptr inbounds i32, i32* %0, i64 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %3, i64 4
store i32 %17, i32* %18
%19 = getelementptr inbounds i32, i32* %0, i64 5
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %3, i64 5
store i32 %20, i32* %21
%22 = getelementptr inbounds i32, i32* %0, i64 6
%23 = load i32, i32* %22
%24 = getelementptr inbounds i32, i32* %3, i64 6
store i32 %23, i32* %24
%25 = getelementptr inbounds i32, i32* %0, i64 7
%26 = load i32, i32* %25
%27 = getelementptr inbounds i32, i32* %3, i64 7
store i32 %26, i32* %27
ret i32* %3
28: ; preds = %1
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
}