#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*/ consumer(double *);
void multi_loop_double(double *x) {
  for (int i = 0; i < 100; ++i)
    x[i] += 3.5 + i;
  consumer(x);
  for (int i = 0; i < 100; ++i)
    x[i] += 3.5 + i;
  consumer(x);
  for (int i = 0; i < 100; ++i)
    x[i] += 3.5 + i;
  consumer(x);
}


x86 assembly (clang, -O0):
<multi_loop_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    115e <multi_loop_double+0x4e>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xec6(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <multi_loop_double+0x13>
mov    -0x8(%rbp),%rdi
call   1030 <consumer@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jge    11a9 <multi_loop_double+0x99>
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <multi_loop_double+0x5e>
mov    -0x8(%rbp),%rdi
call   1030 <consumer@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11f4 <multi_loop_double+0xe4>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe30(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b9 <multi_loop_double+0xa9>
mov    -0x8(%rbp),%rdi
call   1030 <consumer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_loop_double>:
push   %rbx
mov    %rdi,%rbx
movdqa 0xee4(%rip),%xmm0
mov    $0x2,%eax
movapd 0xee7(%rip),%xmm3
nopl   0x0(%rax)
cvtdq2pd %xmm0,%xmm1
addpd  %xmm3,%xmm1
movupd -0x10(%rbx,%rax,8),%xmm2
addpd  %xmm1,%xmm2
movupd (%rbx,%rax,8),%xmm1
movupd %xmm2,-0x10(%rbx,%rax,8)
movdqa %xmm0,%xmm2
paddd  0xec7(%rip),%xmm2
cvtdq2pd %xmm2,%xmm2
addpd  %xmm3,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
paddd  0xebe(%rip),%xmm0
add    $0x4,%rax
cmp    $0x66,%rax
jne    1130 <multi_loop_double+0x20>
mov    %rbx,%rdi
call   1030 <consumer@plt>
movdqa 0xea4(%rip),%xmm5
movdqa 0xe8c(%rip),%xmm4
movapd 0xe74(%rip),%xmm3
movdqa 0xe5c(%rip),%xmm0
mov    $0x2,%eax
nopl   0x0(%rax)
cvtdq2pd %xmm0,%xmm1
addpd  %xmm3,%xmm1
movupd -0x10(%rbx,%rax,8),%xmm2
addpd  %xmm1,%xmm2
movupd (%rbx,%rax,8),%xmm1
movupd %xmm2,-0x10(%rbx,%rax,8)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
cvtdq2pd %xmm2,%xmm2
addpd  %xmm3,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
paddd  %xmm5,%xmm0
add    $0x4,%rax
cmp    $0x66,%rax
jne    11b0 <multi_loop_double+0xa0>
mov    %rbx,%rdi
call   1030 <consumer@plt>
movdqa 0xe2c(%rip),%xmm5
movdqa 0xe14(%rip),%xmm4
movapd 0xdfc(%rip),%xmm3
movdqa 0xde4(%rip),%xmm0
mov    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cvtdq2pd %xmm0,%xmm1
addpd  %xmm3,%xmm1
movupd -0x10(%rbx,%rax,8),%xmm2
addpd  %xmm1,%xmm2
movupd (%rbx,%rax,8),%xmm1
movupd %xmm2,-0x10(%rbx,%rax,8)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
cvtdq2pd %xmm2,%xmm2
addpd  %xmm3,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
paddd  %xmm5,%xmm0
add    $0x4,%rax
cmp    $0x66,%rax
jne    1230 <multi_loop_double+0x120>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <consumer@plt>

LLVM IR (-O0):
define void @multi_loop_double(double* %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %2
store i32 0, i32* %3
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to double
%12 = fadd double 3.500000e+00, %11
%13 = load double*, double** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fadd double %17, %12
store double %18, double* %16
br label %19
19: ; preds = %9
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %6
22: ; preds = %6
%23 = load double*, double** %2
%24 = call i32 @consumer(double* %23)
store i32 0, i32* %4
br label %25
25: ; preds = %38, %22
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 100
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = fadd double 3.500000e+00, %30
%32 = load double*, double** %2
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = fadd double %36, %31
store double %37, double* %35
br label %38
38: ; preds = %28
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %25
41: ; preds = %25
%42 = load double*, double** %2
%43 = call i32 @consumer(double* %42)
store i32 0, i32* %5
br label %44
44: ; preds = %57, %41
%45 = load i32, i32* %5
%46 = icmp slt i32 %45, 100
br i1 %46, label %47, label %60
47: ; preds = %44
%48 = load i32, i32* %5
%49 = sitofp i32 %48 to double
%50 = fadd double 3.500000e+00, %49
%51 = load double*, double** %2
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fadd double %55, %50
store double %56, double* %54
br label %57
57: ; preds = %47
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %44
60: ; preds = %44
%61 = load double*, double** %2
%62 = call i32 @consumer(double* %61)
ret void
}

LLVM IR (-O2):
define void @multi_loop_double(double* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %21, %2 ]
%4 = phi <2 x i32> [ <i32 0, i32 1>, %1 ], [ %22, %2 ]
%5 = sitofp <2 x i32> %4 to <2 x double>
%6 = fadd <2 x double> %5, <double 3.500000e+00, double 3.500000e+00>
%7 = getelementptr inbounds double, double* %0, i64 %3
%8 = bitcast double* %7 to <2 x double>*
%9 = load <2 x double>, <2 x double>* %8
%10 = fadd <2 x double> %6, %9
%11 = bitcast double* %7 to <2 x double>*
store <2 x double> %10, <2 x double>* %11
%12 = or i64 %3, 2
%13 = add <2 x i32> %4, <i32 2, i32 2>
%14 = sitofp <2 x i32> %13 to <2 x double>
%15 = fadd <2 x double> %14, <double 3.500000e+00, double 3.500000e+00>
%16 = getelementptr inbounds double, double* %0, i64 %12
%17 = bitcast double* %16 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = fadd <2 x double> %15, %18
%20 = bitcast double* %16 to <2 x double>*
store <2 x double> %19, <2 x double>* %20
%21 = add nuw nsw i64 %3, 4
%22 = add <2 x i32> %4, <i32 4, i32 4>
%23 = icmp eq i64 %21, 100
br i1 %23, label %24, label %2
24: ; preds = %2
%25 = tail call i32 @consumer(double* %0)
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %45, %26 ]
%28 = phi <2 x i32> [ <i32 0, i32 1>, %24 ], [ %46, %26 ]
%29 = sitofp <2 x i32> %28 to <2 x double>
%30 = fadd <2 x double> %29, <double 3.500000e+00, double 3.500000e+00>
%31 = getelementptr inbounds double, double* %0, i64 %27
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
%34 = fadd <2 x double> %30, %33
%35 = bitcast double* %31 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
%36 = or i64 %27, 2
%37 = add <2 x i32> %28, <i32 2, i32 2>
%38 = sitofp <2 x i32> %37 to <2 x double>
%39 = fadd <2 x double> %38, <double 3.500000e+00, double 3.500000e+00>
%40 = getelementptr inbounds double, double* %0, i64 %36
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = fadd <2 x double> %39, %42
%44 = bitcast double* %40 to <2 x double>*
store <2 x double> %43, <2 x double>* %44
%45 = add nuw nsw i64 %27, 4
%46 = add <2 x i32> %28, <i32 4, i32 4>
%47 = icmp eq i64 %45, 100
br i1 %47, label %48, label %26
48: ; preds = %26
%49 = tail call i32 @consumer(double* %0)
br label %50
50: ; preds = %50, %48
%51 = phi i64 [ 0, %48 ], [ %69, %50 ]
%52 = phi <2 x i32> [ <i32 0, i32 1>, %48 ], [ %70, %50 ]
%53 = sitofp <2 x i32> %52 to <2 x double>
%54 = fadd <2 x double> %53, <double 3.500000e+00, double 3.500000e+00>
%55 = getelementptr inbounds double, double* %0, i64 %51
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = fadd <2 x double> %54, %57
%59 = bitcast double* %55 to <2 x double>*
store <2 x double> %58, <2 x double>* %59
%60 = or i64 %51, 2
%61 = add <2 x i32> %52, <i32 2, i32 2>
%62 = sitofp <2 x i32> %61 to <2 x double>
%63 = fadd <2 x double> %62, <double 3.500000e+00, double 3.500000e+00>
%64 = getelementptr inbounds double, double* %0, i64 %60
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fadd <2 x double> %63, %66
%68 = bitcast double* %64 to <2 x double>*
store <2 x double> %67, <2 x double>* %68
%69 = add nuw nsw i64 %51, 4
%70 = add <2 x i32> %52, <i32 4, i32 4>
%71 = icmp eq i64 %69, 100
br i1 %71, label %72, label %50
72: ; preds = %50
%73 = tail call i32 @consumer(double* %0)
ret void
}