#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 */
double *calloc(int, int);
int /*<<< orphan*/ free(void *);
int main(void) {
  volatile double *a;
  a = calloc(100, sizeof *a);
  for (size_t i = 0; i < 100; ++i) {
    a[i] = a[i];
  }
  free((void *)a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x64,-0x18(%rbp)
jae    1180 <main+0x60>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114a <main+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x64,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    $0x4,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x20(%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rax,%rcx,8)
movsd  -0x18(%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rax,%rcx,8)
movsd  -0x10(%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rax,%rcx,8)
movsd  -0x8(%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rax,%rcx,8)
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x5,%rcx
cmp    $0x68,%rcx
jne    1140 <main+0x20>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca i64
store i32 0, i32* %1
%4 = call double* @calloc(i32 100, i32 8)
store double* %4, double** %2
store i64 0, i64* %3
br label %5
5: ; preds = %16, %0
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 100
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load double*, double** %2
%10 = load i64, i64* %3
%11 = getelementptr inbounds double, double* %9, i64 %10
%12 = load volatile double, double* %11
%13 = load double*, double** %2
%14 = load i64, i64* %3
%15 = getelementptr inbounds double, double* %13, i64 %14
store volatile double %12, double* %15
br label %16
16: ; preds = %8
%17 = load i64, i64* %3
%18 = add i64 %17, 1
store i64 %18, i64* %3
br label %5
19: ; preds = %5
%20 = load double*, double** %2
%21 = bitcast double* %20 to i8*
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call double* @calloc(i32 100, i32 8)
br label %5
2: ; preds = %5
%3 = bitcast double* %1 to i8*
%4 = tail call i32 @free(i8* %3)
ret i32 0
5: ; preds = %5, %0
%6 = phi i64 [ 0, %0 ], [ %21, %5 ]
%7 = getelementptr inbounds double, double* %1, i64 %6
%8 = load volatile double, double* %7
store volatile double %8, double* %7
%9 = add nuw nsw i64 %6, 1
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = load volatile double, double* %10
store volatile double %11, double* %10
%12 = add nuw nsw i64 %6, 2
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load volatile double, double* %13
store volatile double %14, double* %13
%15 = add nuw nsw i64 %6, 3
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = load volatile double, double* %16
store volatile double %17, double* %16
%18 = add nuw nsw i64 %6, 4
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = load volatile double, double* %19
store volatile double %20, double* %19
%21 = add nuw nsw i64 %6, 5
%22 = icmp eq i64 %21, 100
br i1 %22, label %2, label %5
}