#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*/ printf(char *, int);
int transpose_equal(const double *A, const double *B, int total_size) {
  int error = 0;
  const double *Atmp = A;
  const double *Btmp = B;
  for (int i = 0; i < total_size; ++i) {
    double Aabs = (Atmp[i] < 0) ? -Atmp[i] : Atmp[i];
    double Babs = (Btmp[i] < 0) ? -Btmp[i] : Btmp[i];
    double max = (Aabs < Babs) ? Babs : Aabs;
    double diff = (Aabs - Babs);
    diff = (diff < 0) ? -diff : diff;
    if (diff > 0) {
      double relError = (diff / max);
      if (relError > 1.000000e-10) {
        error += 1;
      }
    }
  }
  printf("Number of errors: %d\t\n", error);
  return (error > 0) ? 0 : 1;
}


x86 assembly (clang, -O0):
<transpose_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12f7 <transpose_equal+0x1e7>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    1194 <transpose_equal+0x84>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    11a6 <transpose_equal+0x96>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    11f4 <transpose_equal+0xe4>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1206 <transpose_equal+0xf6>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1233 <transpose_equal+0x123>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    123d <transpose_equal+0x12d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    128a <transpose_equal+0x17a>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1294 <transpose_equal+0x184>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12e4 <transpose_equal+0x1d4>
movsd  -0x50(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xd34(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12df <transpose_equal+0x1cf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12e4 <transpose_equal+0x1d4>
jmp    12e9 <transpose_equal+0x1d9>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1144 <transpose_equal+0x34>
mov    -0x18(%rbp),%esi
lea    0xd07(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovg  %ecx,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose_equal>:
push   %rbx
test   %edx,%edx
jle    11d4 <transpose_equal+0xc4>
mov    %edx,%eax
xor    %ecx,%ecx
movapd 0xedb(%rip),%xmm0
xorpd  %xmm1,%xmm1
movsd  0xedf(%rip),%xmm2
xor    %ebx,%ebx
jmp    114d <transpose_equal+0x3d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rcx
cmp    %rcx,%rax
je     11d6 <transpose_equal+0xc6>
movsd  (%rdi,%rcx,8),%xmm4
movapd %xmm4,%xmm5
xorpd  %xmm0,%xmm5
movapd %xmm4,%xmm3
cmpltsd %xmm1,%xmm3
andpd  %xmm3,%xmm5
andnpd %xmm4,%xmm3
orpd   %xmm5,%xmm3
movsd  (%rsi,%rcx,8),%xmm5
movapd %xmm5,%xmm6
xorpd  %xmm0,%xmm6
movapd %xmm5,%xmm4
cmpltsd %xmm1,%xmm4
andpd  %xmm4,%xmm6
andnpd %xmm5,%xmm4
orpd   %xmm6,%xmm4
movapd %xmm3,%xmm6
subsd  %xmm4,%xmm6
movapd %xmm6,%xmm7
xorpd  %xmm0,%xmm7
movapd %xmm6,%xmm5
cmpltsd %xmm1,%xmm5
andpd  %xmm5,%xmm7
andnpd %xmm6,%xmm5
orpd   %xmm7,%xmm5
ucomisd %xmm1,%xmm5
jbe    1140 <transpose_equal+0x30>
maxsd  %xmm3,%xmm4
divsd  %xmm4,%xmm5
xor    %edx,%edx
ucomisd %xmm2,%xmm5
seta   %dl
add    %edx,%ebx
jmp    1140 <transpose_equal+0x30>
xor    %ebx,%ebx
lea    0xe3b(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setle  %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Number of errors: %d\09\0A\00"
define i32 @transpose_equal(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%16 = load double*, double** %4
store double* %16, double** %8
%17 = load double*, double** %5
store double* %17, double** %9
store i32 0, i32* %10
br label %18
18: ; preds = %99, %3
%19 = load i32, i32* %10
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %102
22: ; preds = %18
%23 = load double*, double** %8
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %36
29: ; preds = %22
%30 = load double*, double** %8
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = fneg double %34
br label %42
36: ; preds = %22
%37 = load double*, double** %8
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
br label %42
42: ; preds = %36, %29
%43 = phi double [ %35, %29 ], [ %41, %36 ]
store double %43, double* %11
%44 = load double*, double** %9
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = fcmp olt double %48, 0.000000e+00
br i1 %49, label %50, label %57
50: ; preds = %42
%51 = load double*, double** %9
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fneg double %55
br label %63
57: ; preds = %42
%58 = load double*, double** %9
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
br label %63
63: ; preds = %57, %50
%64 = phi double [ %56, %50 ], [ %62, %57 ]
store double %64, double* %12
%65 = load double, double* %11
%66 = load double, double* %12
%67 = fcmp olt double %65, %66
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = load double, double* %12
br label %72
70: ; preds = %63
%71 = load double, double* %11
br label %72
72: ; preds = %70, %68
%73 = phi double [ %69, %68 ], [ %71, %70 ]
store double %73, double* %13
%74 = load double, double* %11
%75 = load double, double* %12
%76 = fsub double %74, %75
store double %76, double* %14
%77 = load double, double* %14
%78 = fcmp olt double %77, 0.000000e+00
br i1 %78, label %79, label %82
79: ; preds = %72
%80 = load double, double* %14
%81 = fneg double %80
br label %84
82: ; preds = %72
%83 = load double, double* %14
br label %84
84: ; preds = %82, %79
%85 = phi double [ %81, %79 ], [ %83, %82 ]
store double %85, double* %14
%86 = load double, double* %14
%87 = fcmp ogt double %86, 0.000000e+00
br i1 %87, label %88, label %98
88: ; preds = %84
%89 = load double, double* %14
%90 = load double, double* %13
%91 = fdiv double %89, %90
store double %91, double* %15
%92 = load double, double* %15
%93 = fcmp ogt double %92, 1.000000e-10
br i1 %93, label %94, label %97
94: ; preds = %88
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %97
97: ; preds = %94, %88
br label %98
98: ; preds = %97, %84
br label %99
99: ; preds = %98
%100 = load i32, i32* %10
%101 = add nsw i32 %100, 1
store i32 %101, i32* %10
br label %18
102: ; preds = %18
%103 = load i32, i32* %7
%104 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %103)
%105 = load i32, i32* %7
%106 = icmp sgt i32 %105, 0
%107 = zext i1 %106 to i64
%108 = select i1 %106, i32 0, i32 1
ret i32 %108
}

LLVM IR (-O2):
@.str = [23 x i8] c"Number of errors: %d\09\0A\00"
define i32 @transpose_equal(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %12
7: ; preds = %37, %3
%8 = phi i32 [ 0, %3 ], [ %38, %37 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp slt i32 %8, 1
%11 = zext i1 %10 to i32
ret i32 %11
12: ; preds = %5, %37
%13 = phi i64 [ 0, %5 ], [ %39, %37 ]
%14 = phi i32 [ 0, %5 ], [ %38, %37 ]
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = load double, double* %15
%17 = fcmp olt double %16, 0.000000e+00
%18 = fneg double %16
%19 = select i1 %17, double %18, double %16
%20 = getelementptr inbounds double, double* %1, i64 %13
%21 = load double, double* %20
%22 = fcmp olt double %21, 0.000000e+00
%23 = fneg double %21
%24 = select i1 %22, double %23, double %21
%25 = fsub double %19, %24
%26 = fcmp olt double %25, 0.000000e+00
%27 = fneg double %25
%28 = select i1 %26, double %27, double %25
%29 = fcmp ogt double %28, 0.000000e+00
br i1 %29, label %30, label %37
30: ; preds = %12
%31 = fcmp olt double %19, %24
%32 = select i1 %31, double %24, double %19
%33 = fdiv double %28, %32
%34 = fcmp ogt double %33, 1.000000e-10
%35 = zext i1 %34 to i32
%36 = add nsw i32 %14, %35
br label %37
37: ; preds = %30, %12
%38 = phi i32 [ %36, %30 ], [ %14, %12 ]
%39 = add nuw nsw i64 %13, 1
%40 = icmp eq i64 %39, %6
br i1 %40, label %7, label %12
}