#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 */
void eye(size_t n, double X[n][n]) {
  size_t i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++)
      X[i][j] = 0;
    X[i][i] = 1;
  }
}


x86 assembly (clang, -O0):
<eye>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11a7 <eye+0xa7>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1171 <eye+0x71>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1132 <eye+0x32>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
movsd  0xe6f(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    111c <eye+0x1c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<eye>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
test   %rdi,%rdi
je     12fd <eye+0x1ed>
lea    0x0(,%rdi,8),%rcx
lea    -0x1(%rdi),%rax
mov    %edi,%edx
and    $0x3,%edx
mov    %rdx,0x38(%rsp)
cmp    $0x3,%rax
mov    %rdi,0x30(%rsp)
mov    %rcx,0x8(%rsp)
jae    1154 <eye+0x44>
xor    %edi,%edi
jmp    12a7 <eye+0x197>
mov    %rdi,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,0x50(%rsp)
mov    %rdi,%rax
shl    $0x4,%rax
mov    %rax,0x20(%rsp)
add    $0x10,%rax
mov    %rax,0x18(%rsp)
shl    $0x5,%rdi
mov    %rdi,0x48(%rsp)
lea    0x20(%rdi),%rax
mov    %rax,0x40(%rsp)
lea    0x8(%rcx),%r13
lea    (%rcx,%rcx,2),%rax
mov    %rax,0x10(%rsp)
lea    (%rcx,%rcx,2),%rdx
add    $0x18,%rdx
xor    %eax,%eax
xor    %ebx,%ebx
mov    %rcx,%r12
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdx,0x58(%rsp)
mov    %r12,0x60(%rsp)
mov    %rax,0x28(%rsp)
mov    %r13,0x68(%rsp)
mov    %rdi,0x70(%rsp)
lea    (%rsi,%rax,1),%rdi
mov    %rsi,%r14
xor    %esi,%esi
mov    0x8(%rsp),%r15
mov    %r15,%rdx
call   1030 <memset@plt>
movabs $0x3ff0000000000000,%rbp
mov    %rbp,(%r14,%rbx,1)
lea    (%r14,%r12,1),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <memset@plt>
mov    %rbp,(%r14,%r13,1)
mov    0x20(%rsp),%r12
lea    (%r14,%r12,1),%rdi
xor    %esi,%esi
mov    %r15,%rdx
mov    %r15,%rbp
call   1030 <memset@plt>
mov    0x18(%rsp),%r13
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r14,%r13,1)
mov    0x10(%rsp),%r15
lea    (%r14,%r15,1),%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1030 <memset@plt>
mov    0x58(%rsp),%rdx
mov    0x70(%rsp),%rdi
mov    %r14,%rsi
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r14,%rdx,1)
add    $0x4,%rdi
mov    0x40(%rsp),%rcx
add    %rcx,%r13
mov    %r13,0x18(%rsp)
mov    0x68(%rsp),%r13
mov    0x48(%rsp),%rax
add    %rax,%r12
mov    %r12,0x20(%rsp)
mov    0x60(%rsp),%r12
add    %rcx,%r13
add    %rax,%r12
add    %rcx,%rdx
add    %rax,%r15
mov    %r15,0x10(%rsp)
add    %rcx,%rbx
add    %rax,0x28(%rsp)
mov    0x28(%rsp),%rax
cmp    %rdi,0x50(%rsp)
jne    11b0 <eye+0xa0>
mov    0x38(%rsp),%r12
test   %r12,%r12
mov    0x8(%rsp),%r15
movabs $0x3ff0000000000000,%r13
mov    0x30(%rsp),%rax
je     12fd <eye+0x1ed>
lea    0x8(%r15),%r14
mov    %rdi,%rbp
imul   %r14,%rbp
add    %rsi,%rbp
imul   %rdi,%rax
lea    (%rsi,%rax,8),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <memset@plt>
mov    %r13,0x0(%rbp)
add    %r14,%rbp
add    %r15,%rbx
add    $0xffffffffffffffff,%r12
jne    12e0 <eye+0x1d0>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @eye(i64 %0, double* %1) {
%3 = alloca i64
%4 = alloca double*
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store double* %1, double** %4
%7 = load i64, i64* %3
%8 = load i64, i64* %3
store i64 0, i64* %5
br label %9
9: ; preds = %35, %2
%10 = load i64, i64* %5
%11 = load i64, i64* %3
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
store i64 0, i64* %6
br label %14
14: ; preds = %25, %13
%15 = load i64, i64* %6
%16 = load i64, i64* %3
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load double*, double** %4
%20 = load i64, i64* %5
%21 = mul nsw i64 %20, %8
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load i64, i64* %6
%24 = getelementptr inbounds double, double* %22, i64 %23
store double 0.000000e+00, double* %24
br label %25
25: ; preds = %18
%26 = load i64, i64* %6
%27 = add i64 %26, 1
store i64 %27, i64* %6
br label %14
28: ; preds = %14
%29 = load double*, double** %4
%30 = load i64, i64* %5
%31 = mul nsw i64 %30, %8
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load i64, i64* %5
%34 = getelementptr inbounds double, double* %32, i64 %33
store double 1.000000e+00, double* %34
br label %35
35: ; preds = %28
%36 = load i64, i64* %5
%37 = add i64 %36, 1
store i64 %37, i64* %5
br label %9
38: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @eye(i64 %0, double* nocapture writeonly %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %49, label %4
4: ; preds = %2
%5 = shl nuw i64 %0, 3
%6 = add i64 %0, -1
%7 = and i64 %0, 3
%8 = icmp ult i64 %6, 3
br i1 %8, label %36, label %9
9: ; preds = %4
%10 = and i64 %0, -4
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %33, %11 ]
%13 = phi i64 [ 0, %9 ], [ %34, %11 ]
%14 = mul i64 %12, %0
%15 = getelementptr double, double* %1, i64 %14
%16 = bitcast double* %15 to i8*
%17 = getelementptr inbounds double, double* %15, i64 %12
store double 1.000000e+00, double* %17
%18 = or i64 %12, 1
%19 = mul i64 %18, %0
%20 = getelementptr double, double* %1, i64 %19
%21 = bitcast double* %20 to i8*
%22 = getelementptr inbounds double, double* %20, i64 %18
store double 1.000000e+00, double* %22
%23 = or i64 %12, 2
%24 = mul i64 %23, %0
%25 = getelementptr double, double* %1, i64 %24
%26 = bitcast double* %25 to i8*
%27 = getelementptr inbounds double, double* %25, i64 %23
store double 1.000000e+00, double* %27
%28 = or i64 %12, 3
%29 = mul i64 %28, %0
%30 = getelementptr double, double* %1, i64 %29
%31 = bitcast double* %30 to i8*
%32 = getelementptr inbounds double, double* %30, i64 %28
store double 1.000000e+00, double* %32
%33 = add nuw i64 %12, 4
%34 = add i64 %13, 4
%35 = icmp eq i64 %34, %10
br i1 %35, label %36, label %11
36: ; preds = %11, %4
%37 = phi i64 [ 0, %4 ], [ %33, %11 ]
%38 = icmp eq i64 %7, 0
br i1 %38, label %49, label %39
39: ; preds = %36, %39
%40 = phi i64 [ %46, %39 ], [ %37, %36 ]
%41 = phi i64 [ %47, %39 ], [ 0, %36 ]
%42 = mul i64 %40, %0
%43 = getelementptr double, double* %1, i64 %42
%44 = bitcast double* %43 to i8*
%45 = getelementptr inbounds double, double* %43, i64 %40
store double 1.000000e+00, double* %45
%46 = add nuw i64 %40, 1
%47 = add i64 %41, 1
%48 = icmp eq i64 %47, %7
br i1 %48, label %49, label %39
49: ; preds = %36, %39, %2
ret void
}