#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 CountSortedRowsInt(int, int, int **, int *, int **, int *, int *, int *);
int /*<<< orphan*/ FreeMatrixInt(int **);
int **MatrixInt(int, int);
int /*<<< orphan*/ SortRowsInt(int, int, int **, int **, int *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int UniqueRowsInt(int M, int N, int **list, int **uni_list, int *uni_i,
                  int *uni_j, int *cnt) {
  int **sorted;
  int *sort_idx;
  int u;
  sorted = MatrixInt(M, N);
  sort_idx = (int *)malloc(M * sizeof(int));
  SortRowsInt(M, N, list, sorted, sort_idx);
  u = CountSortedRowsInt(M, N, sorted, sort_idx, uni_list, uni_i, uni_j, cnt);
  FreeMatrixInt(sorted);
  free(sort_idx);
  return u;
}


x86 assembly (clang, -O0):
<UniqueRowsInt>:
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   1040 <MatrixInt@plt>
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <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   1080 <SortRowsInt@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 <CountSortedRowsInt@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <FreeMatrixInt@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UniqueRowsInt>:
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   1040 <MatrixInt@plt>
mov    %rax,%rbx
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
call   1080 <SortRowsInt@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 <CountSortedRowsInt@plt>
add    $0x10,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <FreeMatrixInt@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 @UniqueRowsInt(i32 %0, i32 %1, i32** %2, i32** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i32**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32**
%16 = alloca i32*
%17 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32** %2, i32*** %10
store i32** %3, i32*** %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 i32** @MatrixInt(i32 %18, i32 %19)
store i32** %20, i32*** %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 i32**, i32*** %10
%30 = load i32**, i32*** %15
%31 = load i32*, i32** %16
%32 = call i32 @SortRowsInt(i32 %27, i32 %28, i32** %29, i32** %30, i32* %31)
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = load i32**, i32*** %15
%36 = load i32*, i32** %16
%37 = load i32**, i32*** %11
%38 = load i32*, i32** %12
%39 = load i32*, i32** %13
%40 = load i32*, i32** %14
%41 = call i32 @CountSortedRowsInt(i32 %33, i32 %34, i32** %35, i32* %36, i32** %37, i32* %38, i32* %39, i32* %40)
store i32 %41, i32* %17
%42 = load i32**, i32*** %15
%43 = call i32 @FreeMatrixInt(i32** %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 @UniqueRowsInt(i32 %0, i32 %1, i32** %2, i32** %3, i32* %4, i32* %5, i32* %6) {
%8 = tail call i32** @MatrixInt(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 @SortRowsInt(i32 %0, i32 %1, i32** %2, i32** %8, i32* %11)
%13 = tail call i32 @CountSortedRowsInt(i32 %0, i32 %1, i32** %8, i32* %11, i32** %3, i32* %4, i32* %5, i32* %6)
%14 = tail call i32 @FreeMatrixInt(i32** %8)
%15 = tail call i32 @free(i32* %11)
ret i32 %13
}