#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 SENNA_print_tensor_2d(float *tensor, int nrow, int ncolumn) {
  int c, r;
  printf("\n---\n");
  for (c = 0; c < ncolumn; c++) {
    for (r = 0; r < nrow; r++)
      printf("%f ", tensor[c * nrow + r]);
    printf("\n---\n");
  }
  printf("[Tensor of size %dx%d]\n", nrow, ncolumn);
}


x86 assembly (clang, -O0):
<SENNA_print_tensor_2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a8 <SENNA_print_tensor_2d+0x98>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118c <SENNA_print_tensor_2d+0x7c>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <SENNA_print_tensor_2d+0x3a>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <SENNA_print_tensor_2d+0x27>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SENNA_print_tensor_2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %esi,0x8(%rsp)
mov    %rdi,%rbx
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    11bf <SENNA_print_tensor_2d+0x9f>
movslq 0x8(%rsp),%r13
mov    0xc(%rsp),%eax
mov    %rax,0x10(%rsp)
mov    %r13d,%r12d
shl    $0x2,%r13
xor    %r15d,%r15d
lea    0xe96(%rip),%rbp
jmp    118a <SENNA_print_tensor_2d+0x6a>
nopl   0x0(%rax)
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r15
add    %r13,%rbx
cmp    0x10(%rsp),%r15
je     11bf <SENNA_print_tensor_2d+0x9f>
cmpl   $0x0,0x8(%rsp)
jle    1170 <SENNA_print_tensor_2d+0x50>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  (%rbx,%r14,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    11a0 <SENNA_print_tensor_2d+0x80>
jmp    1170 <SENNA_print_tensor_2d+0x50>
lea    0xe3e(%rip),%rdi
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [24 x i8] c"[Tensor of size %dx%d]\0A\00"
@str.3 = [5 x i8] c"\0A---\00"
define void @SENNA_print_tensor_2d(float* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %28
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
%8 = sext i32 %1 to i64
%9 = zext i32 %2 to i64
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %6, %24
%12 = phi i64 [ 0, %6 ], [ %26, %24 ]
br i1 %7, label %13, label %24
13: ; preds = %11
%14 = mul nsw i64 %12, %8
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %22, %15 ]
%17 = add nsw i64 %16, %14
%18 = getelementptr inbounds float, float* %0, i64 %17
%19 = load float, float* %18
%20 = fpext float %19 to double
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %15
24: ; preds = %15, %11
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%26 = add nuw nsw i64 %12, 1
%27 = icmp eq i64 %26, %9
br i1 %27, label %28, label %11
28: ; preds = %24, %3
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %2)
ret void
}