#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 *smalloc(int);
void genvals2d(double **xvecs, double *vals[4][8], int nvtxs) {
  int nlists = 4;
  double *temp[4];
  int i;
  for (i = 0; i < nlists; i++) {
    temp[i] = smalloc(nvtxs * sizeof(double));
  }
  for (i = 1; i <= nvtxs; i++) {
    temp[0][i - 1] = 4 * xvecs[1][i];
    temp[1][i - 1] = 4 * xvecs[2][i];
    temp[2][i - 1] = 4 * (xvecs[1][i] + xvecs[2][i]);
    temp[3][i - 1] = 4 * (xvecs[2][i] - xvecs[1][i]);
  }
  vals[0][1] = vals[1][0] = vals[2][3] = vals[3][2] = temp[0];
  vals[0][2] = vals[2][0] = vals[1][3] = vals[3][1] = temp[1];
  vals[0][3] = vals[3][0] = temp[2];
  vals[1][2] = vals[2][1] = temp[3];
}


x86 assembly (clang, -O0):
<genvals2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1166 <genvals2d+0x56>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <smalloc@plt>
mov    %rax,%rcx
movslq -0x44(%rbp),%rax
mov    %rcx,-0x40(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1131 <genvals2d+0x21>
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     125d <genvals2d+0x14d>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe73(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe48(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x44(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm1
movsd  0xe07(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
movsd  0xdc7(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    116d <genvals2d+0x5d>
mov    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0xd0(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x98(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x40(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0xc8(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x58(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x80(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0xc0(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x88(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x50(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genvals2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,(%rsp)
lea    0x0(,%r13,8),%ebp
mov    %ebp,%edi
call   1030 <smalloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1030 <smalloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1030 <smalloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   1030 <smalloc@plt>
test   %r13d,%r13d
jle    11d3 <genvals2d+0xc3>
mov    (%rsp),%rdx
mov    0x8(%rdx),%rcx
mov    0x10(%rdx),%rdx
mov    %r13d,%esi
shl    $0x3,%rsi
xor    %edi,%edi
movsd  0xe8c(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x8(%rcx,%rdi,1),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r15,%rdi,1)
movsd  0x8(%rdx,%rdi,1),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rdi,1)
movsd  0x8(%rcx,%rdi,1),%xmm1
addsd  0x8(%rdx,%rdi,1),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rdi,1)
movsd  0x8(%rdx,%rdi,1),%xmm1
subsd  0x8(%rcx,%rdi,1),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rdi,1)
add    $0x8,%rdi
cmp    %rdi,%rsi
jne    1180 <genvals2d+0x70>
mov    %r15,0xd0(%r14)
mov    %r15,0x98(%r14)
mov    %r15,0x40(%r14)
mov    %r15,0x8(%r14)
mov    %rbx,0xc8(%r14)
mov    %rbx,0x58(%r14)
mov    %rbx,0x80(%r14)
mov    %rbx,0x10(%r14)
mov    %r12,0xc0(%r14)
mov    %r12,0x18(%r14)
mov    %rax,0x88(%r14)
mov    %rax,0x50(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @genvals2d(double** %0, [8 x double*]* %1, i32 %2) {
%4 = alloca double**
%5 = alloca [8 x double*]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x double*]
%9 = alloca i32
store double** %0, double*** %4
store [8 x double*]* %1, [8 x double*]** %5
store i32 %2, i32* %6
store i32 4, i32* %7
store i32 0, i32* %9
br label %10
10: ; preds = %23, %3
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call double* @smalloc(i32 %18)
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 %21
store double* %19, double** %22
br label %23
23: ; preds = %14
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %10
26: ; preds = %10
store i32 1, i32* %9
br label %27
27: ; preds = %104, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %107
31: ; preds = %27
%32 = load double**, double*** %4
%33 = getelementptr inbounds double*, double** %32, i64 1
%34 = load double*, double** %33
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fmul double 4.000000e+00, %38
%40 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 0
%41 = load double*, double** %40
%42 = load i32, i32* %9
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %41, i64 %44
store double %39, double* %45
%46 = load double**, double*** %4
%47 = getelementptr inbounds double*, double** %46, i64 2
%48 = load double*, double** %47
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = fmul double 4.000000e+00, %52
%54 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 1
%55 = load double*, double** %54
%56 = load i32, i32* %9
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %55, i64 %58
store double %53, double* %59
%60 = load double**, double*** %4
%61 = getelementptr inbounds double*, double** %60, i64 1
%62 = load double*, double** %61
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double**, double*** %4
%68 = getelementptr inbounds double*, double** %67, i64 2
%69 = load double*, double** %68
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fadd double %66, %73
%75 = fmul double 4.000000e+00, %74
%76 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 2
%77 = load double*, double** %76
%78 = load i32, i32* %9
%79 = sub nsw i32 %78, 1
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %77, i64 %80
store double %75, double* %81
%82 = load double**, double*** %4
%83 = getelementptr inbounds double*, double** %82, i64 2
%84 = load double*, double** %83
%85 = load i32, i32* %9
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = load double**, double*** %4
%90 = getelementptr inbounds double*, double** %89, i64 1
%91 = load double*, double** %90
%92 = load i32, i32* %9
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = fsub double %88, %95
%97 = fmul double 4.000000e+00, %96
%98 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 3
%99 = load double*, double** %98
%100 = load i32, i32* %9
%101 = sub nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %99, i64 %102
store double %97, double* %103
br label %104
104: ; preds = %31
%105 = load i32, i32* %9
%106 = add nsw i32 %105, 1
store i32 %106, i32* %9
br label %27
107: ; preds = %27
%108 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 0
%109 = load double*, double** %108
%110 = load [8 x double*]*, [8 x double*]** %5
%111 = getelementptr inbounds [8 x double*], [8 x double*]* %110, i64 3
%112 = getelementptr inbounds [8 x double*], [8 x double*]* %111, i64 0, i64 2
store double* %109, double** %112
%113 = load [8 x double*]*, [8 x double*]** %5
%114 = getelementptr inbounds [8 x double*], [8 x double*]* %113, i64 2
%115 = getelementptr inbounds [8 x double*], [8 x double*]* %114, i64 0, i64 3
store double* %109, double** %115
%116 = load [8 x double*]*, [8 x double*]** %5
%117 = getelementptr inbounds [8 x double*], [8 x double*]* %116, i64 1
%118 = getelementptr inbounds [8 x double*], [8 x double*]* %117, i64 0, i64 0
store double* %109, double** %118
%119 = load [8 x double*]*, [8 x double*]** %5
%120 = getelementptr inbounds [8 x double*], [8 x double*]* %119, i64 0
%121 = getelementptr inbounds [8 x double*], [8 x double*]* %120, i64 0, i64 1
store double* %109, double** %121
%122 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 1
%123 = load double*, double** %122
%124 = load [8 x double*]*, [8 x double*]** %5
%125 = getelementptr inbounds [8 x double*], [8 x double*]* %124, i64 3
%126 = getelementptr inbounds [8 x double*], [8 x double*]* %125, i64 0, i64 1
store double* %123, double** %126
%127 = load [8 x double*]*, [8 x double*]** %5
%128 = getelementptr inbounds [8 x double*], [8 x double*]* %127, i64 1
%129 = getelementptr inbounds [8 x double*], [8 x double*]* %128, i64 0, i64 3
store double* %123, double** %129
%130 = load [8 x double*]*, [8 x double*]** %5
%131 = getelementptr inbounds [8 x double*], [8 x double*]* %130, i64 2
%132 = getelementptr inbounds [8 x double*], [8 x double*]* %131, i64 0, i64 0
store double* %123, double** %132
%133 = load [8 x double*]*, [8 x double*]** %5
%134 = getelementptr inbounds [8 x double*], [8 x double*]* %133, i64 0
%135 = getelementptr inbounds [8 x double*], [8 x double*]* %134, i64 0, i64 2
store double* %123, double** %135
%136 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 2
%137 = load double*, double** %136
%138 = load [8 x double*]*, [8 x double*]** %5
%139 = getelementptr inbounds [8 x double*], [8 x double*]* %138, i64 3
%140 = getelementptr inbounds [8 x double*], [8 x double*]* %139, i64 0, i64 0
store double* %137, double** %140
%141 = load [8 x double*]*, [8 x double*]** %5
%142 = getelementptr inbounds [8 x double*], [8 x double*]* %141, i64 0
%143 = getelementptr inbounds [8 x double*], [8 x double*]* %142, i64 0, i64 3
store double* %137, double** %143
%144 = getelementptr inbounds [4 x double*], [4 x double*]* %8, i64 0, i64 3
%145 = load double*, double** %144
%146 = load [8 x double*]*, [8 x double*]** %5
%147 = getelementptr inbounds [8 x double*], [8 x double*]* %146, i64 2
%148 = getelementptr inbounds [8 x double*], [8 x double*]* %147, i64 0, i64 1
store double* %145, double** %148
%149 = load [8 x double*]*, [8 x double*]** %5
%150 = getelementptr inbounds [8 x double*], [8 x double*]* %149, i64 1
%151 = getelementptr inbounds [8 x double*], [8 x double*]* %150, i64 0, i64 2
store double* %145, double** %151
ret void
}

LLVM IR (-O2):
define void @genvals2d(double** nocapture %0, [8 x double*]* nocapture writeonly %1, i32 %2) {
%4 = shl i32 %2, 3
%5 = tail call double* @smalloc(i32 %4)
%6 = tail call double* @smalloc(i32 %4)
%7 = tail call double* @smalloc(i32 %4)
%8 = tail call double* @smalloc(i32 %4)
%9 = icmp slt i32 %2, 1
br i1 %9, label %40, label %10
10: ; preds = %3
%11 = getelementptr inbounds double*, double** %0, i64 1
%12 = load double*, double** %11
%13 = getelementptr inbounds double*, double** %0, i64 2
%14 = load double*, double** %13
%15 = add nuw i32 %2, 1
%16 = zext i32 %15 to i64
br label %17
17: ; preds = %10, %17
%18 = phi i64 [ 1, %10 ], [ %38, %17 ]
%19 = getelementptr inbounds double, double* %12, i64 %18
%20 = load double, double* %19
%21 = fmul double %20, 4.000000e+00
%22 = add nsw i64 %18, -1
%23 = getelementptr inbounds double, double* %5, i64 %22
store double %21, double* %23
%24 = getelementptr inbounds double, double* %14, i64 %18
%25 = load double, double* %24
%26 = fmul double %25, 4.000000e+00
%27 = getelementptr inbounds double, double* %6, i64 %22
store double %26, double* %27
%28 = load double, double* %19
%29 = load double, double* %24
%30 = fadd double %28, %29
%31 = fmul double %30, 4.000000e+00
%32 = getelementptr inbounds double, double* %7, i64 %22
store double %31, double* %32
%33 = load double, double* %24
%34 = load double, double* %19
%35 = fsub double %33, %34
%36 = fmul double %35, 4.000000e+00
%37 = getelementptr inbounds double, double* %8, i64 %22
store double %36, double* %37
%38 = add nuw nsw i64 %18, 1
%39 = icmp eq i64 %38, %16
br i1 %39, label %40, label %17
40: ; preds = %17, %3
%41 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 3, i64 2
store double* %5, double** %41
%42 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 2, i64 3
store double* %5, double** %42
%43 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 1, i64 0
store double* %5, double** %43
%44 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 0, i64 1
store double* %5, double** %44
%45 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 3, i64 1
store double* %6, double** %45
%46 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 1, i64 3
store double* %6, double** %46
%47 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 2, i64 0
store double* %6, double** %47
%48 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 0, i64 2
store double* %6, double** %48
%49 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 3, i64 0
store double* %7, double** %49
%50 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 0, i64 3
store double* %7, double** %50
%51 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 2, i64 1
store double* %8, double** %51
%52 = getelementptr inbounds [8 x double*], [8 x double*]* %1, i64 1, i64 2
store double* %8, double** %52
ret void
}