#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 */
typedef double img;

/* Variables and functions */
int /*<<< orphan*/ find_directions_save(double *, int, double *);
int /*<<< orphan*/ free(double *);
double *malloc(int);
void analyze(struct img *images, int num_points) {
  double *weights = malloc(sizeof(double) * 64);
  for (int i = 0; i < 64; i++) {
    weights[i] = 0.2;
  }
  find_directions_save(images, num_points, weights);
  free(images);
  free(weights);
}


x86 assembly (clang, -O0):
<analyze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    1181 <analyze+0x51>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1154 <analyze+0x24>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <find_directions_save@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x200,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movaps 0xeb3(%rip),%xmm0
movups %xmm0,(%rax)
movups %xmm0,0x10(%rax)
movups %xmm0,0x20(%rax)
movups %xmm0,0x30(%rax)
movups %xmm0,0x40(%rax)
movups %xmm0,0x50(%rax)
movups %xmm0,0x60(%rax)
movups %xmm0,0x70(%rax)
movups %xmm0,0x80(%rax)
movups %xmm0,0x90(%rax)
movups %xmm0,0xa0(%rax)
movups %xmm0,0xb0(%rax)
movups %xmm0,0xc0(%rax)
movups %xmm0,0xd0(%rax)
movups %xmm0,0xe0(%rax)
movups %xmm0,0xf0(%rax)
movups %xmm0,0x100(%rax)
movups %xmm0,0x110(%rax)
movups %xmm0,0x120(%rax)
movups %xmm0,0x130(%rax)
movups %xmm0,0x140(%rax)
movups %xmm0,0x150(%rax)
movups %xmm0,0x160(%rax)
movups %xmm0,0x170(%rax)
movups %xmm0,0x180(%rax)
movups %xmm0,0x190(%rax)
movups %xmm0,0x1a0(%rax)
movups %xmm0,0x1b0(%rax)
movups %xmm0,0x1c0(%rax)
movups %xmm0,0x1d0(%rax)
movups %xmm0,0x1e0(%rax)
movups %xmm0,0x1f0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1040 <find_directions_save@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.img = type opaque
define void @analyze(%struct.img* %0, i32 %1) {
%3 = alloca %struct.img*
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
store %struct.img* %0, %struct.img** %3
store i32 %1, i32* %4
%7 = call double* @malloc(i32 512)
store double* %7, double** %5
store i32 0, i32* %6
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 64
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load double*, double** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
store double 2.000000e-01, double* %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %8
19: ; preds = %8
%20 = load %struct.img*, %struct.img** %3
%21 = bitcast %struct.img* %20 to double*
%22 = load i32, i32* %4
%23 = load double*, double** %5
%24 = call i32 @find_directions_save(double* %21, i32 %22, double* %23)
%25 = load %struct.img*, %struct.img** %3
%26 = bitcast %struct.img* %25 to double*
%27 = call i32 @free(double* %26)
%28 = load double*, double** %5
%29 = call i32 @free(double* %28)
ret void
}

LLVM IR (-O2):
%struct.img = type opaque
define void @analyze(%struct.img* %0, i32 %1) {
%3 = tail call double* @malloc(i32 512)
%4 = bitcast double* %3 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %4
%5 = getelementptr inbounds double, double* %3, i64 2
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %6
%7 = getelementptr inbounds double, double* %3, i64 4
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %8
%9 = getelementptr inbounds double, double* %3, i64 6
%10 = bitcast double* %9 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %10
%11 = getelementptr inbounds double, double* %3, i64 8
%12 = bitcast double* %11 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %12
%13 = getelementptr inbounds double, double* %3, i64 10
%14 = bitcast double* %13 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %14
%15 = getelementptr inbounds double, double* %3, i64 12
%16 = bitcast double* %15 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %16
%17 = getelementptr inbounds double, double* %3, i64 14
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %18
%19 = getelementptr inbounds double, double* %3, i64 16
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %20
%21 = getelementptr inbounds double, double* %3, i64 18
%22 = bitcast double* %21 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %22
%23 = getelementptr inbounds double, double* %3, i64 20
%24 = bitcast double* %23 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %24
%25 = getelementptr inbounds double, double* %3, i64 22
%26 = bitcast double* %25 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %26
%27 = getelementptr inbounds double, double* %3, i64 24
%28 = bitcast double* %27 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %28
%29 = getelementptr inbounds double, double* %3, i64 26
%30 = bitcast double* %29 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %30
%31 = getelementptr inbounds double, double* %3, i64 28
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %32
%33 = getelementptr inbounds double, double* %3, i64 30
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %34
%35 = getelementptr inbounds double, double* %3, i64 32
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %36
%37 = getelementptr inbounds double, double* %3, i64 34
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %38
%39 = getelementptr inbounds double, double* %3, i64 36
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %40
%41 = getelementptr inbounds double, double* %3, i64 38
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %42
%43 = getelementptr inbounds double, double* %3, i64 40
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %44
%45 = getelementptr inbounds double, double* %3, i64 42
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %46
%47 = getelementptr inbounds double, double* %3, i64 44
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %48
%49 = getelementptr inbounds double, double* %3, i64 46
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %50
%51 = getelementptr inbounds double, double* %3, i64 48
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %52
%53 = getelementptr inbounds double, double* %3, i64 50
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %54
%55 = getelementptr inbounds double, double* %3, i64 52
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %56
%57 = getelementptr inbounds double, double* %3, i64 54
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %58
%59 = getelementptr inbounds double, double* %3, i64 56
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %60
%61 = getelementptr inbounds double, double* %3, i64 58
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %62
%63 = getelementptr inbounds double, double* %3, i64 60
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %64
%65 = getelementptr inbounds double, double* %3, i64 62
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> <double 2.000000e-01, double 2.000000e-01>, <2 x double>* %66
%67 = bitcast %struct.img* %0 to double*
%68 = tail call i32 @find_directions_save(double* %67, i32 %1, double* %3)
%69 = tail call i32 @free(double* %67)
%70 = tail call i32 @free(double* %3)
ret void
}