#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int);
double rand_in_range(double, double);
double *generate_random_initial_path(int nt, double min, double max) {
  int i;
  double *path = malloc(nt * sizeof(double));
  printf("Generating a random initial path of length %d\n", nt);
  for (i = 0; i < nt; i++) {
    path[i] = rand_in_range(min, max);
  }
  return path;
}


x86 assembly (clang, -O0):
<generate_random_initial_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a4 <generate_random_initial_path+0x74>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <rand_in_range@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <generate_random_initial_path+0x3e>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_random_initial_path>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
lea    0xea2(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
test   %r14d,%r14d
jle    118f <generate_random_initial_path+0x5f>
mov    %r14d,%r14d
xor    %ebx,%ebx
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1050 <rand_in_range@plt>
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <generate_random_initial_path+0x40>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Generating a random initial path of length %d\0A\00"
define double* @generate_random_initial_path(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double*
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call double* @malloc(i32 %12)
store double* %13, double** %8
%14 = load i32, i32* %4
%15 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %28, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load double, double* %5
%22 = load double, double* %6
%23 = call double @rand_in_range(double %21, double %22)
%24 = load double*, double** %8
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double %23, double* %27
br label %28
28: ; preds = %20
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %16
31: ; preds = %16
%32 = load double*, double** %8
ret double* %32
}

LLVM IR (-O2):
@.str = [47 x i8] c"Generating a random initial path of length %d\0A\00"
define noalias double* @generate_random_initial_path(i32 %0, double %1, double %2) {
%4 = shl i32 %0, 3
%5 = tail call double* @malloc(i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %0)
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %14, %10 ]
%12 = tail call double @rand_in_range(double %1, double %2)
%13 = getelementptr inbounds double, double* %5, i64 %11
store double %12, double* %13
%14 = add nuw nsw i64 %11, 1
%15 = icmp eq i64 %14, %9
br i1 %15, label %16, label %10
16: ; preds = %10, %3
ret double* %5
}