#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 *, ...);
int print_matrix(unsigned long *matrix, unsigned long n, unsigned long d) {
  unsigned long i, j, ij;
  printf("Current configuration is of dimension %lu and degree %lu. Matrix:\n",
         d, n);
  for (ij = 0, i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j, ++ij)
      printf("%lu ", matrix[ij]);
    printf("\n");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c4 <print_matrix+0xb4>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a5 <print_matrix+0x95>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1160 <print_matrix+0x50>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114a <print_matrix+0x3a>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec8(%rip),%rdi
mov    %rdx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14,%r14
je     119d <print_matrix+0x7d>
lea    0x0(,%r14,8),%r12
lea    0xeea(%rip),%r15
xor    %r13d,%r13d
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1170 <print_matrix+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    %r12,%rbx
cmp    %r14,%r13
jne    1160 <print_matrix+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"Current configuration is of dimension %lu and degree %lu. Matrix:\0A\00"
@.str.1 = [5 x i8] c"%lu \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @print_matrix(i64* %0, i64 %1, i64 %2) {
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i64* %0, i64** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%10 = load i64, i64* %6
%11 = load i64, i64* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i64 %10, i64 %11)
store i64 0, i64* %9
store i64 0, i64* %7
br label %13
13: ; preds = %35, %3
%14 = load i64, i64* %7
%15 = load i64, i64* %5
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
store i64 0, i64* %8
br label %18
18: ; preds = %28, %17
%19 = load i64, i64* %8
%20 = load i64, i64* %5
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i64*, i64** %4
%24 = load i64, i64* %9
%25 = getelementptr inbounds i64, i64* %23, i64 %24
%26 = load i64, i64* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %26)
br label %28
28: ; preds = %22
%29 = load i64, i64* %8
%30 = add i64 %29, 1
store i64 %30, i64* %8
%31 = load i64, i64* %9
%32 = add i64 %31, 1
store i64 %32, i64* %9
br label %18
33: ; preds = %18
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33
%36 = load i64, i64* %7
%37 = add i64 %36, 1
store i64 %37, i64* %7
br label %13
38: ; preds = %13
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [67 x i8] c"Current configuration is of dimension %lu and degree %lu. Matrix:\0A\00"
@.str.1 = [5 x i8] c"%lu \00"
define i32 @print_matrix(i64* nocapture %0, i64 %1, i64 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i64 %2, i64 %1)
%5 = icmp eq i64 %1, 0
br i1 %5, label %21, label %6
6: ; preds = %3, %17
%7 = phi i64 [ %9, %17 ], [ 0, %3 ]
%8 = phi i64 [ %19, %17 ], [ 0, %3 ]
%9 = add i64 %7, %1
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ %7, %6 ], [ %15, %10 ]
%12 = getelementptr inbounds i64, i64* %0, i64 %11
%13 = load i64, i64* %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = add i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = tail call i32 @putchar(i32 10)
%19 = add nuw i64 %8, 1
%20 = icmp eq i64 %19, %1
br i1 %20, label %21, label %6
21: ; preds = %17, %3
%22 = tail call i32 @putchar(i32 10)
ret i32 0
}