// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0x0, 0x5ee8(%rip)      # 0x71b4
jne 0x12db
xorl %edi, %edi
callq 0x11a0
movl %eax, 0x5ed9(%rip)      # 0x71b4
movq 0x5d16(%rip), %r15      # 0x6ff8
movq (%r15), %rdi
movl 0x5ec9(%rip), %edx      # 0x71b4
leaq 0x2d88(%rip), %rsi      # 0x407a
xorl %eax, %eax
callq 0x1180
movl 0x5eb5(%rip), %edi      # 0x71b4
callq 0x1150
movslq 0x5e6d(%rip), %rbx      # 0x7178
incq %rbx
imulq 0x5eba(%rip), %rbx      # 0x71d0
movq %rbx, %r14
shlq $0x4, %r14
leaq 0x5eb4(%rip), %rdi      # 0x71d8
movl $0x80, %esi
movq %r14, %rdx
callq 0x1260
cmpq $0x0, 0x5e9f(%rip)      # 0x71d8
je 0x145b
leaq 0x5e9a(%rip), %rdi      # 0x71e0
movl $0x80, %esi
movq %r14, %rdx
callq 0x1260
cmpq $0x0, 0x5e85(%rip)      # 0x71e0
je 0x1472
addq %rbx, %rbx
cmpl $0x0, 0x5e59(%rip)      # 0x71c4
jne 0x13e2
testq %rbx, %rbx
jle 0x13af
xorl %r14d, %r14d
callq 0x12a0
cvtsi2sd %eax, %xmm0
divsd 0x2c82(%rip), %xmm0     # 0x4008
addsd 0x2c82(%rip), %xmm0     # 0x4010
cvtsi2sdl 0x5de2(%rip), %xmm1 # 0x7178
divsd %xmm1, %xmm0
movq 0x5e37(%rip), %rax      # 0x71d8
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x1375
cmpl $0x0, 0x5e16(%rip)      # 0x71cc
jne 0x1415
testq %rbx, %rbx
jle 0x13dc
movq 0x5e1c(%rip), %rax      # 0x71e0
xorl %ecx, %ecx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %rbx
jne 0x13d0
popq %rbx
popq %r14
popq %r15
retq
movq (%r15), %rdi
leaq 0x2ce7(%rip), %rsi      # 0x40d3
leaq 0x5dfd(%rip), %r14      # 0x71f0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1180
movq 0x5dd4(%rip), %rsi      # 0x71d8
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1a7c
testl %eax, %eax
je 0x13af
jmp 0x1446
movq (%r15), %rdi
leaq 0x2cda(%rip), %rsi      # 0x40f9
leaq 0x61ba(%rip), %r14      # 0x75e0
movq %r14, %rdx
xorl %eax, %eax
callq 0x1180
movq 0x5da9(%rip), %rsi      # 0x71e0
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1a7c
testl %eax, %eax
je 0x13dc
movq 0x5d8b(%rip), %rdi      # 0x71d8
callq 0x1030
movq 0x5d87(%rip), %rdi      # 0x71e0
jmp 0x148e
movq (%r15), %rcx
leaq 0x2c2b(%rip), %rdi      # 0x4090
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1250
jmp 0x1493
movq (%r15), %rcx
leaq 0x2c33(%rip), %rdi      # 0x40af
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x1250
movq 0x5d4a(%rip), %rdi      # 0x71d8
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1240