#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*/ matrixSwap(int **, int, int, int);
void matrixSort(int arr[10][20]) {
  for (int h = 0; h < 10; h++) {
    for (int i = 0; i < 20; i++) {
      for (int k = i; k > 0; k--) {
        if (arr[h][k] < arr[h][k - 1])
          matrixSwap(arr, h, k, k - 1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<matrixSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11d3 <matrixSort+0xc3>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    11c0 <matrixSort+0xb0>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11ad <matrixSort+0x9d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
imul   $0x50,%rdx,%rdx
add    %rdx,%rcx
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    119a <matrixSort+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
call   1030 <matrixSwap@plt>
jmp    119f <matrixSort+0x8f>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <matrixSort+0x34>
jmp    11b2 <matrixSort+0xa2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <matrixSort+0x24>
jmp    11c5 <matrixSort+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <matrixSort+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixSort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
xor    %r15d,%r15d
mov    %rdi,%r13
jmp    1147 <matrixSort+0x37>
nopl   0x0(%rax)
add    $0x1,%r15
mov    0x8(%rsp),%r13
add    $0x50,%r13
cmp    $0xa,%r15
je     11cc <matrixSort+0xbc>
mov    $0xffffffffffffffff,%rbx
mov    %r13,0x8(%rsp)
xor    %r12d,%r12d
jmp    1177 <matrixSort+0x67>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
mov    0x10(%rsp),%rbx
add    $0x1,%rbx
add    $0x4,%r13
cmp    $0x14,%r12
je     1130 <matrixSort+0x20>
mov    %r13,%rbp
mov    %rbx,0x10(%rsp)
test   %r12d,%r12d
jne    11a5 <matrixSort+0x95>
jmp    1160 <matrixSort+0x50>
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rbx),%rax
add    $0x1,%rbx
add    $0xfffffffffffffffc,%rbp
cmp    $0x1,%rbx
mov    %rax,%rbx
jle    1160 <matrixSort+0x50>
mov    0x0(%rbp),%eax
mov    %ebx,%ecx
lea    (%r15,%r15,4),%rdx
shl    $0x4,%rdx
add    %r14,%rdx
cmp    (%rdx,%rcx,4),%eax
jge    1190 <matrixSort+0x80>
lea    0x1(%rbx),%edx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%ecx
call   1030 <matrixSwap@plt>
jmp    1190 <matrixSort+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @matrixSort([20 x i32]* %0) {
%2 = alloca [20 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store [20 x i32]* %0, [20 x i32]** %2
store i32 0, i32* %3
br label %6
6: ; preds = %54, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %57
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %50, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 20
br i1 %12, label %13, label %53
13: ; preds = %10
%14 = load i32, i32* %4
store i32 %14, i32* %5
br label %15
15: ; preds = %46, %13
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %49
18: ; preds = %15
%19 = load [20 x i32]*, [20 x i32]** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %19, i64 %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %22, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load [20 x i32]*, [20 x i32]** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i32], [20 x i32]* %27, i64 %29
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %30, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp slt i32 %26, %35
br i1 %36, label %37, label %45
37: ; preds = %18
%38 = load [20 x i32]*, [20 x i32]** %2
%39 = bitcast [20 x i32]* %38 to i32**
%40 = load i32, i32* %3
%41 = load i32, i32* %5
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 1
%44 = call i32 @matrixSwap(i32** %39, i32 %40, i32 %41, i32 %43)
br label %45
45: ; preds = %37, %18
br label %46
46: ; preds = %45
%47 = load i32, i32* %5
%48 = add nsw i32 %47, -1
store i32 %48, i32* %5
br label %15
49: ; preds = %15
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %10
53: ; preds = %10
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %6
57: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @matrixSort([20 x i32]* %0) {
%2 = bitcast [20 x i32]* %0 to i32**
br label %3
3: ; preds = %1, %11
%4 = phi i64 [ 0, %1 ], [ %12, %11 ]
%5 = trunc i64 %4 to i32
br label %7
6: ; preds = %11
ret void
7: ; preds = %3, %14
%8 = phi i64 [ 0, %3 ], [ %15, %14 ]
%9 = trunc i64 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %17
11: ; preds = %14
%12 = add nuw nsw i64 %4, 1
%13 = icmp eq i64 %12, 10
br i1 %13, label %6, label %3
14: ; preds = %30, %7
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, 20
br i1 %16, label %11, label %7
17: ; preds = %7, %30
%18 = phi i64 [ %21, %30 ], [ %8, %7 ]
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %4, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i64 %18, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %0, i64 %4, i64 %22
%24 = load i32, i32* %23
%25 = icmp slt i32 %20, %24
br i1 %25, label %26, label %30
26: ; preds = %17
%27 = trunc i64 %21 to i32
%28 = trunc i64 %18 to i32
%29 = tail call i32 @matrixSwap(i32** %2, i32 %5, i32 %28, i32 %27)
br label %30
30: ; preds = %17, %26
%31 = icmp sgt i64 %18, 1
br i1 %31, label %17, label %14
}