#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 */
double *make_dv(int);
double *colvec(double **a, int col, int nrows) {
  double *temp;
  int i;
  temp = make_dv(nrows);
  for (i = 1; i <= nrows; i++)
    temp[i] = a[i][col];
  return temp;
}


x86 assembly (clang, -O0):
<colvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <make_dv@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1171 <colvec+0x61>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1135 <colvec+0x25>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colvec>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%edi
call   1030 <make_dv@plt>
test   %ebp,%ebp
jle    11c7 <colvec+0xb7>
movslq %r14d,%rcx
mov    %ebp,%esi
lea    -0x1(%rsi),%rbp
mov    %esi,%edx
and    $0x3,%edx
mov    $0x1,%edi
cmp    $0x3,%rbp
jb     11a1 <colvec+0x91>
and    $0xfffffffc,%esi
xor    %edi,%edi
nopl   0x0(%rax)
mov    0x8(%rbx,%rdi,8),%rbp
movsd  0x0(%rbp,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdi,8)
mov    0x10(%rbx,%rdi,8),%rbp
movsd  0x0(%rbp,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdi,8)
mov    0x18(%rbx,%rdi,8),%rbp
movsd  0x0(%rbp,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdi,8)
mov    0x20(%rbx,%rdi,8),%rbp
movsd  0x0(%rbp,%rcx,8),%xmm0
movsd  %xmm0,0x20(%rax,%rdi,8)
add    $0x4,%rdi
cmp    %rdi,%rsi
jne    1150 <colvec+0x40>
add    $0x1,%rdi
test   %rdx,%rdx
je     11c7 <colvec+0xb7>
lea    (%rax,%rdi,8),%rsi
lea    (%rbx,%rdi,8),%rdi
xor    %ebp,%ebp
mov    (%rdi,%rbp,8),%rbx
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rsi,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rdx
jne    11b0 <colvec+0xa0>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define double* @colvec(double** nocapture %0, i32 %1, i32 %2) {
%4 = tail call double* @make_dv(i32 %2)
%5 = icmp slt i32 %2, 1
br i1 %5, label %59, label %6
6: ; preds = %3
%7 = sext i32 %1 to i64
%8 = add nuw i32 %2, 1
%9 = zext i32 %8 to i64
%10 = add nsw i64 %9, -1
%11 = add nsw i64 %9, -2
%12 = and i64 %10, 3
%13 = icmp ult i64 %11, 3
br i1 %13, label %45, label %14
14: ; preds = %6
%15 = and i64 %10, -4
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ 1, %14 ], [ %42, %16 ]
%18 = phi i64 [ 0, %14 ], [ %43, %16 ]
%19 = getelementptr inbounds double*, double** %0, i64 %17
%20 = load double*, double** %19
%21 = getelementptr inbounds double, double* %20, i64 %7
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %4, i64 %17
store double %22, double* %23
%24 = add nuw nsw i64 %17, 1
%25 = getelementptr inbounds double*, double** %0, i64 %24
%26 = load double*, double** %25
%27 = getelementptr inbounds double, double* %26, i64 %7
%28 = load double, double* %27
%29 = getelementptr inbounds double, double* %4, i64 %24
store double %28, double* %29
%30 = add nuw nsw i64 %17, 2
%31 = getelementptr inbounds double*, double** %0, i64 %30
%32 = load double*, double** %31
%33 = getelementptr inbounds double, double* %32, i64 %7
%34 = load double, double* %33
%35 = getelementptr inbounds double, double* %4, i64 %30
store double %34, double* %35
%36 = add nuw nsw i64 %17, 3
%37 = getelementptr inbounds double*, double** %0, i64 %36
%38 = load double*, double** %37
%39 = getelementptr inbounds double, double* %38, i64 %7
%40 = load double, double* %39
%41 = getelementptr inbounds double, double* %4, i64 %36
store double %40, double* %41
%42 = add nuw nsw i64 %17, 4
%43 = add i64 %18, 4
%44 = icmp eq i64 %43, %15
br i1 %44, label %45, label %16
45: ; preds = %16, %6
%46 = phi i64 [ 1, %6 ], [ %42, %16 ]
%47 = icmp eq i64 %12, 0
br i1 %47, label %59, label %48
48: ; preds = %45, %48
%49 = phi i64 [ %56, %48 ], [ %46, %45 ]
%50 = phi i64 [ %57, %48 ], [ 0, %45 ]
%51 = getelementptr inbounds double*, double** %0, i64 %49
%52 = load double*, double** %51
%53 = getelementptr inbounds double, double* %52, i64 %7
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %4, i64 %49
store double %54, double* %55
%56 = add nuw nsw i64 %49, 1
%57 = add i64 %50, 1
%58 = icmp eq i64 %57, %12
br i1 %58, label %59, label %48
59: ; preds = %45, %48, %3
ret double* %4
}