// File: /workspace/github_c_makefile_star2_O3/schroeder-lvb[P]sissm/src/pirebooter.c
// Function: pirebooterInitConfig
int pirebooterInitConfig( void )
{
    cfsPtr cP;

    cP = cfsCreate( sissmGetConfigPath() );

    // read "pirebooter.pluginstate" variable from the .cfg file
    pirebooterConfig.pluginState = (int) cfsFetchNum( cP, "pirebooter.pluginState", 0.0 );  // disabled by default
    pirebooterConfig.rebootIdleSec = (long int) cfsFetchNum( cP, "pirebooter.rebootidlesec", (double)   20*60 );
    pirebooterConfig.rebootBusySec = (long int) cfsFetchNum( cP, "pirebooter.rebootbusysec", (double) 5*60*60 );
    pirebooterConfig.rebootDeadSec = (long int) cfsFetchNum( cP, "pirebooter.rebootdeadsec", (double)    5*60 );
    pirebooterConfig.rebootHungSec = (long int) cfsFetchNum( cP, "pirebooter.reboothungsec", (double)   20*60 );

    pirebooterConfig.rebootOnEOR   = (long int) cfsFetchNum( cP, "pirebooter.rebootoneor",   (double)       0 );

    // read the daily reboot time, e.g., "19:03".  Add colon "19:03:" so that it can be pattern
    // checked quickly against HH:MM:SS system clockstring and not get mistaken for MM:SS check.
    //
    strlcpy( pirebooterConfig.rebootDailyHM, cfsFetchStr( cP, "pirebooter.rebootDailyHM", "99:99"), CFS_FETCH_MAX );
    if ( 5 == strlen( pirebooterConfig.rebootDailyHM )) 
        strlcat( pirebooterConfig.rebootDailyHM, ":", CFS_FETCH_MAX );
    else
        strlcat( pirebooterConfig.rebootDailyHM, "99:99:", CFS_FETCH_MAX );

    pirebooterConfig.logUpdateSec  = (int)      cfsFetchNum( cP, "pirebooter.logUpdateSec",  (double)      60 );

    strlcpy( pirebooterConfig.rebootWarning, 
        cfsFetchStr( cP, "pirebooter.rebootWarning", "Server restart at end of round - up in 60sec" ), CFS_FETCH_MAX);
    strlcpy( pirebooterConfig.rebootDaily, 
        cfsFetchStr( cP, "pirebooter.rebootDaily", "** Server will reboot shortly - up in 60sec" ), CFS_FETCH_MAX);

    cfsDestroy( cP );
    
    pirebooterConfig.timeLastReboot = apiTimeGet();
    pirebooterConfig.timeLastProgress = apiTimeGet();
    pirebooterConfig.timeFirstIdle  = 0;

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x8970
movq %rax, %rdi
callq 0x8ffc
movq %rax, %rbx
leaq 0xf535(%rip), %rsi      # 0x1cb10
xorpd %xmm0, %xmm0
movq %rax, %rdi
callq 0x926a
cvttsd2si %xmm0, %eax
movl %eax, 0x6de8f(%rip)     # 0x7b480
leaq 0xf52f(%rip), %rsi      # 0x1cb27
movsd 0xf4f0(%rip), %xmm0     # 0x1caf0
movq %rbx, %rdi
callq 0x926a
cvttsd2si %xmm0, %rax
movq %rax, 0x6de74(%rip)     # 0x7b488
leaq 0xf525(%rip), %rsi      # 0x1cb40
movsd 0xf4d5(%rip), %xmm0     # 0x1caf8
movq %rbx, %rdi
callq 0x926a
cvttsd2si %xmm0, %rax
movq %rax, 0x6de59(%rip)     # 0x7b490
leaq 0xf51b(%rip), %rsi      # 0x1cb59
movsd 0xf4ba(%rip), %xmm0     # 0x1cb00
movq %rbx, %rdi
callq 0x926a
cvttsd2si %xmm0, %rax
movq %rax, 0x6de3e(%rip)     # 0x7b498
leaq 0xf511(%rip), %rsi      # 0x1cb72
movq %rbx, %rdi
movsd 0xf484(%rip), %xmm0     # 0x1caf0
callq 0x926a
cvttsd2si %xmm0, %rax
movq %rax, 0x6de23(%rip)     # 0x7b4a0
leaq 0xf507(%rip), %rsi      # 0x1cb8b
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x926a
cvttsd2si %xmm0, %rax
movq %rax, 0x6e20c(%rip)     # 0x7b8a8
leaq 0xf4ff(%rip), %rsi      # 0x1cba2
leaq 0xf511(%rip), %rdx      # 0x1cbbb
movq %rbx, %rdi
callq 0x9073
leaq 0x6ddef(%rip), %r14     # 0x7b4a8
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
movq %rax, %rsi
callq 0xf384
movq %r14, %rdi
callq 0x8120
cmpq $0x5, %rax
leaq 0x107a1(%rip), %rax     # 0x1de7d
leaq 0xf4de(%rip), %rsi      # 0x1cbc1
cmoveq %rax, %rsi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
callq 0xf310
leaq 0xf4cd(%rip), %rsi      # 0x1cbc8
movsd 0xf405(%rip), %xmm0     # 0x1cb08
movq %rbx, %rdi
callq 0x926a
cvttsd2si %xmm0, %eax
movl %eax, 0x6dd6f(%rip)     # 0x7b484
leaq 0xf4c4(%rip), %rsi      # 0x1cbe0
leaq 0xf4d6(%rip), %rdx      # 0x1cbf9
movq %rbx, %rdi
callq 0x9073
leaq 0x6e196(%rip), %rdi     # 0x7b8c8
movl $0x400, %edx            # imm = 0x400
movq %rax, %rsi
callq 0xf384
leaq 0xf4e0(%rip), %rsi      # 0x1cc26
leaq 0xf4f0(%rip), %rdx      # 0x1cc3d
movq %rbx, %rdi
callq 0x9073
leaq 0x6e56c(%rip), %rdi     # 0x7bcc8
movl $0x400, %edx            # imm = 0x400
movq %rax, %rsi
callq 0xf384
movq %rbx, %rdi
callq 0x9054
callq 0x117c0
movq %rax, 0x6e133(%rip)     # 0x7b8b0
callq 0x117c0
movq %rax, 0x6e137(%rip)     # 0x7b8c0
movq $0x0, 0x6e124(%rip) # 0x7b8b8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq