#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 *, ...);
void T_sparse(int total, int array2[total][3]) {
  int i;
  total = array2[0][2];
  printf("\n*Now, the Sparse Matrix is transposed and arranged*\n");
  printf("\nRow\tColumn\tValue\n");
  for (i = 0; i <= total; i++)
    printf("%d\t%d\t%d\n", array2[i][0], array2[i][1], array2[i][2]);
}


x86 assembly (clang, -O0):
<T_sparse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11a9 <T_sparse+0x99>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%ecx
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <T_sparse+0x3c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<T_sparse>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    0x8(%rsi),%ebx
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
js     1181 <T_sparse+0x61>
lea    (%rbx,%rbx,2),%rax
lea    0xc(,%rax,4),%r15
lea    0xea3(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%r12,%rbx,1),%esi
mov    0x4(%r12,%rbx,1),%edx
mov    0x8(%r12,%rbx,1),%ecx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xc,%rbx
cmp    %rbx,%r15
jne    1160 <T_sparse+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [54 x i8] c"\0A*Now, the Sparse Matrix is transposed and arranged*\0A\00"
@.str.1 = [19 x i8] c"\0ARow\09Column\09Value\0A\00"
@.str.2 = [10 x i8] c"%d\09%d\09%d\0A\00"
define void @T_sparse(i32 %0, [3 x i32]* %1) {
%3 = alloca i32
%4 = alloca [3 x i32]*
%5 = alloca i32
store i32 %0, i32* %3
store [3 x i32]* %1, [3 x i32]** %4
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
%8 = load [3 x i32]*, [3 x i32]** %4
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 2
%11 = load i32, i32* %10
store i32 %11, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %38, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = load [3 x i32]*, [3 x i32]** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %19, i64 %21
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %22, i64 0, i64 0
%24 = load i32, i32* %23
%25 = load [3 x i32]*, [3 x i32]** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %25, i64 %27
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %28, i64 0, i64 1
%30 = load i32, i32* %29
%31 = load [3 x i32]*, [3 x i32]** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %31, i64 %33
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %34, i64 0, i64 2
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %30, i32 %36)
br label %38
38: ; preds = %18
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %14
41: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str.2 = [10 x i8] c"%d\09%d\09%d\0A\00"
@str = [53 x i8] c"\0A*Now, the Sparse Matrix is transposed and arranged*\00"
@str.3 = [18 x i8] c"\0ARow\09Column\09Value\00"
define void @T_sparse(i32 %0, [3 x i32]* nocapture %1) {
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%4 = load i32, i32* %3
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
%7 = icmp slt i32 %4, 0
br i1 %7, label %22, label %8
8: ; preds = %2
%9 = add nuw i32 %4, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %20, %11 ]
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 %12, i64 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 %12, i64 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 %12, i64 2
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16, i32 %18)
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11, %2
ret void
}