#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*/ is_equal(double, double);
int /*<<< orphan*/ mult_matrix(int, int, int, double *, double *, double *);
int verify_ls(int n, double *a, double *var, double *r) {
  int i;
  double res[n];
  mult_matrix(n, n, 1, a, var, res);
  for (i = 0; i < n; i++)
    if (!is_equal(res[i], r[i]))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<verify_ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r9
sub    %rcx,%r9
mov    %r9,-0x48(%rbp)
mov    %r9,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x1,%edx
call   1030 <mult_matrix@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d7 <verify_ls+0xb7>
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1040 <is_equal@plt>
cmp    $0x0,%eax
jne    11c4 <verify_ls+0xa4>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    11e5 <verify_ls+0xc5>
jmp    11c9 <verify_ls+0xa9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117d <verify_ls+0x5d>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_ls>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %edi,%r12d
mov    %edi,%r13d
mov    %rsp,%r14
lea    0xf(,%r13,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    $0x1,%ebx
mov    %edi,%esi
mov    $0x1,%edx
mov    %r14,%r9
call   1030 <mult_matrix@plt>
test   %r12d,%r12d
jle    1197 <verify_ls+0x77>
xor    %ebx,%ebx
nopl   (%rax)
movsd  (%r14,%rbx,8),%xmm0
movsd  (%r15,%rbx,8),%xmm1
call   1040 <is_equal@plt>
test   %eax,%eax
je     1195 <verify_ls+0x75>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <verify_ls+0x50>
mov    $0x1,%ebx
jmp    1197 <verify_ls+0x77>
xor    %ebx,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @verify_ls(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 %0, i32* %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca double, i64 %15
store i64 %15, i64* %12
%18 = load i32, i32* %6
%19 = load i32, i32* %6
%20 = load double*, double** %7
%21 = load double*, double** %8
%22 = call i32 @mult_matrix(i32 %18, i32 %19, i32 1, double* %20, double* %21, double* %17)
store i32 0, i32* %10
br label %23
23: ; preds = %41, %4
%24 = load i32, i32* %10
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %17, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %9
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = call i32 @is_equal(double %31, double %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %27
store i32 0, i32* %5
store i32 1, i32* %13
br label %45
40: ; preds = %27
br label %41
41: ; preds = %40
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %23
44: ; preds = %23
store i32 1, i32* %5
store i32 1, i32* %13
br label %45
45: ; preds = %44, %39
%46 = load i8*, i8** %11
%47 = load i32, i32* %5
ret i32 %47
}

LLVM IR (-O2):
define i32 @verify_ls(i32 %0, double* %1, double* %2, double* nocapture %3) {
%5 = zext i32 %0 to i64
%6 = alloca double, i64 %5
%7 = call i32 @mult_matrix(i32 %0, i32 %0, i32 1, double* %1, double* %2, double* %6)
%8 = icmp sgt i32 %0, 0
br i1 %8, label %11, label %20
9: ; preds = %11
%10 = icmp eq i64 %19, %5
br i1 %10, label %20, label %11
11: ; preds = %4, %9
%12 = phi i64 [ %19, %9 ], [ 0, %4 ]
%13 = getelementptr inbounds double, double* %6, i64 %12
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %3, i64 %12
%16 = load double, double* %15
%17 = call i32 @is_equal(double %14, double %16)
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i64 %12, 1
br i1 %18, label %20, label %9
20: ; preds = %11, %9, %4
%21 = phi i32 [ 1, %4 ], [ 1, %9 ], [ 0, %11 ]
ret i32 %21
}