#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 LD(int, double const *, double *, double *);
double *eye(int);
int /*<<< orphan*/ free(double *);
double *mat(int, int);
int /*<<< orphan*/ matmul(char *, int, int, int, double, double *,
                          double const *, double, double *);
int /*<<< orphan*/ reduction(int, double *, double *, double *);
int search(int, int, double *, double *, double *, double *, double *);
int solve(char *, double *, double *, int, int, double *);
double *zeros(int, int);
extern int lambda(int n, int m, const double *a, const double *Q, double *F,
                  double *s) {
  int info;
  double *L, *D, *Z, *z, *E;
  if (n <= 0 || m <= 0)
    return -1;
  L = zeros(n, n);
  D = mat(n, 1);
  Z = eye(n);
  z = mat(n, 1), E = mat(n, m);
  if (!(info = LD(n, Q, L, D))) {
    reduction(n, L, D, Z);
    matmul("TN", n, 1, n, 1.0, Z, a, 0.0, z);
    if (!(info = search(n, m, L, D, z, E, s))) {
      info = solve("T", Z, E, n, m, F);
    }
  }
  free(L);
  free(D);
  free(Z);
  free(z);
  free(E);
  return info;
}


x86 assembly (clang, -O0):
<lambda>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11c2 <lambda+0x32>
cmpl   $0x0,-0xc(%rbp)
jg     11ce <lambda+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1309 <lambda+0x179>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
call   10b0 <zeros@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1060 <mat@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <eye@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1060 <mat@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <mat@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
call   1090 <LD@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    12d6 <lambda+0x146>
mov    -0x8(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
call   1050 <reduction@plt>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x58(%rbp),%rax
lea    0xda1(%rip),%rdi
mov    $0x1,%edx
movsd  0xd8c(%rip),%xmm0
xorps  %xmm1,%xmm1
mov    %rax,(%rsp)
call   10a0 <matmul@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <search@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    12d1 <lambda+0x141>
mov    -0x50(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x28(%rbp),%r9
lea    0xd42(%rip),%rdi
call   1030 <solve@plt>
mov    %eax,-0x34(%rbp)
jmp    12d6 <lambda+0x146>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x60(%rbp),%rdi
call   1040 <free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lambda>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0xffffffff,%r13d
test   %edi,%edi
jle    12e5 <lambda+0x155>
mov    %esi,%r15d
test   %esi,%esi
jle    12e5 <lambda+0x155>
mov    %rcx,%r14
mov    %edi,%ebx
mov    %rdx,0x28(%rsp)
mov    %r9,0x30(%rsp)
mov    %r8,0x20(%rsp)
mov    %edi,%esi
call   10b0 <zeros@plt>
mov    %rax,%r13
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <mat@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1080 <eye@plt>
mov    %rax,%rbp
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <mat@plt>
mov    %rax,0x18(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
call   1060 <mat@plt>
mov    %rax,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rbp,%r14
mov    %r13,%rbp
mov    %r13,%rdx
mov    %r12,%rcx
call   1090 <LD@plt>
mov    %eax,%r13d
test   %eax,%eax
jne    12b9 <lambda+0x129>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1050 <reduction@plt>
mov    0x18(%rsp),%r13
mov    %r13,(%rsp)
lea    0xdb9(%rip),%rdi
movsd  0xda9(%rip),%xmm0
xorps  %xmm1,%xmm1
mov    %ebx,%esi
mov    $0x1,%edx
mov    %ebx,%ecx
mov    %r14,%r8
mov    0x28(%rsp),%r9
call   10a0 <matmul@plt>
mov    0x30(%rsp),%rax
mov    %rax,(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    0x10(%rsp),%r9
call   1070 <search@plt>
mov    %eax,%r13d
test   %eax,%eax
jne    12b9 <lambda+0x129>
lea    0xd6c(%rip),%rdi
mov    %r14,%rsi
mov    0x10(%rsp),%rdx
mov    %ebx,%ecx
mov    %r15d,%r8d
mov    0x20(%rsp),%r9
call   1030 <solve@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    %r13d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"TN\00"
@.str.1 = [2 x i8] c"T\00"
define i32 @lambda(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
store i32 %0, i32* %8
store i32 %1, i32* %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
%20 = load i32, i32* %8
%21 = icmp sle i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %6
%23 = load i32, i32* %9
%24 = icmp sle i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22, %6
store i32 -1, i32* %7
br label %86
26: ; preds = %22
%27 = load i32, i32* %8
%28 = load i32, i32* %8
%29 = call double* @zeros(i32 %27, i32 %28)
store double* %29, double** %15
%30 = load i32, i32* %8
%31 = call double* @mat(i32 %30, i32 1)
store double* %31, double** %16
%32 = load i32, i32* %8
%33 = call double* @eye(i32 %32)
store double* %33, double** %17
%34 = load i32, i32* %8
%35 = call double* @mat(i32 %34, i32 1)
store double* %35, double** %18
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = call double* @mat(i32 %36, i32 %37)
store double* %38, double** %19
%39 = load i32, i32* %8
%40 = load double*, double** %11
%41 = load double*, double** %15
%42 = load double*, double** %16
%43 = call i32 @LD(i32 %39, double* %40, double* %41, double* %42)
store i32 %43, i32* %14
%44 = icmp ne i32 %43, 0
br i1 %44, label %74, label %45
45: ; preds = %26
%46 = load i32, i32* %8
%47 = load double*, double** %15
%48 = load double*, double** %16
%49 = load double*, double** %17
%50 = call i32 @reduction(i32 %46, double* %47, double* %48, double* %49)
%51 = load i32, i32* %8
%52 = load i32, i32* %8
%53 = load double*, double** %17
%54 = load double*, double** %10
%55 = load double*, double** %18
%56 = call i32 @matmul(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %51, i32 1, i32 %52, double 1.000000e+00, double* %53, double* %54, double 0.000000e+00, double* %55)
%57 = load i32, i32* %8
%58 = load i32, i32* %9
%59 = load double*, double** %15
%60 = load double*, double** %16
%61 = load double*, double** %18
%62 = load double*, double** %19
%63 = load double*, double** %13
%64 = call i32 @search(i32 %57, i32 %58, double* %59, double* %60, double* %61, double* %62, double* %63)
store i32 %64, i32* %14
%65 = icmp ne i32 %64, 0
br i1 %65, label %73, label %66
66: ; preds = %45
%67 = load double*, double** %17
%68 = load double*, double** %19
%69 = load i32, i32* %8
%70 = load i32, i32* %9
%71 = load double*, double** %12
%72 = call i32 @solve(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), double* %67, double* %68, i32 %69, i32 %70, double* %71)
store i32 %72, i32* %14
br label %73
73: ; preds = %66, %45
br label %74
74: ; preds = %73, %26
%75 = load double*, double** %15
%76 = call i32 @free(double* %75)
%77 = load double*, double** %16
%78 = call i32 @free(double* %77)
%79 = load double*, double** %17
%80 = call i32 @free(double* %79)
%81 = load double*, double** %18
%82 = call i32 @free(double* %81)
%83 = load double*, double** %19
%84 = call i32 @free(double* %83)
%85 = load i32, i32* %14
store i32 %85, i32* %7
br label %86
86: ; preds = %74, %25
%87 = load i32, i32* %7
ret i32 %87
}

LLVM IR (-O2):
@.str = [3 x i8] c"TN\00"
@.str.1 = [2 x i8] c"T\00"
define i32 @lambda(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = icmp slt i32 %0, 1
%8 = icmp slt i32 %1, 1
%9 = or i1 %7, %8
br i1 %9, label %32, label %10
10: ; preds = %6
%11 = tail call double* @zeros(i32 %0, i32 %0)
%12 = tail call double* @mat(i32 %0, i32 1)
%13 = tail call double* @eye(i32 %0)
%14 = tail call double* @mat(i32 %0, i32 1)
%15 = tail call double* @mat(i32 %0, i32 %1)
%16 = tail call i32 @LD(i32 %0, double* %3, double* %11, double* %12)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = tail call i32 @reduction(i32 %0, double* %11, double* %12, double* %13)
%20 = tail call i32 @matmul(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0, i32 1, i32 %0, double 1.000000e+00, double* %13, double* %2, double 0.000000e+00, double* %14)
%21 = tail call i32 @search(i32 %0, i32 %1, double* %11, double* %12, double* %14, double* %15, double* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = tail call i32 @solve(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), double* %13, double* %15, i32 %0, i32 %1, double* %4)
br label %25
25: ; preds = %18, %23, %10
%26 = phi i32 [ %16, %10 ], [ %21, %18 ], [ %24, %23 ]
%27 = tail call i32 @free(double* %11)
%28 = tail call i32 @free(double* %12)
%29 = tail call i32 @free(double* %13)
%30 = tail call i32 @free(double* %14)
%31 = tail call i32 @free(double* %15)
br label %32
32: ; preds = %6, %25
%33 = phi i32 [ %26, %25 ], [ -1, %6 ]
ret i32 %33
}