#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sum(double *, int);
int main() {
  double lista[] = {40.5, 26.7, 21.9, 1.5, -40.5, -23.4};
  printf("%20.1lf\n", sum(lista, 6));
  printf("%20.1lf\n", sum(lista, 2));
  printf("%20.1lf\n", sum(lista, 0));
  printf("%20.1lf\n", sum(lista, 3));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe68(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1050 <sum@plt>
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x2,%esi
call   1050 <sum@plt>
mov    %eax,%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1050 <sum@plt>
mov    %eax,%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
call   1050 <sum@plt>
mov    %eax,%esi
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x6,%esi
call   1040 <sum@plt>
lea    0xecf(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1040 <sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1040 <sum@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%20.1lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x double]
store i32 0, i32* %1
%3 = bitcast [6 x double]* %2 to i8*
%4 = bitcast i8* %3 to [6 x double]*
%5 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 0
store double 4.050000e+01, double* %5
%6 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 1
store double 2.670000e+01, double* %6
%7 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 2
store double 2.190000e+01, double* %7
%8 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 3
store double 1.500000e+00, double* %8
%9 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 4
store double -4.050000e+01, double* %9
%10 = getelementptr inbounds [6 x double], [6 x double]* %4, i32 0, i32 5
store double -2.340000e+01, double* %10
%11 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%12 = call i32 @sum(double* %11, i32 6)
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%15 = call i32 @sum(double* %14, i32 2)
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%18 = call i32 @sum(double* %17, i32 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [6 x double], [6 x double]* %2, i64 0, i64 0
%21 = call i32 @sum(double* %20, i32 3)
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@.str = [9 x i8] c"%20.1lf\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [6 x double]
%2 = bitcast [6 x double]* %1 to i8*
%3 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 0
%4 = bitcast [6 x double]* %1 to <2 x double>*
store <2 x double> <double 4.050000e+01, double 2.670000e+01>, <2 x double>* %4
%5 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 2
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 2.190000e+01, double 1.500000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [6 x double], [6 x double]* %1, i64 0, i64 4
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double -4.050000e+01, double -2.340000e+01>, <2 x double>* %8
%9 = call i32 @sum(double* %3, i32 6)
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @sum(double* %3, i32 2)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @sum(double* %3, i32 0)
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @sum(double* %3, i32 3)
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}