#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 /*<<< orphan*/ printf(char *, double, double);
int verify_ls(int n, double *a, double *var, double *r) {
  int i, no_error = 1;
  double res[n];
  mult_matrix(n, n, 1, a, var, res);
  for (i = 0; i < n; i++)
    if (!is_equal(res[i], r[i])) {
      printf("Error: %.2lf != %.2lf\n", res[i], r[i]);
      no_error = 0;
    }
  return no_error;
}


x86 assembly (clang, -O0):
<verify_ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x4(%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,-0x40(%rbp)
mov    %r9,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%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    -0x4(%rbp),%eax
jge    1208 <verify_ls+0xd8>
mov    -0x40(%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   1050 <is_equal@plt>
cmp    $0x0,%eax
jne    11f5 <verify_ls+0xc5>
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
jmp    11fa <verify_ls+0xca>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <verify_ls+0x64>
mov    -0x28(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
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,%r14
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %edi,%r12d
mov    %edi,%r13d
mov    %rsp,%rbx
lea    0xf(,%r13,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    $0x1,%r15d
mov    %edi,%esi
mov    $0x1,%edx
mov    %rbx,%r9
call   1030 <mult_matrix@plt>
test   %r12d,%r12d
jle    11cb <verify_ls+0x9b>
mov    $0x1,%r15d
xor    %r12d,%r12d
jmp    1199 <verify_ls+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%r13
je     11cb <verify_ls+0x9b>
movsd  (%rbx,%r12,8),%xmm0
movsd  (%r14,%r12,8),%xmm1
call   1050 <is_equal@plt>
test   %eax,%eax
jne    1190 <verify_ls+0x60>
movsd  (%rbx,%r12,8),%xmm0
movsd  (%r14,%r12,8),%xmm1
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %r15d,%r15d
jmp    1190 <verify_ls+0x60>
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Error: %.2lf != %.2lf\0A\00"
define i32 @verify_ls(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 i32
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 1, i32* %10
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %11
%16 = alloca double, i64 %14
store i64 %14, i64* %12
%17 = load i32, i32* %5
%18 = load i32, i32* %5
%19 = load double*, double** %6
%20 = load double*, double** %7
%21 = call i32 @mult_matrix(i32 %17, i32 %18, i32 1, double* %19, double* %20, double* %16)
store i32 0, i32* %9
br label %22
22: ; preds = %50, %4
%23 = load i32, i32* %9
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %53
26: ; preds = %22
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %16, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %8
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call i32 @is_equal(double %30, double %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %49, label %38
38: ; preds = %26
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %16, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %8
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %42, double %47)
store i32 0, i32* %10
br label %49
49: ; preds = %38, %26
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %22
53: ; preds = %22
%54 = load i32, i32* %10
%55 = load i8*, i8** %11
ret i32 %54
}

LLVM IR (-O2):
@.str = [23 x i8] c"Error: %.2lf != %.2lf\0A\00"
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 %9, label %26
9: ; preds = %4, %22
%10 = phi i64 [ %24, %22 ], [ 0, %4 ]
%11 = phi i32 [ %23, %22 ], [ 1, %4 ]
%12 = getelementptr inbounds double, double* %6, i64 %10
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %3, i64 %10
%15 = load double, double* %14
%16 = call i32 @is_equal(double %13, double %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = load double, double* %12
%20 = load double, double* %14
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %19, double %20)
br label %22
22: ; preds = %9, %18
%23 = phi i32 [ %11, %9 ], [ 0, %18 ]
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %26, label %9
26: ; preds = %22, %4
%27 = phi i32 [ 1, %4 ], [ %23, %22 ]
ret i32 %27
}