#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 CountSortedRowsDouble(int, int, double **, int *, double **, int *, int *,
                          int *);
int /*<<< orphan*/ FreeMatrixDouble(double **);
double **MatrixDouble(int, int);
int /*<<< orphan*/ SortRowsDouble(int, int, double **, double **, int *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int UniqueRowsDouble(int M, int N, double **list, double **uni_list, int *uni_i,
                     int *uni_j, int *cnt) {
  double **sorted;
  int *sort_idx;
  int u;
  sorted = MatrixDouble(M, N);
  sort_idx = (int *)malloc(M * sizeof(int));
  SortRowsDouble(M, N, list, sorted, sort_idx);
  u = CountSortedRowsDouble(M, N, sorted, sort_idx, uni_list, uni_i, uni_j,
                            cnt);
  FreeMatrixDouble(sorted);
  free(sort_idx);
  return u;
}


x86 assembly (clang, -O0):
<UniqueRowsDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <MatrixDouble@plt>
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1070 <SortRowsDouble@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%r10
mov    0x10(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <CountSortedRowsDouble@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <FreeMatrixDouble@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UniqueRowsDouble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %esi,%ebp
mov    %edi,%r14d
call   1050 <MatrixDouble@plt>
mov    %rax,%rbx
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
call   1070 <SortRowsDouble@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    0x8(%rsp),%r9
push   0x50(%rsp)
push   0x18(%rsp)
call   1060 <CountSortedRowsDouble@plt>
add    $0x10,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <FreeMatrixDouble@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @UniqueRowsDouble(i32 %0, i32 %1, double** %2, double** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
%11 = alloca double**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca double**
%16 = alloca i32*
%17 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store double** %2, double*** %10
store double** %3, double*** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = call double** @MatrixDouble(i32 %18, i32 %19)
store double** %20, double*** %15
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %16
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = load double**, double*** %10
%30 = load double**, double*** %15
%31 = load i32*, i32** %16
%32 = call i32 @SortRowsDouble(i32 %27, i32 %28, double** %29, double** %30, i32* %31)
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = load double**, double*** %15
%36 = load i32*, i32** %16
%37 = load double**, double*** %11
%38 = load i32*, i32** %12
%39 = load i32*, i32** %13
%40 = load i32*, i32** %14
%41 = call i32 @CountSortedRowsDouble(i32 %33, i32 %34, double** %35, i32* %36, double** %37, i32* %38, i32* %39, i32* %40)
store i32 %41, i32* %17
%42 = load double**, double*** %15
%43 = call i32 @FreeMatrixDouble(double** %42)
%44 = load i32*, i32** %16
%45 = call i32 @free(i32* %44)
%46 = load i32, i32* %17
ret i32 %46
}

LLVM IR (-O2):
define i32 @UniqueRowsDouble(i32 %0, i32 %1, double** %2, double** %3, i32* %4, i32* %5, i32* %6) {
%8 = tail call double** @MatrixDouble(i32 %0, i32 %1)
%9 = shl i32 %0, 2
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
%12 = tail call i32 @SortRowsDouble(i32 %0, i32 %1, double** %2, double** %8, i32* %11)
%13 = tail call i32 @CountSortedRowsDouble(i32 %0, i32 %1, double** %8, i32* %11, double** %3, i32* %4, i32* %5, i32* %6)
%14 = tail call i32 @FreeMatrixDouble(double** %8)
%15 = tail call i32 @free(i32* %11)
ret i32 %13
}