#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*/ assert(int);
scalar_t__ memcmp(double const *, double const *, size_t const);
void compare_d3matrix(const double **m1, const double **m2, const size_t dim1,
                      const size_t dim2, const size_t dim3) {
  size_t i, j;
  for (i = 0; i < dim1; i++) {
    for (j = 0; j < dim2; j++)
      assert(memcmp(m1[i], m2[i], dim3 * sizeof(double)) == 0);
  }
}


x86 assembly (clang, -O0):
<compare_d3matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c5 <compare_d3matrix+0xa5>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11af <compare_d3matrix+0x8f>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%rdx
shl    $0x3,%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    115a <compare_d3matrix+0x3a>
jmp    11b4 <compare_d3matrix+0x94>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1144 <compare_d3matrix+0x24>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_d3matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
test   %rdx,%rdx
je     1197 <compare_d3matrix+0x77>
mov    %r8,%r12
mov    %rcx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
shl    $0x3,%r12
xor    %ebp,%ebp
jmp    115a <compare_d3matrix+0x3a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    (%rsp),%rbp
je     1197 <compare_d3matrix+0x77>
test   %r15,%r15
je     1150 <compare_d3matrix+0x30>
mov    %r15,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rdi
mov    0x0(%r13,%rbp,8),%rsi
mov    %r12,%rdx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0xffffffffffffffff,%r14
jne    1170 <compare_d3matrix+0x50>
jmp    1150 <compare_d3matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @compare_d3matrix(double** %0, double** %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca double**
%7 = alloca double**
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store double** %0, double*** %6
store double** %1, double*** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i64 0, i64* %11
br label %13
13: ; preds = %41, %5
%14 = load i64, i64* %11
%15 = load i64, i64* %8
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
store i64 0, i64* %12
br label %18
18: ; preds = %37, %17
%19 = load i64, i64* %12
%20 = load i64, i64* %9
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load double**, double*** %6
%24 = load i64, i64* %11
%25 = getelementptr inbounds double*, double** %23, i64 %24
%26 = load double*, double** %25
%27 = load double**, double*** %7
%28 = load i64, i64* %11
%29 = getelementptr inbounds double*, double** %27, i64 %28
%30 = load double*, double** %29
%31 = load i64, i64* %10
%32 = mul i64 %31, 8
%33 = call i64 @memcmp(double* %26, double* %30, i64 %32)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %37
37: ; preds = %22
%38 = load i64, i64* %12
%39 = add i64 %38, 1
store i64 %39, i64* %12
br label %18
40: ; preds = %18
br label %41
41: ; preds = %40
%42 = load i64, i64* %11
%43 = add i64 %42, 1
store i64 %43, i64* %11
br label %13
44: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @compare_d3matrix(double** nocapture %0, double** nocapture %1, i64 %2, i64 %3, i64 %4) {
%6 = icmp eq i64 %2, 0
br i1 %6, label %28, label %7
7: ; preds = %5
%8 = icmp eq i64 %3, 0
%9 = shl i64 %4, 3
br label %10
10: ; preds = %7, %25
%11 = phi i64 [ 0, %7 ], [ %26, %25 ]
br i1 %8, label %25, label %12
12: ; preds = %10
%13 = getelementptr inbounds double*, double** %0, i64 %11
%14 = getelementptr inbounds double*, double** %1, i64 %11
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 0, %12 ], [ %23, %15 ]
%17 = load double*, double** %13
%18 = load double*, double** %14
%19 = tail call i64 @memcmp(double* %17, double* %18, i64 %9)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = add nuw i64 %16, 1
%24 = icmp eq i64 %23, %3
br i1 %24, label %25, label %15
25: ; preds = %15, %10
%26 = add nuw i64 %11, 1
%27 = icmp eq i64 %26, %2
br i1 %27, label %28, label %10
28: ; preds = %25, %5
ret void
}