#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 dump_calibration_matrix(int nr_rows, int nr_cols, int *mtx) {
  int i, j;
  printf("calibration matrix dump:\n");
  printf("nr rows: %d\n", nr_rows);
  printf("nr columns: %d\n", nr_cols);
  for (i = 0; i < nr_rows; i++) {
    for (j = 0; j < nr_cols; j++) {
      printf("%d  ", *mtx);
      mtx++;
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_calibration_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c2 <dump_calibration_matrix+0xb2>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a6 <dump_calibration_matrix+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <dump_calibration_matrix+0x5c>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <dump_calibration_matrix+0x49>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_calibration_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
jle    11c7 <dump_calibration_matrix+0x97>
lea    0xe9f(%rip),%r13
xor    %r12d,%r12d
jmp    11a3 <dump_calibration_matrix+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    %r14d,%r12d
je     11c7 <dump_calibration_matrix+0x97>
test   %r15d,%r15d
jle    1190 <dump_calibration_matrix+0x60>
mov    %r15d,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x4,%rbx
add    $0xffffffff,%ebp
jne    11b0 <dump_calibration_matrix+0x80>
jmp    1190 <dump_calibration_matrix+0x60>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"calibration matrix dump:\0A\00"
@.str.1 = [13 x i8] c"nr rows: %d\0A\00"
@.str.2 = [16 x i8] c"nr columns: %d\0A\00"
@.str.3 = [5 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dump_calibration_matrix(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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %12)
store i32 0, i32* %7
br label %14
14: ; preds = %34, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
store i32 0, i32* %8
br label %19
19: ; preds = %29, %18
%20 = load i32, i32* %8
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %6
br label %29
29: ; preds = %23
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %19
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %14
37: ; preds = %14
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"nr rows: %d\0A\00"
@.str.2 = [16 x i8] c"nr columns: %d\0A\00"
@.str.3 = [5 x i8] c"%d \00"
@str = [25 x i8] c"calibration matrix dump:\00"
define void @dump_calibration_matrix(i32 %0, i32 %1, i32* nocapture %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %1)
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %26
8: ; preds = %3
%9 = icmp sgt i32 %1, 0
br label %10
10: ; preds = %8, %21
%11 = phi i32 [ 0, %8 ], [ %24, %21 ]
%12 = phi i32* [ %2, %8 ], [ %22, %21 ]
br i1 %9, label %13, label %21
13: ; preds = %10, %13
%14 = phi i32 [ %19, %13 ], [ 0, %10 ]
%15 = phi i32* [ %18, %13 ], [ %12, %10 ]
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds i32, i32* %15, i64 1
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, %1
br i1 %20, label %21, label %13
21: ; preds = %13, %10
%22 = phi i32* [ %12, %10 ], [ %18, %13 ]
%23 = tail call i32 @putchar(i32 10)
%24 = add nuw nsw i32 %11, 1
%25 = icmp eq i32 %24, %0
br i1 %25, label %26, label %10
26: ; preds = %21, %3
%27 = tail call i32 @putchar(i32 10)
ret void
}