#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 */
scalar_t__ loop(float *, float *, int);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char *argv[]) {
  int i, j;
  float x[2048];
  float y[2048];
  double total = 0.0;
  float a = 0.0f;
  float b = 1.0f;
  for (i = 0; i < 500000; ++i) {
    if (i % 10) {
      a = 0.0f;
      b = 1.0f;
    } else {
      a += 0.1f;
      b += 0.2f;
    }
    for (j = 0; j < 2048; ++j) {
      x[j] = a + (float)j;
      y[j] = b + (float)j;
    }
    total += loop(x, y, 2048);
  }
  printf("Total is %g\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x4028(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x402c(%rbp)
ff
movss  0xea9(%rip),%xmm0
movss  %xmm0,-0x4030(%rbp)
ff
movl   $0x0,-0x14(%rbp)
cmpl   $0x7a120,-0x14(%rbp)
jge    1270 <main+0x150>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a7 <main+0x87>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x402c(%rbp)
ff
movss  0xe66(%rip),%xmm0
movss  %xmm0,-0x4030(%rbp)
ff
jmp    11d7 <main+0xb7>
movss  0xe59(%rip),%xmm0
addss  -0x402c(%rbp),%xmm0
ff
movss  %xmm0,-0x402c(%rbp)
ff
movss  0xe3d(%rip),%xmm0
addss  -0x4030(%rbp),%xmm0
ff
movss  %xmm0,-0x4030(%rbp)
ff
movl   $0x0,-0x18(%rbp)
cmpl   $0x800,-0x18(%rbp)
jge    1235 <main+0x115>
movss  -0x402c(%rbp),%xmm0
ff
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
movslq -0x18(%rbp),%rax
movss  %xmm0,-0x2020(%rbp,%rax,4)
ff ff
movss  -0x4030(%rbp),%xmm0
ff
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
movslq -0x18(%rbp),%rax
movss  %xmm0,-0x4020(%rbp,%rax,4)
ff ff
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11de <main+0xbe>
lea    -0x2020(%rbp),%rdi
lea    -0x4020(%rbp),%rsi
mov    $0x800,%edx
call   1030 <loop@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x4028(%rbp),%xmm0
ff
movsd  %xmm0,-0x4028(%rbp)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <main+0x46>
movsd  -0x4028(%rbp),%xmm0
ff
lea    0xd8d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x4030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4020,%rsp
movss  0xecc(%rip),%xmm1
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movdqa 0xeee(%rip),%xmm7
movdqa 0xef5(%rip),%xmm8
movdqa 0xefc(%rip),%xmm9
movdqa 0xf03(%rip),%xmm10
lea    0x2020(%rsp),%r14
lea    0x20(%rsp),%r15
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
imul   $0xcccccccd,%ebx,%eax
ror    %eax
xor    %ecx,%ecx
cmp    $0x1999999a,%eax
setb   %cl
addps  0xe81(%rip),%xmm1
movd   %ecx,%xmm0
pshufd $0x50,%xmm0,%xmm0
pslld  $0x1f,%xmm0
psrad  $0x1f,%xmm0
andps  %xmm0,%xmm1
movss  0xe53(%rip),%xmm2
andnps %xmm2,%xmm0
movaps %xmm0,%xmm2
orps   %xmm1,%xmm2
pshufd $0x55,%xmm2,%xmm0
movaps %xmm2,0x10(%rsp)
pshufd $0x0,%xmm2,%xmm1
xor    %eax,%eax
movdqa 0xe51(%rip),%xmm2
nop
movdqa %xmm2,%xmm3
paddd  %xmm7,%xmm3
cvtdq2ps %xmm2,%xmm4
cvtdq2ps %xmm3,%xmm3
movdqa %xmm0,%xmm5
addps  %xmm4,%xmm5
movdqa %xmm0,%xmm6
addps  %xmm3,%xmm6
movaps %xmm5,0x2020(%rsp,%rax,4)
movaps %xmm6,0x2030(%rsp,%rax,4)
addps  %xmm1,%xmm4
addps  %xmm1,%xmm3
movaps %xmm4,0x20(%rsp,%rax,4)
movaps %xmm3,0x30(%rsp,%rax,4)
movdqa %xmm2,%xmm3
paddd  %xmm8,%xmm3
movdqa %xmm2,%xmm4
paddd  %xmm9,%xmm4
cvtdq2ps %xmm3,%xmm3
cvtdq2ps %xmm4,%xmm4
movdqa %xmm0,%xmm5
addps  %xmm3,%xmm5
movdqa %xmm0,%xmm6
addps  %xmm4,%xmm6
movaps %xmm5,0x2040(%rsp,%rax,4)
movaps %xmm6,0x2050(%rsp,%rax,4)
addps  %xmm1,%xmm3
addps  %xmm1,%xmm4
movaps %xmm3,0x40(%rsp,%rax,4)
movaps %xmm4,0x50(%rsp,%rax,4)
add    $0x10,%rax
paddd  %xmm10,%xmm2
cmp    $0x800,%rax
jne    11d0 <main+0xb0>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x800,%edx
call   1030 <loop@plt>
movdqa 0xde0(%rip),%xmm10
movdqa 0xdc7(%rip),%xmm9
movdqa 0xdae(%rip),%xmm8
movdqa 0xd96(%rip),%xmm7
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x1,%ebx
cmp    $0x7a120,%ebx
movaps 0x10(%rsp),%xmm1
jne    1170 <main+0x50>
lea    0xda5(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x4020,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Total is %g\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x float]
%4 = alloca [2048 x float]
%5 = bitcast [2048 x float]* %3 to i8*
%6 = bitcast [2048 x float]* %4 to i8*
%7 = getelementptr inbounds [2048 x float], [2048 x float]* %3, i64 0, i64 0
%8 = getelementptr inbounds [2048 x float], [2048 x float]* %4, i64 0, i64 0
br label %9
9: ; preds = %2, %59
%10 = phi double [ 0.000000e+00, %2 ], [ %62, %59 ]
%11 = phi i32 [ 0, %2 ], [ %63, %59 ]
%12 = phi <2 x float> [ <float 1.000000e+00, float 0.000000e+00>, %2 ], [ %18, %59 ]
%13 = urem i32 %11, 10
%14 = icmp eq i32 %13, 0
%15 = fadd <2 x float> %12, <float 0x3FC99999A0000000, float 0x3FB99999A0000000>
%16 = insertelement <2 x i1> poison, i1 %14, i64 0
%17 = shufflevector <2 x i1> %16, <2 x i1> poison, <2 x i32> zeroinitializer
%18 = select <2 x i1> %17, <2 x float> %15, <2 x float> <float 1.000000e+00, float 0.000000e+00>
%19 = shufflevector <2 x float> %18, <2 x float> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%20 = shufflevector <2 x float> %18, <2 x float> undef, <4 x i32> zeroinitializer
br label %21
21: ; preds = %21, %9
%22 = phi i64 [ 0, %9 ], [ %56, %21 ]
%23 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %9 ], [ %57, %21 ]
%24 = add <4 x i32> %23, <i32 4, i32 4, i32 4, i32 4>
%25 = sitofp <4 x i32> %23 to <4 x float>
%26 = sitofp <4 x i32> %24 to <4 x float>
%27 = fadd <4 x float> %19, %25
%28 = fadd <4 x float> %19, %26
%29 = getelementptr inbounds [2048 x float], [2048 x float]* %3, i64 0, i64 %22
%30 = bitcast float* %29 to <4 x float>*
store <4 x float> %27, <4 x float>* %30
%31 = getelementptr inbounds float, float* %29, i64 4
%32 = bitcast float* %31 to <4 x float>*
store <4 x float> %28, <4 x float>* %32
%33 = fadd <4 x float> %20, %25
%34 = fadd <4 x float> %20, %26
%35 = getelementptr inbounds [2048 x float], [2048 x float]* %4, i64 0, i64 %22
%36 = bitcast float* %35 to <4 x float>*
store <4 x float> %33, <4 x float>* %36
%37 = getelementptr inbounds float, float* %35, i64 4
%38 = bitcast float* %37 to <4 x float>*
store <4 x float> %34, <4 x float>* %38
%39 = or i64 %22, 8
%40 = add <4 x i32> %23, <i32 8, i32 8, i32 8, i32 8>
%41 = add <4 x i32> %23, <i32 12, i32 12, i32 12, i32 12>
%42 = sitofp <4 x i32> %40 to <4 x float>
%43 = sitofp <4 x i32> %41 to <4 x float>
%44 = fadd <4 x float> %19, %42
%45 = fadd <4 x float> %19, %43
%46 = getelementptr inbounds [2048 x float], [2048 x float]* %3, i64 0, i64 %39
%47 = bitcast float* %46 to <4 x float>*
store <4 x float> %44, <4 x float>* %47
%48 = getelementptr inbounds float, float* %46, i64 4
%49 = bitcast float* %48 to <4 x float>*
store <4 x float> %45, <4 x float>* %49
%50 = fadd <4 x float> %20, %42
%51 = fadd <4 x float> %20, %43
%52 = getelementptr inbounds [2048 x float], [2048 x float]* %4, i64 0, i64 %39
%53 = bitcast float* %52 to <4 x float>*
store <4 x float> %50, <4 x float>* %53
%54 = getelementptr inbounds float, float* %52, i64 4
%55 = bitcast float* %54 to <4 x float>*
store <4 x float> %51, <4 x float>* %55
%56 = add nuw nsw i64 %22, 16
%57 = add <4 x i32> %23, <i32 16, i32 16, i32 16, i32 16>
%58 = icmp eq i64 %56, 2048
br i1 %58, label %59, label %21
59: ; preds = %21
%60 = call i64 @loop(float* %7, float* %8, i32 2048)
%61 = sitofp i64 %60 to double
%62 = fadd double %10, %61
%63 = add nuw nsw i32 %11, 1
%64 = icmp eq i32 %63, 500000
br i1 %64, label %65, label %9
65: ; preds = %59
%66 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %62)
ret i32 0
}