#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int Print1DArray(const char *array_name, const float *array,
                 const int num_elem) {
  int num_elem_to_print = (num_elem > 16) ? 16 : num_elem;
  fprintf(stderr, "%s:\n", array_name);
  for (int i = 0; i < num_elem_to_print; ++i)
    fprintf(stderr, "%8.2f ", array[i]);
  fprintf(stderr, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<Print1DArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jle    113a <Print1DArray+0x2a>
mov    $0x10,%eax
mov    %eax,-0x20(%rbp)
jmp    1140 <Print1DArray+0x30>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11aa <Print1DArray+0x9a>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <Print1DArray+0x58>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Print1DArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rdx
mov    0x2eb8(%rip),%r14
mov    (%r14),%edi
lea    0xece(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
jle    1180 <Print1DArray+0x70>
cmp    $0x10,%r15d
mov    $0x10,%ebp
cmovb  %r15d,%ebp
xor    %ebx,%ebx
lea    0xeb1(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edi
movss  (%r12,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <Print1DArray+0x50>
mov    (%r14),%edi
lea    0xe79(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [7 x i8] c"%8.2f \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @Print1DArray(i8* %0, float* nocapture %1, i32 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = icmp ult i32 %2, 16
%9 = select i1 %8, i32 %2, i32 16
%10 = zext i32 %9 to i64
br label %14
11: ; preds = %14, %3
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
14: ; preds = %7, %14
%15 = phi i64 [ 0, %7 ], [ %21, %14 ]
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds float, float* %1, i64 %15
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, %10
br i1 %22, label %11, label %14
}