#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 /*<<< orphan*/ LUIterate(double *, int, int, double **, double **);
int /*<<< orphan*/ copy(double *, double **, int, int);
int /*<<< orphan*/ mult(double *, double *, int, int, int, int, double **);
int /*<<< orphan*/ zeros(int, int, double **);
void LUDecomposition(double *matrix, int n, double **Lout, double **Uout) {
  double *Lprod;
  double *Ltemp;
  double *Lprodnew;
  double *A;
  double *A2;
  zeros(n, n, &Ltemp);
  zeros(n, n, &Lprod);
  zeros(n, n, &A);
  zeros(n, n, &A2);
  zeros(n, n, &Lprodnew);
  for (int j = 0; j < n - 1; j++) {
    if (j == 0) {
      LUIterate(matrix, n, 0, &Ltemp, &A2);
      copy(Ltemp, &Lprod, n, n);
    } else {
      LUIterate(A, n, j, &Ltemp, &A2);
      mult(Lprod, Ltemp, n, n, n, n, &Lprodnew);
      copy(Lprodnew, &Lprod, n, n);
    }
    copy(A2, &A, n, n);
  }
  copy(A, Uout, n, n);
  copy(Lprod, Lout, n, n);
}


x86 assembly (clang, -O0):
<LUDecomposition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1060 <zeros@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1060 <zeros@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x40(%rbp),%rdx
call   1060 <zeros@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x48(%rbp),%rdx
call   1060 <zeros@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1060 <zeros@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1260 <LUDecomposition+0x120>
cmpl   $0x0,-0x4c(%rbp)
jne    11f2 <LUDecomposition+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
lea    -0x30(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1030 <LUIterate@plt>
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    -0x28(%rbp),%rsi
call   1040 <copy@plt>
jmp    123f <LUDecomposition+0xff>
mov    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x4c(%rbp),%edx
lea    -0x30(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1030 <LUIterate@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0xc(%rbp),%r9d
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <mult@plt>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    -0x28(%rbp),%rsi
call   1040 <copy@plt>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    -0x40(%rbp),%rsi
call   1040 <copy@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11a9 <LUDecomposition+0x69>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <copy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <copy@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LUDecomposition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x38(%rsp)
mov    %rdx,0x40(%rsp)
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0x20(%rsp),%rdx
mov    %esi,%edi
call   1060 <zeros@plt>
lea    0x28(%rsp),%rdx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <zeros@plt>
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <zeros@plt>
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <zeros@plt>
lea    0x30(%rsp),%rdx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <zeros@plt>
cmp    $0x2,%ebx
jl     128b <LUDecomposition+0x14b>
lea    -0x1(%rbx),%r14d
lea    0x20(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <LUIterate@plt>
mov    0x20(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
mov    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
cmp    $0x1,%r14d
je     128b <LUDecomposition+0x14b>
mov    $0x2,%r13d
sub    %ebx,%r13d
mov    $0x1,%ebp
lea    0x10(%rsp),%r14
lea    0x28(%rsp),%r15
lea    0x18(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
lea    0x20(%rsp),%rcx
mov    %r14,%r8
call   1030 <LUIterate@plt>
mov    0x28(%rsp),%rdi
mov    0x20(%rsp),%rsi
lea    0x30(%rsp),%rax
mov    %rax,(%rsp)
mov    %ebx,%edx
mov    %ebx,%ecx
mov    %ebx,%r8d
mov    %ebx,%r9d
call   1050 <mult@plt>
mov    0x30(%rsp),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
lea    0x1(%r13,%rbp,1),%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1220 <LUDecomposition+0xe0>
mov    0x18(%rsp),%rdi
mov    0x38(%rsp),%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
mov    0x28(%rsp),%rdi
mov    0x40(%rsp),%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <copy@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @LUDecomposition(double* %0, i32 %1, double** %2, double** %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double**
%8 = alloca double**
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double** %2, double*** %7
store double** %3, double*** %8
%15 = load i32, i32* %6
%16 = load i32, i32* %6
%17 = call i32 @zeros(i32 %15, i32 %16, double** %10)
%18 = load i32, i32* %6
%19 = load i32, i32* %6
%20 = call i32 @zeros(i32 %18, i32 %19, double** %9)
%21 = load i32, i32* %6
%22 = load i32, i32* %6
%23 = call i32 @zeros(i32 %21, i32 %22, double** %12)
%24 = load i32, i32* %6
%25 = load i32, i32* %6
%26 = call i32 @zeros(i32 %24, i32 %25, double** %13)
%27 = load i32, i32* %6
%28 = load i32, i32* %6
%29 = call i32 @zeros(i32 %27, i32 %28, double** %11)
store i32 0, i32* %14
br label %30
30: ; preds = %67, %4
%31 = load i32, i32* %14
%32 = load i32, i32* %6
%33 = sub nsw i32 %32, 1
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %70
35: ; preds = %30
%36 = load i32, i32* %14
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load double*, double** %5
%40 = load i32, i32* %6
%41 = call i32 @LUIterate(double* %39, i32 %40, i32 0, double** %10, double** %13)
%42 = load double*, double** %10
%43 = load i32, i32* %6
%44 = load i32, i32* %6
%45 = call i32 @copy(double* %42, double** %9, i32 %43, i32 %44)
br label %62
46: ; preds = %35
%47 = load double*, double** %12
%48 = load i32, i32* %6
%49 = load i32, i32* %14
%50 = call i32 @LUIterate(double* %47, i32 %48, i32 %49, double** %10, double** %13)
%51 = load double*, double** %9
%52 = load double*, double** %10
%53 = load i32, i32* %6
%54 = load i32, i32* %6
%55 = load i32, i32* %6
%56 = load i32, i32* %6
%57 = call i32 @mult(double* %51, double* %52, i32 %53, i32 %54, i32 %55, i32 %56, double** %11)
%58 = load double*, double** %11
%59 = load i32, i32* %6
%60 = load i32, i32* %6
%61 = call i32 @copy(double* %58, double** %9, i32 %59, i32 %60)
br label %62
62: ; preds = %46, %38
%63 = load double*, double** %13
%64 = load i32, i32* %6
%65 = load i32, i32* %6
%66 = call i32 @copy(double* %63, double** %12, i32 %64, i32 %65)
br label %67
67: ; preds = %62
%68 = load i32, i32* %14
%69 = add nsw i32 %68, 1
store i32 %69, i32* %14
br label %30
70: ; preds = %30
%71 = load double*, double** %12
%72 = load double**, double*** %8
%73 = load i32, i32* %6
%74 = load i32, i32* %6
%75 = call i32 @copy(double* %71, double** %72, i32 %73, i32 %74)
%76 = load double*, double** %9
%77 = load double**, double*** %7
%78 = load i32, i32* %6
%79 = load i32, i32* %6
%80 = call i32 @copy(double* %76, double** %77, i32 %78, i32 %79)
ret void
}

LLVM IR (-O2):
define void @LUDecomposition(double* %0, i32 %1, double** %2, double** %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = bitcast double** %5 to i8*
%11 = bitcast double** %6 to i8*
%12 = bitcast double** %7 to i8*
%13 = bitcast double** %8 to i8*
%14 = bitcast double** %9 to i8*
%15 = call i32 @zeros(i32 %1, i32 %1, double** %6)
%16 = call i32 @zeros(i32 %1, i32 %1, double** %5)
%17 = call i32 @zeros(i32 %1, i32 %1, double** %8)
%18 = call i32 @zeros(i32 %1, i32 %1, double** %9)
%19 = call i32 @zeros(i32 %1, i32 %1, double** %7)
%20 = add i32 %1, -1
%21 = icmp sgt i32 %1, 1
br i1 %21, label %22, label %29
22: ; preds = %4
%23 = call i32 @LUIterate(double* %0, i32 %1, i32 0, double** %6, double** %9)
%24 = load double*, double** %6
%25 = call i32 @copy(double* %24, double** %5, i32 %1, i32 %1)
%26 = load double*, double** %9
%27 = call i32 @copy(double* %26, double** %8, i32 %1, i32 %1)
%28 = icmp eq i32 %20, 1
br i1 %28, label %29, label %34
29: ; preds = %34, %22, %4
%30 = load double*, double** %8
%31 = call i32 @copy(double* %30, double** %3, i32 %1, i32 %1)
%32 = load double*, double** %5
%33 = call i32 @copy(double* %32, double** %2, i32 %1, i32 %1)
ret void
34: ; preds = %22, %34
%35 = phi i32 [ %45, %34 ], [ 1, %22 ]
%36 = load double*, double** %8
%37 = call i32 @LUIterate(double* %36, i32 %1, i32 %35, double** %6, double** %9)
%38 = load double*, double** %5
%39 = load double*, double** %6
%40 = call i32 @mult(double* %38, double* %39, i32 %1, i32 %1, i32 %1, i32 %1, double** %7)
%41 = load double*, double** %7
%42 = call i32 @copy(double* %41, double** %5, i32 %1, i32 %1)
%43 = load double*, double** %9
%44 = call i32 @copy(double* %43, double** %8, i32 %1, i32 %1)
%45 = add nuw nsw i32 %35, 1
%46 = icmp eq i32 %45, %20
br i1 %46, label %29, label %34
}