#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*/ free(double *);
double get_time();
int /*<<< orphan*/ lu(int, double *, double *, double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ solve_lx(int, double *, double *, double *);
int /*<<< orphan*/ solve_uy(int, double *, double *, double *);
int /*<<< orphan*/ verify_ls(int, double *, double *, double *);
double solve(int n, double *a, double *var, double *r) {
  int no_error = 1;
  double *l = (double *)malloc(sizeof(double) * (n * n)),
         *u = (double *)malloc(sizeof(double) * (n * n)), r1[n];
  double start, end;
  start = get_time();
  lu(n, a, l, u);
  end = get_time();
  if (no_error) {
    solve_lx(n, l, r1, r);
    if (!verify_ls(n, l, r1, r))
      printf("Error: lx yield not expected value.\n");
    solve_uy(n, u, var, r1);
    if (!verify_ls(n, u, var, r1))
      printf("Error: uy yield not expected value.\n");
    if (!verify_ls(n, a, var, r)) {
      printf("Error: linnear system not solved right.\n");
      no_error = 0;
    }
  }
  free(l);
  free(u);
  return end - start;
}


x86 assembly (clang, -O0):
<solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x4(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
imul   %edi,%edi
shl    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1080 <get_time@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   1070 <lu@plt>
mov    $0x0,%al
call   1080 <get_time@plt>
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12ce <solve+0x14e>
mov    -0x60(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rcx
call   1030 <solve_lx@plt>
mov    -0x60(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rcx
call   10a0 <verify_ls@plt>
cmp    $0x0,%eax
jne    125c <solve+0xdc>
lea    0xda9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x60(%rbp),%rcx
mov    -0x4(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <solve_uy@plt>
mov    -0x60(%rbp),%rcx
mov    -0x4(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10a0 <verify_ls@plt>
cmp    $0x0,%eax
jne    1299 <solve+0x119>
lea    0xd91(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   10a0 <verify_ls@plt>
cmp    $0x0,%eax
jne    12c9 <solve+0x149>
lea    0xd8d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x24(%rbp)
jmp    12ce <solve+0x14e>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,-0x38(%rbp)
mov    %rdx,-0x48(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %edi,%r13d
mov    %edi,%ebx
imul   %edi,%ebx
shl    $0x3,%ebx
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %r13d,%eax
mov    %rsp,%r15
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
xor    %eax,%eax
call   1080 <get_time@plt>
movsd  %xmm0,-0x50(%rbp)
mov    %r13d,%edi
mov    -0x30(%rbp),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1070 <lu@plt>
xor    %eax,%eax
call   1080 <get_time@plt>
movsd  %xmm0,-0x40(%rbp)
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    -0x38(%rbp),%rbx
mov    %rbx,%rcx
call   1030 <solve_lx@plt>
mov    %r13d,%edi
mov    %r14,-0x58(%rbp)
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   10a0 <verify_ls@plt>
test   %eax,%eax
jne    1238 <solve+0xb8>
lea    0xdcd(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <solve_uy@plt>
mov    %r13d,%edi
mov    %r12,%r14
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   10a0 <verify_ls@plt>
test   %eax,%eax
jne    1271 <solve+0xf1>
lea    0xdb8(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    -0x30(%rbp),%rsi
mov    %rbx,%rdx
mov    -0x38(%rbp),%rcx
call   10a0 <verify_ls@plt>
test   %eax,%eax
jne    1294 <solve+0x114>
lea    0xdb9(%rip),%rdi
call   1050 <puts@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
movsd  -0x40(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Error: lx yield not expected value.\0A\00"
@.str.1 = [37 x i8] c"Error: uy yield not expected value.\0A\00"
@.str.2 = [41 x i8] c"Error: linnear system not solved right.\0A\00"
define double @solve(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 1, i32* %9
%16 = load i32, i32* %5
%17 = load i32, i32* %5
%18 = mul nsw i32 %16, %17
%19 = sext i32 %18 to i64
%20 = mul i64 8, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %10
%24 = load i32, i32* %5
%25 = load i32, i32* %5
%26 = mul nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to double*
store double* %31, double** %11
%32 = load i32, i32* %5
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %12
%35 = alloca double, i64 %33
store i64 %33, i64* %13
%36 = call double (...) @get_time()
store double %36, double* %14
%37 = load i32, i32* %5
%38 = load double*, double** %6
%39 = load double*, double** %10
%40 = load double*, double** %11
%41 = call i32 @lu(i32 %37, double* %38, double* %39, double* %40)
%42 = call double (...) @get_time()
store double %42, double* %15
%43 = load i32, i32* %9
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %79
45: ; preds = %4
%46 = load i32, i32* %5
%47 = load double*, double** %10
%48 = load double*, double** %8
%49 = call i32 @solve_lx(i32 %46, double* %47, double* %35, double* %48)
%50 = load i32, i32* %5
%51 = load double*, double** %10
%52 = load double*, double** %8
%53 = call i32 @verify_ls(i32 %50, double* %51, double* %35, double* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %45
%56 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %57
57: ; preds = %55, %45
%58 = load i32, i32* %5
%59 = load double*, double** %11
%60 = load double*, double** %7
%61 = call i32 @solve_uy(i32 %58, double* %59, double* %60, double* %35)
%62 = load i32, i32* %5
%63 = load double*, double** %11
%64 = load double*, double** %7
%65 = call i32 @verify_ls(i32 %62, double* %63, double* %64, double* %35)
%66 = icmp ne i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %57
%68 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %69
69: ; preds = %67, %57
%70 = load i32, i32* %5
%71 = load double*, double** %6
%72 = load double*, double** %7
%73 = load double*, double** %8
%74 = call i32 @verify_ls(i32 %70, double* %71, double* %72, double* %73)
%75 = icmp ne i32 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %69
%77 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %9
br label %78
78: ; preds = %76, %69
br label %79
79: ; preds = %78, %4
%80 = load double*, double** %10
%81 = call i32 @free(double* %80)
%82 = load double*, double** %11
%83 = call i32 @free(double* %82)
%84 = load double, double* %15
%85 = load double, double* %14
%86 = fsub double %84, %85
%87 = load i8*, i8** %12
ret double %86
}

LLVM IR (-O2):
@str = [36 x i8] c"Error: lx yield not expected value.\00"
@str.3 = [36 x i8] c"Error: uy yield not expected value.\00"
@str.4 = [40 x i8] c"Error: linnear system not solved right.\00"
define double @solve(i32 %0, double* %1, double* %2, double* %3) {
%5 = shl i32 %0, 3
%6 = mul i32 %5, %0
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double*
%9 = tail call i64 @malloc(i32 %6)
%10 = inttoptr i64 %9 to double*
%11 = zext i32 %0 to i64
%12 = alloca double, i64 %11
%13 = tail call double (...) @get_time()
%14 = tail call i32 @lu(i32 %0, double* %1, double* %8, double* %10)
%15 = tail call double (...) @get_time()
%16 = call i32 @solve_lx(i32 %0, double* %8, double* %12, double* %3)
%17 = call i32 @verify_ls(i32 %0, double* %8, double* %12, double* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = call i32 @solve_uy(i32 %0, double* %10, double* %2, double* %12)
%23 = call i32 @verify_ls(i32 %0, double* %10, double* %2, double* %12)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = call i32 @verify_ls(i32 %0, double* %1, double* %2, double* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.4, i64 0, i64 0))
br label %32
32: ; preds = %27, %30
%33 = call i32 @free(double* %8)
%34 = call i32 @free(double* %10)
%35 = fsub double %15, %13
ret double %35
}