#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*/ transpose_scalar_block(float *, float *, int const,
                                          int const, int const);
void transpose_block(float *const A, float *const B, const int n, const int m,
                     const int lda, const int ldb, const int block_size) {
#pragma omp parallel for
  for (int i = 0; i < n; i += block_size) {
    for (int j = 0; j < m; j += block_size) {
      transpose_scalar_block(&A[i * lda + j], &B[j * ldb + i], lda, ldb,
                             block_size);
    }
  }
}


x86 assembly (clang, -O0):
<transpose_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <transpose_block+0xa5>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a2 <transpose_block+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    -0x28(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%eax
imul   -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%r8d
call   1030 <transpose_scalar_block@plt>
mov    0x10(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    114b <transpose_block+0x3b>
jmp    11a7 <transpose_block+0x97>
mov    0x10(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1138 <transpose_block+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose_block>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,0x8(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
test   %edx,%edx
jle    1204 <transpose_block+0xf4>
mov    %r9d,%r13d
mov    %r8d,%ebp
mov    0x80(%rsp),%eax
movslq %eax,%r8
movslq %r9d,%rbx
movslq 0x8(%rsp),%rcx
movslq %ebp,%rsi
mov    %edx,%edx
mov    %rdx,0x20(%rsp)
lea    0x0(,%r8,4),%rdi
imul   %r8,%rbx
shl    $0x2,%rbx
imul   %r8,%rsi
shl    $0x2,%rsi
mov    %rsi,0x28(%rsp)
xor    %esi,%esi
mov    %ebp,0xc(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rdi,0x38(%rsp)
jmp    11ae <transpose_block+0x9e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x30(%rsp),%rsi
add    %r8,%rsi
add    %rdi,0x18(%rsp)
mov    0x28(%rsp),%rdx
add    %rdx,0x10(%rsp)
cmp    0x20(%rsp),%rsi
jge    1204 <transpose_block+0xf4>
mov    %rsi,0x30(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    1190 <transpose_block+0x80>
mov    0x10(%rsp),%r12
mov    0x18(%rsp),%r15
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
mov    %r8,%rbp
call   1030 <transpose_scalar_block@plt>
mov    0x38(%rsp),%rdi
mov    0x40(%rsp),%rcx
mov    %rbp,%r8
mov    0xc(%rsp),%ebp
add    %r8,%r14
add    %rbx,%r15
add    %rdi,%r12
cmp    %rcx,%r14
jl     11d0 <transpose_block+0xc0>
jmp    1190 <transpose_block+0x80>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @transpose_block(float* %0, float* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %20
9: ; preds = %7
%10 = icmp sgt i32 %3, 0
%11 = sext i32 %6 to i64
%12 = sext i32 %5 to i64
%13 = sext i32 %3 to i64
%14 = sext i32 %4 to i64
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %9, %21
%17 = phi i64 [ 0, %9 ], [ %22, %21 ]
br i1 %10, label %18, label %21
18: ; preds = %16
%19 = mul nsw i64 %17, %14
br label %24
20: ; preds = %21, %7
ret void
21: ; preds = %24, %16
%22 = add i64 %17, %11
%23 = icmp slt i64 %22, %15
br i1 %23, label %16, label %20
24: ; preds = %18, %24
%25 = phi i64 [ 0, %18 ], [ %32, %24 ]
%26 = add nsw i64 %25, %19
%27 = getelementptr inbounds float, float* %0, i64 %26
%28 = mul nsw i64 %25, %12
%29 = add nsw i64 %28, %17
%30 = getelementptr inbounds float, float* %1, i64 %29
%31 = tail call i32 @transpose_scalar_block(float* %27, float* %30, i32 %4, i32 %5, i32 %6)
%32 = add i64 %25, %11
%33 = icmp slt i64 %32, %13
br i1 %33, label %24, label %21
}