#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 mat_elem(int **, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void print_transpose(int nrows, int ncols, int *m[]) {
  int i, j;
  if (m == NULL || nrows <= 0 || ncols <= 0)
    return;
  for (i = 0; i < ncols; i++) {
    for (j = 0; j < nrows; j++)
      printf("%d\t", mat_elem(m, ncols, j, i));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_transpose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1151 <print_transpose+0x31>
cmpl   $0x0,-0x4(%rbp)
jle    1151 <print_transpose+0x31>
cmpl   $0x0,-0x8(%rbp)
jg     1156 <print_transpose+0x36>
jmp    11c8 <print_transpose+0xa8>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c8 <print_transpose+0xa8>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ac <print_transpose+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <mat_elem@plt>
mov    %eax,%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <print_transpose+0x50>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <print_transpose+0x3d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_transpose>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a5 <print_transpose+0x75>
mov    %edi,%r12d
test   %edi,%edi
jle    11a5 <print_transpose+0x75>
mov    %rdx,%r14
test   %rdx,%rdx
je     11a5 <print_transpose+0x75>
mov    %esi,%r13d
lea    0xea8(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <mat_elem@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1170 <print_transpose+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r13d,%ebx
jne    1160 <print_transpose+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_transpose(i32 %0, i32 %1, i32** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32** %2, i32*** %6
%9 = load i32**, i32*** %6
%10 = icmp eq i32** %9, null
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14, %11, %3
br label %43
18: ; preds = %14
store i32 0, i32* %7
br label %19
19: ; preds = %40, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %43
23: ; preds = %19
store i32 0, i32* %8
br label %24
24: ; preds = %35, %23
%25 = load i32, i32* %8
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = load i32**, i32*** %6
%30 = load i32, i32* %5
%31 = load i32, i32* %8
%32 = load i32, i32* %7
%33 = call i32 @mat_elem(i32** %29, i32 %30, i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %24
38: ; preds = %24
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %19
43: ; preds = %17, %19
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @print_transpose(i32 %0, i32 %1, i32** %2) {
%4 = icmp eq i32** %2, null
%5 = icmp slt i32 %0, 1
%6 = or i1 %5, %4
%7 = icmp slt i32 %1, 1
%8 = or i1 %7, %6
br i1 %8, label %21, label %9
9: ; preds = %3, %17
%10 = phi i32 [ %19, %17 ], [ 0, %3 ]
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ %15, %11 ], [ 0, %9 ]
%13 = tail call i32 @mat_elem(i32** %2, i32 %1, i32 %12, i32 %10)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %12, 1
%16 = icmp eq i32 %15, %0
br i1 %16, label %17, label %11
17: ; preds = %11
%18 = tail call i32 @putchar(i32 10)
%19 = add nuw nsw i32 %10, 1
%20 = icmp eq i32 %19, %1
br i1 %20, label %21, label %9
21: ; preds = %17, %3
ret void
}