#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*/ free(double *);
scalar_t__ malloc(int);
double pow(int, int);
double sqrt(int);
int main(int argc, char *argv[]) {
  int i;
  double *c = (double *)malloc(sizeof(double) * 500000);
  for (i = 0; i < 500000; i++) {
    c[i] = sqrt(i * 32) + sqrt(i * 16 + i * 8) + sqrt(i * 4 + i * 2 + i);
    c[i] -= sqrt(i * 32 * i * 16 + i * 4 + i * 2 + i);
    c[i] += pow(i * 32, 8) + pow(i * 16, 12);
  }
  free(c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3d0900,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7a120,-0x14(%rbp)
jge    126a <main+0x12a>
mov    -0x14(%rbp),%edi
shl    $0x5,%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x4,%edi
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
add    %eax,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x2,%edi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    %eax,%edi
add    -0x14(%rbp),%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%edi
shl    $0x5,%edi
imul   -0x14(%rbp),%edi
shl    $0x4,%edi
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
add    %eax,%edi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    %eax,%edi
add    -0x14(%rbp),%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%edi
shl    $0x5,%edi
mov    $0x8,%esi
call   1050 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
shl    $0x4,%edi
mov    $0xc,%esi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%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    116b <main+0x2b>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x3d0900,%edi
call   1040 <malloc@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
movl   $0x6,0x14(%rsp)
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r14d,%r14d
mov    0x20(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %rax,0x18(%rsp)
mov    0x18(%rsp),%rdi
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1060 <sqrt@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1060 <sqrt@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%r14,8)
mov    0x14(%rsp),%r15d
mov    %r15d,%edi
imul   %r14d,%edi
add    %r14d,%edi
call   1060 <sqrt@plt>
movsd  0x0(%r13,%r14,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%r14,8)
mov    0x18(%rsp),%rdi
mov    $0x8,%esi
call   1050 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
mov    $0xc,%esi
call   1050 <pow@plt>
mov    0x18(%rsp),%rax
addsd  0x8(%rsp),%xmm0
addsd  0x0(%r13,%r14,8),%xmm0
movsd  %xmm0,0x0(%r13,%r14,8)
add    $0x1,%r14
add    $0x10,%r12d
add    $0x7,%ebx
add    $0x18,%ebp
add    $0x20,%eax
add    $0x200,%r15d
mov    %r15d,0x14(%rsp)
cmp    $0x7a120,%r14
jne    1180 <main+0x40>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @malloc(i32 4000000)
%9 = inttoptr i64 %8 to double*
store double* %9, double** %7
store i32 0, i32* %6
br label %10
10: ; preds = %70, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 500000
br i1 %12, label %13, label %73
13: ; preds = %10
%14 = load i32, i32* %6
%15 = mul nsw i32 %14, 32
%16 = call double @sqrt(i32 %15)
%17 = load i32, i32* %6
%18 = mul nsw i32 %17, 16
%19 = load i32, i32* %6
%20 = mul nsw i32 %19, 8
%21 = add nsw i32 %18, %20
%22 = call double @sqrt(i32 %21)
%23 = fadd double %16, %22
%24 = load i32, i32* %6
%25 = mul nsw i32 %24, 4
%26 = load i32, i32* %6
%27 = mul nsw i32 %26, 2
%28 = add nsw i32 %25, %27
%29 = load i32, i32* %6
%30 = add nsw i32 %28, %29
%31 = call double @sqrt(i32 %30)
%32 = fadd double %23, %31
%33 = load double*, double** %7
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
%37 = load i32, i32* %6
%38 = mul nsw i32 %37, 32
%39 = load i32, i32* %6
%40 = mul nsw i32 %38, %39
%41 = mul nsw i32 %40, 16
%42 = load i32, i32* %6
%43 = mul nsw i32 %42, 4
%44 = add nsw i32 %41, %43
%45 = load i32, i32* %6
%46 = mul nsw i32 %45, 2
%47 = add nsw i32 %44, %46
%48 = load i32, i32* %6
%49 = add nsw i32 %47, %48
%50 = call double @sqrt(i32 %49)
%51 = load double*, double** %7
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fsub double %55, %50
store double %56, double* %54
%57 = load i32, i32* %6
%58 = mul nsw i32 %57, 32
%59 = call double @pow(i32 %58, i32 8)
%60 = load i32, i32* %6
%61 = mul nsw i32 %60, 16
%62 = call double @pow(i32 %61, i32 12)
%63 = fadd double %59, %62
%64 = load double*, double** %7
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = fadd double %68, %63
store double %69, double* %67
br label %70
70: ; preds = %13
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %10
73: ; preds = %10
%74 = load double*, double** %7
%75 = call i32 @free(double* %74)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 4000000)
%4 = inttoptr i64 %3 to double*
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %34, %5 ]
%7 = trunc i64 %6 to i32
%8 = trunc i64 %6 to i32
%9 = shl i32 %8, 5
%10 = tail call double @sqrt(i32 %9)
%11 = trunc i64 %6 to i32
%12 = mul i32 %11, 24
%13 = tail call double @sqrt(i32 %12)
%14 = fadd double %10, %13
%15 = trunc i64 %6 to i32
%16 = mul i32 %15, 7
%17 = tail call double @sqrt(i32 %16)
%18 = fadd double %14, %17
%19 = getelementptr inbounds double, double* %4, i64 %6
store double %18, double* %19
%20 = shl i32 %7, 9
%21 = or i32 %20, 6
%22 = mul i32 %21, %7
%23 = add i32 %22, %7
%24 = tail call double @sqrt(i32 %23)
%25 = load double, double* %19
%26 = fsub double %25, %24
store double %26, double* %19
%27 = tail call double @pow(i32 %9, i32 8)
%28 = trunc i64 %6 to i32
%29 = shl i32 %28, 4
%30 = tail call double @pow(i32 %29, i32 12)
%31 = fadd double %27, %30
%32 = load double, double* %19
%33 = fadd double %32, %31
store double %33, double* %19
%34 = add nuw nsw i64 %6, 1
%35 = icmp eq i64 %34, 500000
br i1 %35, label %36, label %5
36: ; preds = %5
%37 = tail call i32 @free(double* %4)
ret i32 0
}