#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, double const);
void printDoubleArr(const double *arr, int N) {
  if (N < 1)
    return;
  if (arr == NULL)
    return;
  int i;
  for (i = 0; i < N; ++i) {
    printf("%d: %f\n", i, arr[i]);
  }
}


x86 assembly (clang, -O0):
<printDoubleArr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    112e <printDoubleArr+0x1e>
jmp    117b <printDoubleArr+0x6b>
cmpq   $0x0,-0x8(%rbp)
jne    113e <printDoubleArr+0x2e>
jmp    117b <printDoubleArr+0x6b>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117b <printDoubleArr+0x6b>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <printDoubleArr+0x35>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDoubleArr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1149 <printDoubleArr+0x39>
test   %esi,%esi
jle    1149 <printDoubleArr+0x39>
mov    %rdi,%r14
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xed0(%rip),%r15
movsd  (%r14,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <printDoubleArr+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%d: %f\0A\00"
define void @printDoubleArr(double* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = icmp ne double* %0, null
%5 = and i1 %4, %3
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = trunc i64 %9 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12, double %11)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %2
ret void
}