#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 int /*<<< orphan*/ time_t;

/* Variables and functions */
double RAND_MAX;
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void init_sym_matrix_packed(double *AP, int n) {
  int i, j, k;
  srand((unsigned)time((time_t *)NULL));
  k = 0;
  for (j = 0; j < n; j++)
    for (i = j; i < n; i++)
      AP[k++] = (double)rand() / RAND_MAX;
}


x86 assembly (clang, -O0):
<init_sym_matrix_packed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <init_sym_matrix_packed+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <init_sym_matrix_packed+0x87>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e5a(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <init_sym_matrix_packed+0x3f>
jmp    11bc <init_sym_matrix_packed+0x8c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <init_sym_matrix_packed+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_sym_matrix_packed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    11b3 <init_sym_matrix_packed+0x83>
mov    0x2e8b(%rip),%r12
mov    0x4(%rsp),%r14d
xor    %ebp,%ebp
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rbp
mov    %r14d,%r15d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r12),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
add    $0xffffffff,%r15d
jne    1180 <init_sym_matrix_packed+0x50>
add    $0x1,%r13d
add    $0xffffffff,%r14d
cmp    0x4(%rsp),%r13d
jne    1170 <init_sym_matrix_packed+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @init_sym_matrix_packed(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%8 = call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %7
store i32 0, i32* %6
br label %11
11: ; preds = %35, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = load i32, i32* %6
store i32 %16, i32* %5
br label %17
17: ; preds = %31, %15
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = call i64 (...) @rand()
%23 = sitofp i64 %22 to double
%24 = load double, double* @RAND_MAX
%25 = fdiv double %23, %24
%26 = load double*, double** %3
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
store double %25, double* %30
br label %31
31: ; preds = %21
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %17
34: ; preds = %17
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %11
38: ; preds = %11
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @init_sym_matrix_packed(double* nocapture writeonly %0, i32 %1) {
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %26
7: ; preds = %2, %23
%8 = phi i64 [ %19, %23 ], [ 0, %2 ]
%9 = phi i32 [ %24, %23 ], [ 0, %2 ]
%10 = shl i64 %8, 32
%11 = ashr exact i64 %10, 32
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ %11, %7 ], [ %19, %12 ]
%14 = phi i32 [ %9, %7 ], [ %21, %12 ]
%15 = tail call i64 (...) @rand()
%16 = sitofp i64 %15 to double
%17 = load double, double* @RAND_MAX
%18 = fdiv double %16, %17
%19 = add nsw i64 %13, 1
%20 = getelementptr inbounds double, double* %0, i64 %13
store double %18, double* %20
%21 = add nuw i32 %14, 1
%22 = icmp eq i32 %21, %1
br i1 %22, label %23, label %12
23: ; preds = %12
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, %1
br i1 %25, label %26, label %7
26: ; preds = %23, %2
ret void
}