#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 *, double);
int /*<<< orphan*/ ps1();
double test(int SIZE, float *p1) {
  ps1();
  double SUM = 0.;
  int i;
  for (i = 0; i < SIZE; i++) {
    SUM = SUM + p1[i];
    p1[i] = -p1[i];
  }
  printf("%f\n", SUM);
  return SUM;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <ps1@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <test+0x85>
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <test+0x25>
movsd  -0x18(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <ps1@plt>
test   %ebp,%ebp
jle    1142 <test+0x22>
mov    %ebp,%eax
cmp    $0x1,%ebp
jne    1148 <test+0x28>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    119b <test+0x7b>
xorpd  %xmm0,%xmm0
jmp    11bb <test+0x9b>
mov    %eax,%edx
and    $0xfffffffe,%edx
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
movaps 0xea6(%rip),%xmm4
nopw   0x0(%rax,%rax,1)
movss  (%rbx,%rcx,4),%xmm1
movss  0x4(%rbx,%rcx,4),%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm4,%xmm1
movss  %xmm1,(%rbx,%rcx,4)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
addsd  %xmm3,%xmm0
xorps  %xmm4,%xmm2
movss  %xmm2,0x4(%rbx,%rcx,4)
add    $0x2,%rcx
cmp    %rcx,%rdx
jne    1160 <test+0x40>
test   $0x1,%al
je     11bb <test+0x9b>
movss  (%rbx,%rcx,4),%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
addsd  %xmm1,%xmm0
xorps  0xe4a(%rip),%xmm2
movss  %xmm2,(%rbx,%rcx,4)
movsd  %xmm0,(%rsp)
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
define double @test(i32 %0, float* nocapture %1) {
%3 = tail call i32 (...) @ps1()
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %40
5: ; preds = %2
%6 = zext i32 %0 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %0, 1
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %26, %11 ]
%13 = phi double [ 0.000000e+00, %9 ], [ %24, %11 ]
%14 = phi i64 [ 0, %9 ], [ %27, %11 ]
%15 = getelementptr inbounds float, float* %1, i64 %12
%16 = load float, float* %15
%17 = fpext float %16 to double
%18 = fadd double %13, %17
%19 = fneg float %16
store float %19, float* %15
%20 = or i64 %12, 1
%21 = getelementptr inbounds float, float* %1, i64 %20
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = fadd double %18, %23
%25 = fneg float %22
store float %25, float* %21
%26 = add nuw nsw i64 %12, 2
%27 = add i64 %14, 2
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %11
29: ; preds = %11, %5
%30 = phi double [ undef, %5 ], [ %24, %11 ]
%31 = phi i64 [ 0, %5 ], [ %26, %11 ]
%32 = phi double [ 0.000000e+00, %5 ], [ %24, %11 ]
%33 = icmp eq i64 %7, 0
br i1 %33, label %40, label %34
34: ; preds = %29
%35 = getelementptr inbounds float, float* %1, i64 %31
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = fadd double %32, %37
%39 = fneg float %36
store float %39, float* %35
br label %40
40: ; preds = %34, %29, %2
%41 = phi double [ 0.000000e+00, %2 ], [ %30, %29 ], [ %38, %34 ]
%42 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %41)
ret double %41
}