#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 /*<<< orphan*/ scanf(char *, double *);
int getArray(double *s, int Lim) {
  int i = 0;
  printf("Enter the elements of the array ,one per line.\n");
  printf("Use -1 to signal the end of the list.\n");
  for (i = 0; i < Lim; i++) {
    printf(" ? ");
    scanf("%lf", (s + i));
    if (*(s + i) == -1) {
      break;
    }
  }
  return (i);
}


x86 assembly (clang, -O0):
<getArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c5 <getArray+0xa5>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xee0(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b2 <getArray+0x92>
jp     11b2 <getArray+0x92>
jmp    11c5 <getArray+0xa5>
jmp    11b7 <getArray+0x97>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <getArray+0x35>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    11a8 <getArray+0x78>
mov    %ebp,%ebp
xor    %r14d,%r14d
lea    0xea3(%rip),%r15
lea    0xea0(%rip),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  (%rbx),%xmm0
ucomisd 0xe71(%rip),%xmm0
jne    1193 <getArray+0x63>
jnp    11ad <getArray+0x7d>
add    $0xffffffffffffffff,%r14
add    $0x8,%rbx
mov    %rbp,%rax
add    %r14,%rax
jne    1170 <getArray+0x40>
mov    %ebp,%r14d
jmp    11b0 <getArray+0x80>
xor    %r14d,%r14d
jmp    11b0 <getArray+0x80>
neg    %r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Enter the elements of the array ,one per line.\0A\00"
@.str.1 = [39 x i8] c"Use -1 to signal the end of the list.\0A\00"
@.str.2 = [4 x i8] c" ? \00"
@.str.3 = [4 x i8] c"%lf\00"
define i32 @getArray(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %27, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = load double*, double** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %17)
%19 = load double*, double** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = fcmp oeq double %23, -1.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %12
br label %30
26: ; preds = %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %8
30: ; preds = %25, %8
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c" ? \00"
@.str.3 = [4 x i8] c"%lf\00"
@str = [47 x i8] c"Enter the elements of the array ,one per line.\00"
@str.4 = [38 x i8] c"Use -1 to signal the end of the list.\00"
define i32 @getArray(double* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.4, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %15
%9 = phi i64 [ 0, %6 ], [ %16, %15 ]
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds double, double* %0, i64 %9
%12 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %11)
%13 = load double, double* %11
%14 = fcmp oeq double %13, -1.000000e+00
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %20, label %8
18: ; preds = %8
%19 = trunc i64 %9 to i32
br label %20
20: ; preds = %15, %18, %2
%21 = phi i32 [ 0, %2 ], [ %19, %18 ], [ %1, %15 ]
ret i32 %21
}