#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 print_mat(float *matrix, size_t n) {
  size_t nb_lines = 10;
  for (size_t i = 0; i < n; ++i) {
    if (i % nb_lines == 0)
      printf("\n%3f ", matrix[i]);
    else
      printf("%3f ", matrix[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xa,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ad <print_mat+0x9d>
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1178 <print_mat+0x68>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1197 <print_mat+0x87>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    119c <print_mat+0x8c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1130 <print_mat+0x20>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1186 <print_mat+0x66>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
movabs $0xcccccccccccccccd,%r12
cc cc cc
lea    0xeb7(%rip),%r13
lea    0xeb1(%rip),%rbp
mov    %rbx,%rax
mul    %r12
shr    $0x2,%rdx
and    $0xfffffffffffffffe,%rdx
lea    (%rdx,%rdx,4),%rax
cmp    %rbx,%rax
movss  (%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
cmove  %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <print_mat+0x30>
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 = [6 x i8] c"\0A%3f \00"
@.str.1 = [5 x i8] c"%3f \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_mat(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store float* %0, float** %3
store i64 %1, i64* %4
store i64 10, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %31, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load i64, i64* %6
%13 = load i64, i64* %5
%14 = urem i64 %12, %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load float*, float** %3
%18 = load i64, i64* %6
%19 = getelementptr inbounds float, float* %17, i64 %18
%20 = load float, float* %19
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %21)
br label %30
23: ; preds = %11
%24 = load float*, float** %3
%25 = load i64, i64* %6
%26 = getelementptr inbounds float, float* %24, i64 %25
%27 = load float, float* %26
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %28)
br label %30
30: ; preds = %23, %16
br label %31
31: ; preds = %30
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
br label %7
34: ; preds = %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\0A%3f \00"
@.str.1 = [5 x i8] c"%3f \00"
define void @print_mat(float* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %6, %2
%5 = tail call i32 @putchar(i32 10)
ret void
6: ; preds = %2, %6
%7 = phi i64 [ %15, %6 ], [ 0, %2 ]
%8 = urem i64 %7, 10
%9 = icmp eq i64 %8, 0
%10 = getelementptr inbounds float, float* %0, i64 %7
%11 = load float, float* %10
%12 = fpext float %11 to double
%13 = select i1 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, double %12)
%15 = add nuw i64 %7, 1
%16 = icmp eq i64 %15, %1
br i1 %16, label %4, label %6
}