#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 **new_matrix2(int, int);
double **new_identity_matrix2(int n) {
  double **mat = new_matrix2(n, n);
  int i;
  for (i = 0; i < n; ++i)
    mat[i][i] = 1;
  return mat;
}


x86 assembly (clang, -O0):
<new_identity_matrix2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <new_matrix2@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1168 <new_identity_matrix2+0x58>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <new_identity_matrix2+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_identity_matrix2>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%esi
call   1030 <new_matrix2@plt>
test   %ebx,%ebx
jle    11a2 <new_identity_matrix2+0x92>
mov    %ebx,%edi
lea    -0x1(%rdi),%rsi
mov    %edi,%ecx
and    $0x3,%ecx
movabs $0x3ff0000000000000,%rdx
cmp    $0x3,%rsi
jae    1141 <new_identity_matrix2+0x31>
xor    %esi,%esi
jmp    117f <new_identity_matrix2+0x6f>
and    $0xfffffffc,%edi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
mov    (%rax,%rsi,8),%rbx
mov    %rdx,(%rbx,%rsi,8)
mov    0x8(%rax,%rsi,8),%rbx
mov    %rdx,0x8(%rbx,%rsi,8)
mov    0x10(%rax,%rsi,8),%rbx
mov    %rdx,0x10(%rbx,%rsi,8)
mov    0x18(%rax,%rsi,8),%rbx
mov    %rdx,0x18(%rbx,%rsi,8)
add    $0x4,%rsi
cmp    %rsi,%rdi
jne    1150 <new_identity_matrix2+0x40>
test   %rcx,%rcx
je     11a2 <new_identity_matrix2+0x92>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rax,%rsi,8),%rdi
mov    %rdx,(%rdi,%rsi,8)
add    $0x1,%rsi
add    $0xffffffffffffffff,%rcx
jne    1190 <new_identity_matrix2+0x80>
pop    %rbx
ret

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

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