#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 */
int fmin(int, int);
void LUCroutInplaceDecompose(int n, double *A) {
  int i, j, k;
  double soma, w;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      soma = A[i * n + j];
      for (k = 0; k < fmin(i, j); k++) {
        soma -= A[i * n + k] * A[k * n + j];
      }
      if (j > i) {
        w = A[i * n + i];
        soma /= w;
      }
      A[i * n + j] = soma;
    }
  }
}


x86 assembly (clang, -O0):
<LUCroutInplaceDecompose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125e <LUCroutInplaceDecompose+0x14e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124b <LUCroutInplaceDecompose+0x13b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <fmin@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    11e8 <LUCroutInplaceDecompose+0xd8>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <LUCroutInplaceDecompose+0x57>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1222 <LUCroutInplaceDecompose+0x112>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <LUCroutInplaceDecompose+0x29>
jmp    1250 <LUCroutInplaceDecompose+0x140>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <LUCroutInplaceDecompose+0x16>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LUCroutInplaceDecompose>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %edi,%edi
jle    124c <LUCroutInplaceDecompose+0x13c>
mov    %edi,%eax
lea    0x0(,%rax,8),%r13
xor    %r15d,%r15d
mov    %rsi,%rbp
mov    %rsi,0x10(%rsp)
mov    %rax,0x8(%rsp)
jmp    1160 <LUCroutInplaceDecompose+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15
add    %r13,%rbp
cmp    %rax,%r15
je     124c <LUCroutInplaceDecompose+0x13c>
mov    %r15,%rcx
imul   %rax,%rcx
mov    %rcx,%rdx
mov    %rcx,0x30(%rsp)
add    %r15,%rcx
mov    %rcx,0x28(%rsp)
mov    %rsi,%r14
xor    %ebx,%ebx
jmp    11b0 <LUCroutInplaceDecompose+0xa0>
xchg   %ax,%ax
mov    0x10(%rsp),%rsi
mov    0x28(%rsp),%rax
divsd  (%rsi,%rax,8),%xmm0
mov    0x8(%rsp),%rax
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%rcx
movsd  %xmm0,(%rsi,%rcx,8)
add    $0x1,%rbx
add    $0x8,%r14
cmp    %rax,%rbx
je     1150 <LUCroutInplaceDecompose+0x40>
mov    0x30(%rsp),%rax
lea    (%rbx,%rax,1),%r12
movsd  (%rsi,%r12,8),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15d,%edi
mov    %ebx,%esi
call   1030 <fmin@plt>
test   %eax,%eax
mov    %r14,0x20(%rsp)
mov    %r12,0x18(%rsp)
jle    1230 <LUCroutInplaceDecompose+0x120>
xor    %r12d,%r12d
movsd  (%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x0(%rbp,%r12,8),%xmm0
mulsd  (%r14),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%r12
mov    %r15d,%edi
mov    %ebx,%esi
call   1030 <fmin@plt>
movsd  (%rsp),%xmm1
cltq
add    %r13,%r14
cmp    %rax,%r12
jl     11f0 <LUCroutInplaceDecompose+0xe0>
jmp    1235 <LUCroutInplaceDecompose+0x125>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm0
cmp    %r15,%rbx
ja     1180 <LUCroutInplaceDecompose+0x70>
mov    0x10(%rsp),%rsi
jmp    118f <LUCroutInplaceDecompose+0x7f>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LUCroutInplaceDecompose(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
store i32 0, i32* %5
br label %10
10: ; preds = %91, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %94
14: ; preds = %10
store i32 0, i32* %6
br label %15
15: ; preds = %87, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %90
19: ; preds = %15
%20 = load double*, double** %4
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %20, i64 %26
%28 = load double, double* %27
store double %28, double* %8
store i32 0, i32* %7
br label %29
29: ; preds = %57, %19
%30 = load i32, i32* %7
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = call i32 @fmin(i32 %31, i32 %32)
%34 = icmp slt i32 %30, %33
br i1 %34, label %35, label %60
35: ; preds = %29
%36 = load double*, double** %4
%37 = load i32, i32* %5
%38 = load i32, i32* %3
%39 = mul nsw i32 %37, %38
%40 = load i32, i32* %7
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %36, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %4
%46 = load i32, i32* %7
%47 = load i32, i32* %3
%48 = mul nsw i32 %46, %47
%49 = load i32, i32* %6
%50 = add nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %45, i64 %51
%53 = load double, double* %52
%54 = load double, double* %8
%55 = fneg double %44
%56 = call double @llvm.fmuladd.f64(double %55, double %53, double %54)
store double %56, double* %8
br label %57
57: ; preds = %35
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %29
60: ; preds = %29
%61 = load i32, i32* %6
%62 = load i32, i32* %5
%63 = icmp sgt i32 %61, %62
br i1 %63, label %64, label %77
64: ; preds = %60
%65 = load double*, double** %4
%66 = load i32, i32* %5
%67 = load i32, i32* %3
%68 = mul nsw i32 %66, %67
%69 = load i32, i32* %5
%70 = add nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %65, i64 %71
%73 = load double, double* %72
store double %73, double* %9
%74 = load double, double* %9
%75 = load double, double* %8
%76 = fdiv double %75, %74
store double %76, double* %8
br label %77
77: ; preds = %64, %60
%78 = load double, double* %8
%79 = load double*, double** %4
%80 = load i32, i32* %5
%81 = load i32, i32* %3
%82 = mul nsw i32 %80, %81
%83 = load i32, i32* %6
%84 = add nsw i32 %82, %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %79, i64 %85
store double %78, double* %86
br label %87
87: ; preds = %77
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %15
90: ; preds = %15
br label %91
91: ; preds = %90
%92 = load i32, i32* %5
%93 = add nsw i32 %92, 1
store i32 %93, i32* %5
br label %10
94: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @LUCroutInplaceDecompose(i32 %0, double* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %50
4: ; preds = %2
%5 = zext i32 %0 to i64
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %47, %4
%8 = phi i64 [ 0, %4 ], [ %48, %47 ]
%9 = mul nsw i64 %8, %5
%10 = add nuw nsw i64 %9, %8
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = trunc i64 %8 to i32
br label %13
13: ; preds = %7, %43
%14 = phi i64 [ 0, %7 ], [ %45, %43 ]
%15 = add nuw nsw i64 %14, %9
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = load double, double* %16
%18 = trunc i64 %14 to i32
%19 = tail call i32 @fmin(i32 %12, i32 %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %37
21: ; preds = %13, %21
%22 = phi i64 [ %33, %21 ], [ 0, %13 ]
%23 = phi double [ %32, %21 ], [ %17, %13 ]
%24 = add nuw nsw i64 %22, %9
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = load double, double* %25
%27 = mul nsw i64 %22, %5
%28 = add nuw nsw i64 %27, %14
%29 = getelementptr inbounds double, double* %1, i64 %28
%30 = load double, double* %29
%31 = fneg double %26
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %23)
%33 = add nuw nsw i64 %22, 1
%34 = tail call i32 @fmin(i32 %12, i32 %18)
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %21, label %37
37: ; preds = %21, %13
%38 = phi double [ %17, %13 ], [ %32, %21 ]
%39 = icmp ugt i64 %14, %8
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load double, double* %11
%42 = fdiv double %38, %41
br label %43
43: ; preds = %40, %37
%44 = phi double [ %42, %40 ], [ %38, %37 ]
store double %44, double* %16
%45 = add nuw nsw i64 %14, 1
%46 = icmp eq i64 %45, %6
br i1 %46, label %47, label %13
47: ; preds = %43
%48 = add nuw nsw i64 %8, 1
%49 = icmp eq i64 %48, %6
br i1 %49, label %50, label %7
50: ; preds = %47, %2
ret void
}