#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 */
typedef size_t uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_tensor(float *input, uint32_t input_len) {
  uint32_t i;
  for (i = 0; i < input_len; i++) {
    printf("%f, ", input[i]);
    if (i % 5 == 4) {
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<print_tensor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1191 <print_tensor+0x81>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    $0x5,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x4,%rdx
jne    117b <print_tensor+0x6b>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <print_tensor+0x70>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <print_tensor+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tensor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1190 <print_tensor+0x70>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
movabs $0xcccccccccccccccd,%r13
cc cc cc
lea    0xeb7(%rip),%r12
jmp    1159 <print_tensor+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1190 <print_tensor+0x70>
mov    %rbx,%rax
mul    %r13
shr    $0x2,%rdx
lea    (%rdx,%rdx,4),%rbp
add    $0x4,%rbp
movss  (%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    %rbx,%rbp
jne    1150 <print_tensor+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <print_tensor+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%f, \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_tensor(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca i64
store float* %0, float** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %23, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load float*, float** %3
%12 = load i64, i64* %5
%13 = getelementptr inbounds float, float* %11, i64 %12
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %15)
%17 = load i64, i64* %5
%18 = urem i64 %17, 5
%19 = icmp eq i64 %18, 4
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %10
br label %23
23: ; preds = %22
%24 = load i64, i64* %5
%25 = add i64 %24, 1
store i64 %25, i64* %5
br label %6
26: ; preds = %6
ret void
}

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