// File: /workspace/github_c_makefile_star2_O3/stanfordnlp[P]GloVe/src/glove.c
// Function: initialize_parameters
void initialize_parameters(void) {
    // TODO: return an error code when an error occurs, clean up in the calling routine
    if (seed == 0) {
        seed = time(0);
    }
    fprintf(stderr, "Using random seed %d\n", seed);
    srand(seed);
    long long a;
    long long W_size = 2 * vocab_size * (vector_size + 1); // +1 to allocate space for bias

    /* Allocate space for word vectors and context word vectors, and correspodning gradsq */
    a = posix_memalign((void **)&W, 128, W_size * sizeof(real)); // Might perform better than malloc
    if (W == NULL) {
        fprintf(stderr, "Error allocating memory for W\n");
        exit(1);
    }
    a = posix_memalign((void **)&gradsq, 128, W_size * sizeof(real)); // Might perform better than malloc
    if (gradsq == NULL) {
        fprintf(stderr, "Error allocating memory for gradsq\n");
        free(W);
        exit(1);
    }
    if (load_init_param) {
        // Load existing parameters
        fprintf(stderr, "\nLoading initial parameters from %s \n", init_param_file);
        if (load_init_file(init_param_file, W, W_size)) {
            free(W);
            free(gradsq);
            exit(1);
        }
    } else {
        // Initialize new parameters
        for (a = 0; a < W_size; ++a) {
            W[a] = (rand() / (real)RAND_MAX - 0.5) / vector_size;
        }
    }

    if (load_init_gradsq) {
        // Load existing squared gradients
        fprintf(stderr, "\nLoading initial squared gradients from %s \n", init_gradsq_file);
        if (load_init_file(init_gradsq_file, gradsq, W_size)) {
            free(W);
            free(gradsq);
            exit(1);
        }
    } else {
        // Initialize new squared gradients
        for (a = 0; a < W_size; ++a) {
            gradsq[a] = 1.0; // So initial value of eta is equal to initial learning rate
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl 0x5ef9(%rip), %edx      # 0x71b4
testl %edx, %edx
jne 0x12cf
xorl %edi, %edi
callq 0x1190
movq %rax, %rdx
movl %edx, 0x5ee5(%rip)      # 0x71b4
movq 0x5d22(%rip), %r15      # 0x6ff8
movq (%r15), %rdi
leaq 0x2dda(%rip), %rsi      # 0x40ba
xorl %eax, %eax
callq 0x1170
movl 0x5ec7(%rip), %edi      # 0x71b4
callq 0x1140
movslq 0x5e77(%rip), %rbx      # 0x7170
incq %rbx
imulq 0x5ecc(%rip), %rbx      # 0x71d0
movq %rbx, %r14
shlq $0x4, %r14
leaq 0x5ec6(%rip), %rdi      # 0x71d8
movl $0x80, %esi
movq %r14, %rdx
callq 0x1250
cmpq $0x0, 0x5eb1(%rip)      # 0x71d8
je 0x1449
leaq 0x5eac(%rip), %rdi      # 0x71e0
movl $0x80, %esi
movq %r14, %rdx
callq 0x1250
cmpq $0x0, 0x5e97(%rip)      # 0x71e0
je 0x1460
addq %rbx, %rbx
cmpl $0x0, 0x5e6b(%rip)      # 0x71c4
jne 0x13d0
testq %rbx, %rbx
jle 0x139d
xorl %r14d, %r14d
callq 0x1290
cvtsi2sd %eax, %xmm0
divsd 0x2c94(%rip), %xmm0     # 0x4008
addsd 0x2c94(%rip), %xmm0     # 0x4010
cvtsi2sdl 0x5dec(%rip), %xmm1 # 0x7170
divsd %xmm1, %xmm0
movq 0x5e49(%rip), %rax      # 0x71d8
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x1363
cmpl $0x0, 0x5e28(%rip)      # 0x71cc
jne 0x1403
testq %rbx, %rbx
jle 0x13ca
movq 0x5e2e(%rip), %rax      # 0x71e0
xorl %ecx, %ecx
movapd 0x2c74(%rip), %xmm0     # 0x4030
movupd %xmm0, (%rax,%rcx,8)
addq $0x2, %rcx
cmpq %rcx, %rbx
jne 0x13bc
popq %rbx
popq %r14
popq %r15
retq
movq (%r15), %rdi
leaq 0x2d39(%rip), %rsi      # 0x4113
leaq 0x5e0f(%rip), %r14      # 0x71f0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq 0x5de6(%rip), %rsi      # 0x71d8
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1adc
testl %eax, %eax
je 0x139d
jmp 0x1434
movq (%r15), %rdi
leaq 0x2d2c(%rip), %rsi      # 0x4139
leaq 0x61cc(%rip), %r14      # 0x75e0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq 0x5dbb(%rip), %rsi      # 0x71e0
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1adc
testl %eax, %eax
je 0x13ca
movq 0x5d9d(%rip), %rdi      # 0x71d8
callq 0x1030
movq 0x5d99(%rip), %rdi      # 0x71e0
jmp 0x147c
movq (%r15), %rcx
leaq 0x2c7d(%rip), %rdi      # 0x40d0
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1240
jmp 0x1481
movq (%r15), %rcx
leaq 0x2c85(%rip), %rdi      # 0x40ef
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x1240
movq 0x5d5c(%rip), %rdi      # 0x71d8
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1230