// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
pushq %rax
movl 0x5d56(%rip), %edx      # 0x71b4
testl %edx, %edx
jne 0x1472
xorl %edi, %edi
callq 0x1190
movq %rax, %rdx
movl %edx, 0x5d42(%rip)      # 0x71b4
movq 0x5b7f(%rip), %r15      # 0x6ff8
movq (%r15), %rdi
leaq 0x2c17(%rip), %rsi      # 0x409a
xorl %eax, %eax
callq 0x1170
movl 0x5d24(%rip), %edi      # 0x71b4
callq 0x1140
movslq 0x5cd4(%rip), %rbx      # 0x7170
incq %rbx
imulq 0x5d29(%rip), %rbx      # 0x71d0
movq %rbx, %r14
shlq $0x4, %r14
leaq 0x5d23(%rip), %rdi      # 0x71d8
movl $0x80, %esi
movq %r14, %rdx
callq 0x1250
cmpq $0x0, 0x5d0e(%rip)      # 0x71d8
je 0x15ed
leaq 0x5d09(%rip), %rdi      # 0x71e0
movl $0x80, %esi
movq %r14, %rdx
callq 0x1250
cmpq $0x0, 0x5cf4(%rip)      # 0x71e0
je 0x1604
addq %rbx, %rbx
cmpl $0x0, 0x5cc8(%rip)      # 0x71c4
jne 0x154a
xorl %r14d, %r14d
testq %rbx, %rbx
movl $0x0, %r12d
cmovgq %rbx, %r12
cmpq %r14, %r12
je 0x157f
callq 0x1290
cvtsi2sd %eax, %xmm0
divsd 0x2ae4(%rip), %xmm0     # 0x4008
addsd 0x2ae4(%rip), %xmm0     # 0x4010
cvtsi2sdl 0x5c3c(%rip), %xmm1 # 0x7170
divsd %xmm1, %xmm0
movq 0x5c99(%rip), %rax      # 0x71d8
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x150e
movq (%r15), %rdi
leaq 0x2b9f(%rip), %rsi      # 0x40f3
leaq 0x5c95(%rip), %r14      # 0x71f0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq 0x5c6c(%rip), %rsi      # 0x71d8
movq %r14, %rdi
movq %rbx, %rdx
callq 0x139c
testl %eax, %eax
jne 0x162d
cmpl $0x0, 0x5c46(%rip)      # 0x71cc
jne 0x15b0
movq 0x5c51(%rip), %rax      # 0x71e0
xorl %ecx, %ecx
testq %rbx, %rbx
cmovleq %rcx, %rbx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
cmpq %rcx, %rbx
je 0x15e1
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x15a2
movq (%r15), %rdi
leaq 0x2b5f(%rip), %rsi      # 0x4119
leaq 0x601f(%rip), %r14      # 0x75e0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq 0x5c0e(%rip), %rsi      # 0x71e0
movq %r14, %rdi
movq %rbx, %rdx
callq 0x139c
testl %eax, %eax
jne 0x162d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r15), %rcx
leaq 0x2ab9(%rip), %rdi      # 0x40b0
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1240
jmp 0x1625
movq (%r15), %rcx
leaq 0x2ac1(%rip), %rdi      # 0x40cf
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x1240
movq 0x5bb8(%rip), %rdi      # 0x71d8
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1230
movq 0x5ba4(%rip), %rdi      # 0x71d8
callq 0x1030
movq 0x5ba0(%rip), %rdi      # 0x71e0
jmp 0x1620