#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 */
char getchar();
int /*<<< orphan*/ printArray(double *, int const);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, double *);
int main(void) {
  const int SIZE = 8;
  double arr1[SIZE];
  double arr2[SIZE];
  int count = 0;
  arr2[0] = 0;
  while (count < SIZE) {
    printf("Enter No.%d element: ", count + 1);
    if (scanf("%lf", &arr1[count])) {
      if (count == 0)
        arr2[count] = arr1[count];
      else
        arr2[count] = arr2[count - 1] + arr1[count];
      count++;
    }
    while (getchar() != '\n')
      ;
  }
  printArray(arr1, SIZE);
  printArray(arr2, SIZE);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x8,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
cmpl   $0x8,-0x14(%rbp)
jge    122c <main+0xec>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe72(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     120a <main+0xca>
cmpl   $0x0,-0x14(%rbp)
jne    11d9 <main+0x99>
movslq -0x14(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
jmp    1201 <main+0xc1>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0xa0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x14(%rbp),%rax
addsd  -0x60(%rbp,%rax,8),%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120f <main+0xcf>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1227 <main+0xe7>
jmp    120f <main+0xcf>
jmp    1172 <main+0x32>
lea    -0x60(%rbp),%rdi
mov    $0x8,%esi
call   1060 <printArray@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x8,%esi
call   1060 <printArray@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movq   $0x0,(%rsp)
lea    0xea0(%rip),%r14
lea    0xeaf(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    0x1(%rbp),%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
movslq %ebp,%r13
lea    (%rsp,%r13,8),%rbx
add    $0x40,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11d0 <main+0x90>
test   %ebp,%ebp
je     11b0 <main+0x70>
movsd  -0x8(%rsp,%r13,8),%xmm0
addsd  (%rbx),%xmm0
jmp    11ba <main+0x7a>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx),%xmm0
mov    $0x1,%r12d
movsd  %xmm0,(%rsp,%r13,8)
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    11d0 <main+0x90>
cmp    $0x7,%ebp
jle    1170 <main+0x30>
lea    0x40(%rsp),%rdi
mov    $0x8,%esi
call   1060 <printArray@plt>
mov    %rsp,%rdi
mov    $0x8,%esi
call   1060 <printArray@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter No.%d element: \00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
store i32 8, i32* %2
%5 = call i8* @llvm.stacksave()
store i8* %5, i8** %3
%6 = alloca double, i64 8
%7 = alloca double, i64 8
store i32 0, i32* %4
%8 = getelementptr inbounds double, double* %7, i64 0
store double 0.000000e+00, double* %8
br label %9
9: ; preds = %55, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %56
12: ; preds = %9
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %6, i64 %17
%19 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %12
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %6, i64 %26
%28 = load double, double* %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %7, i64 %30
store double %28, double* %31
br label %46
32: ; preds = %21
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %7, i64 %35
%37 = load double, double* %36
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %6, i64 %39
%41 = load double, double* %40
%42 = fadd double %37, %41
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %7, i64 %44
store double %42, double* %45
br label %46
46: ; preds = %32, %24
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %49
49: ; preds = %46, %12
br label %50
50: ; preds = %54, %49
%51 = call signext i8 (...) @getchar()
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 10
br i1 %53, label %54, label %55
54: ; preds = %50
br label %50
55: ; preds = %50
br label %9
56: ; preds = %9
%57 = call i32 @printArray(double* %6, i32 8)
%58 = call i32 @printArray(double* %7, i32 8)
store i32 0, i32* %1
%59 = load i8*, i8** %3
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter No.%d element: \00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca [8 x double]
%2 = alloca [8 x double]
%3 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
store double 0.000000e+00, double* %3
br label %6
4: ; preds = %31
%5 = icmp slt i32 %30, 8
br i1 %5, label %6, label %34
6: ; preds = %0, %4
%7 = phi i32 [ 0, %0 ], [ %30, %4 ]
%8 = add nsw i32 %7, 1
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 %10
%12 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %6
%15 = icmp eq i32 %7, 0
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = load double, double* %11
br label %25
18: ; preds = %14
%19 = add nsw i32 %7, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 %20
%22 = load double, double* %21
%23 = load double, double* %11
%24 = fadd double %22, %23
br label %25
25: ; preds = %18, %16
%26 = phi double [ %17, %16 ], [ %24, %18 ]
%27 = phi i32 [ 1, %16 ], [ %8, %18 ]
%28 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 %10
store double %26, double* %28
br label %29
29: ; preds = %25, %6
%30 = phi i32 [ %7, %6 ], [ %27, %25 ]
br label %31
31: ; preds = %31, %29
%32 = call signext i8 (...) @getchar()
%33 = icmp eq i8 %32, 10
br i1 %33, label %4, label %31
34: ; preds = %4
%35 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 0
%36 = call i32 @printArray(double* %35, i32 8)
%37 = call i32 @printArray(double* %3, i32 8)
ret i32 0
}