#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 **safeMatrixAlloc(int, int);
double **hypercycleAlloc(int n) {
  int i;
  double **a = safeMatrixAlloc(n, n);
  for (i = 0; i < n; i++) {
    a[i][(i + 1) % n] = 1.0;
  }
  return a;
}


x86 assembly (clang, -O0):
<hypercycleAlloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <safeMatrixAlloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1179 <hypercycleAlloc+0x69>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x4(%rbp)
mov    -0x18(%rbp),%rax
movslq %edx,%rcx
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1131 <hypercycleAlloc+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypercycleAlloc>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%esi
call   1030 <safeMatrixAlloc@plt>
test   %ebx,%ebx
jle    11a0 <hypercycleAlloc+0x90>
mov    %ebx,%r8d
movabs $0x3ff0000000000000,%r9
cmp    $0x1,%ebx
jne    1137 <hypercycleAlloc+0x27>
xor    %ebx,%ebx
jmp    1183 <hypercycleAlloc+0x73>
mov    %r8d,%r11d
and    $0xfffffffe,%r11d
lea    -0x1(%r8),%r10
lea    -0x2(%r8),%r14
xor    %ecx,%ecx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
mov    (%rax,%rdx,8),%rdi
lea    0x1(%rdx),%esi
cmp    %rdx,%r10
cmove  %rcx,%rsi
mov    %r9,(%rdi,%rsi,8)
mov    0x8(%rax,%rdx,8),%rsi
lea    0x2(%rdx),%rbx
mov    %ebx,%edi
and    $0xfffffffe,%edi
cmp    %rdx,%r14
cmove  %rcx,%rdi
mov    %r9,(%rsi,%rdi,8)
mov    %rbx,%rdx
cmp    %rbx,%r11
jne    1150 <hypercycleAlloc+0x40>
test   $0x1,%r8b
je     11a0 <hypercycleAlloc+0x90>
mov    (%rax,%rbx,8),%rcx
add    $0x1,%rbx
xor    %edx,%edx
cmp    %r8,%rbx
mov    %ebx,%esi
cmovne %rsi,%rdx
mov    %r9,(%rcx,%rdx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define double** @hypercycleAlloc(i32 %0) {
%2 = tail call double** @safeMatrixAlloc(i32 %0, i32 %0)
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %40
4: ; preds = %1
%5 = zext i32 %0 to i64
%6 = and i64 %5, 1
%7 = icmp eq i32 %0, 1
br i1 %7, label %29, label %8
8: ; preds = %4
%9 = and i64 %5, 4294967294
br label %10
10: ; preds = %10, %8
%11 = phi i64 [ 0, %8 ], [ %22, %10 ]
%12 = phi i64 [ 0, %8 ], [ %27, %10 ]
%13 = getelementptr inbounds double*, double** %2, i64 %11
%14 = load double*, double** %13
%15 = or i64 %11, 1
%16 = icmp eq i64 %15, %5
%17 = and i64 %15, 4294967295
%18 = select i1 %16, i64 0, i64 %17
%19 = getelementptr inbounds double, double* %14, i64 %18
store double 1.000000e+00, double* %19
%20 = getelementptr inbounds double*, double** %2, i64 %15
%21 = load double*, double** %20
%22 = add nuw nsw i64 %11, 2
%23 = icmp eq i64 %22, %5
%24 = and i64 %22, 4294967294
%25 = select i1 %23, i64 0, i64 %24
%26 = getelementptr inbounds double, double* %21, i64 %25
store double 1.000000e+00, double* %26
%27 = add i64 %12, 2
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %10
29: ; preds = %10, %4
%30 = phi i64 [ 0, %4 ], [ %22, %10 ]
%31 = icmp eq i64 %6, 0
br i1 %31, label %40, label %32
32: ; preds = %29
%33 = getelementptr inbounds double*, double** %2, i64 %30
%34 = load double*, double** %33
%35 = add nuw nsw i64 %30, 1
%36 = icmp eq i64 %35, %5
%37 = and i64 %35, 4294967295
%38 = select i1 %36, i64 0, i64 %37
%39 = getelementptr inbounds double, double* %34, i64 %38
store double 1.000000e+00, double* %39
br label %40
40: ; preds = %32, %29, %1
ret double** %2
}