#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 printArray(double *srcdata, int p, int r) {
  printf("(p,r) = (%d,%d)\n", p, r);
  for (int idx = p; idx <= r; idx++) {
    printf("%f, ", srcdata[idx]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1171 <printArray+0x61>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <printArray+0x2c>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r15d
jg     1179 <printArray+0x59>
movslq %r15d,%rax
lea    (%r14,%rax,8),%rbp
sub    %r15d,%r12d
add    $0x1,%r12d
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1160 <printArray+0x40>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"(p,r) = (%d,%d)\0A\00"
@.str.1 = [5 x i8] c"%f, \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printArray(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %5
store i32 %11, i32* %7
br label %12
12: ; preds = %23, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load double*, double** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %12
26: ; preds = %12
%27 = 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 = [17 x i8] c"(p,r) = (%d,%d)\0A\00"
@.str.1 = [5 x i8] c"%f, \00"
define void @printArray(double* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%5 = icmp sgt i32 %1, %2
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = sext i32 %1 to i64
%8 = add i32 %2, 1
br label %11
9: ; preds = %11, %3
%10 = tail call i32 @putchar(i32 10)
ret void
11: ; preds = %6, %11
%12 = phi i64 [ %7, %6 ], [ %16, %11 ]
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = load double, double* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %14)
%16 = add nsw i64 %12, 1
%17 = trunc i64 %16 to i32
%18 = icmp eq i32 %8, %17
br i1 %18, label %9, label %11
}