// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/example/example.c
// Function: main
int main(void) {
    /*
     * Instantiate the libsir initialization struct and customize the configuration.
     *
     * NOTE: It is not necessary to retain this structure in memory;
     * libsir makes a copy of it before returning from ::sir_init.
     */

    sirinit si;
    if (!sir_makeinit(&si))
        return report_error();

    /* Levels for stdout: send debug, information, warning, and notice there. */
    si.d_stdout.levels = SIRL_DEBUG | SIRL_INFO | SIRL_WARN | SIRL_NOTICE;

    /* Options for stdout: don't show the timestamp, hostname, or thread ID. */
    si.d_stdout.opts = SIRO_NOTIME | SIRO_NOHOST | SIRO_NOTID;

    /* Levels for stderr: send error and above there. */
    si.d_stderr.levels = SIRL_ERROR | SIRL_CRIT | SIRL_ALERT | SIRL_EMERG;

    /* Options for stderr: don't show the timestamp, hostname, or thread ID. */
    si.d_stderr.opts = SIRO_NOTIME | SIRO_NOHOST | SIRO_NOTID;

    /* Levels for the system logger: don't send any output there. */
    si.d_syslog.levels = SIRL_NONE;

    /* Options for the system logger: use the default value. */
    si.d_syslog.opts = SIRO_DEFAULT;

    /* Configure a name to associate with our output. */
    static const char* appname = "MyFooServer";
    (void)_sir_strncpy(si.name, SIR_MAXNAME, appname, strnlen(appname, SIR_MAXNAME));

    /* Initialize libsir. */
    if (!sir_init(&si))
        return report_error();

    /* Set a friendly name for the current thread. */
    static const char* thread_name = "example[main]";
    (void)_sir_setthreadname(thread_name);

    /*
     * Configure and add a log file; don't log the process name or hostname,
     * and send all levels there.
     */

    sirfileid fileid = sir_addfile("libsir-example.log", SIRL_ALL, SIRO_NONAME | SIRO_NOHOST);
    if (0 == fileid)
        return report_error();

    /*
     * Ready to start logging. The messages passed to sir_debug() will be sent
     * to all destinations registered for the ::SIRL_DEBUG level. In our example,
     * that is stdout and 'libsir-example.log'.
     */

    /* Notice that it is not necessary to include a newline */
    (void)sir_debug("Reading config file %s...", "/usr/local/myapp/myapp.conf");

    /* Pretend to read a config file */
    (void)sir_debug("Config file successfully parsed; connecting to database...");

    /* Pretend to connect to a database */
    (void)sir_debug("Database connection established.");
    (void)sir_debug("Binding a TCP socket to interface '%s'"
                    " (IPv4: %s) on port %u and listening for connections...",
                    "eth0", "120.22.140.8", 5500);

    /*
     * Log a message for each of the remaining severity levels. Only up to
     * 'notice' will the messages be emitted from stdout; the rest will come from
     * stderr.
     */

    (void)sir_info("MyFooServer v%d.%d.%d (amd64) started successfully in %.2fsec.",
                   2, 9, 4, (double)1.94f);

    (void)sir_notice("Client at %s:%u (username: %s) failed 5 authentication attempts!",
                     "210.10.54.3", 43113, "bob");

    (void)sir_warn("Detected downgraded link speed on %s: last transfer rate: %.1f KiB/s",
                   "eth0", (double)219.4f);

    /* Hmm, what else could go wrong... */
    (void)sir_error("Failed to synchronize with node pool.846.myfooserver.io! Error:"
                    " %s", "connection reset by peer. Retry in 30sec");

    /*
     * We better set up logging to the system logger; things seem to be going poorly.
     *
     * Set up an identity, some options, and register for error and higher.
     *
     * NOTE: If this platform does not have a supported system logger, or the
     * SIR_NO_SYSTEM_LOGGERS preprocessor define was set when libsir was
     * compiled, these calls will fail and have no effect.
     */

    if (!sir_syslogid(appname))
        report_warning("Failed to set system logger ID");

    if (!sir_syslogopts(SIRO_NOPID))
        report_warning("Failed to set system logger options");

    if (!sir_sysloglevels(SIRL_ERROR | SIRL_CRIT | SIRL_ALERT | SIRL_EMERG))
        report_warning("Failed to set system logger levels");

    /* Okay, syslog should be configured now. Continue executing. */
    (void)sir_crit("Database query failure! Ignoring incoming client requests while"
                   " the database is analyzed and repaired...");

    /* Things just keep getting worse for this poor sysadmin. */
    (void)sir_alert("Database repair attempt unsuccessful! Error: %s", "<unknown>");
    (void)sir_emerg("Unable to process client requests for %s! Restarting...", "4m52s");

    (void)sir_debug("Begin server shutdown.");
    (void)sir_debug("If this was real, we would be exiting with code %d now!", 1);

    /* Deregister (and close) the log file. */
    if (!sir_remfile(fileid))
        report_warning("Failed to deregister log file");

    /*
     * Now, you can examine the terminal output, libsir-example.log, and
     * syslog to ensure that the library operated as expected.
     *
     * The last thing we have to do is uninitialize libsir by calling sir_cleanup().
     */

    return sir_cleanup() ? EXIT_SUCCESS : report_error();
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
leaq 0x8(%rsp), %rdi
callq 0x2890
testb %al, %al
je 0x27c0
leaq 0xf0(%rsp), %rdi
movw $0xf0, -0xe8(%rdi)
movl $0x4500, %eax           # imm = 0x4500
movl %eax, -0xe4(%rdi)
movw $0xf, -0xe0(%rdi)
movl %eax, -0xdc(%rdi)
andw $0x0, -0xd8(%rdi)
movl $0x100000, -0xd4(%rdi)  # imm = 0x100000
leaq 0x6a2b(%rip), %rdx      # 0x9018
pushq $0x20
popq %rsi
pushq $0xb
popq %rcx
callq 0x5401
leaq 0x8(%rsp), %rdi
callq 0x2895
testb %al, %al
je 0x27c0
leaq 0x6a13(%rip), %rdi      # 0x9024
callq 0x7245
leaq 0x6a15(%rip), %rdi      # 0x9032
movl $0xff, %esi
movl $0x1400, %edx           # imm = 0x1400
callq 0x2e57
testl %eax, %eax
je 0x27c0
movl %eax, %ebx
leaq 0x6a08(%rip), %rdi      # 0x9045
leaq 0x6a1b(%rip), %rsi      # 0x905f
xorl %eax, %eax
callq 0x28b9
leaq 0x6a29(%rip), %rdi      # 0x907b
xorl %eax, %eax
callq 0x28b9
leaq 0x6a56(%rip), %rdi      # 0x90b6
xorl %eax, %eax
callq 0x28b9
leaq 0x6a69(%rip), %rdi      # 0x90d7
leaq 0x6ac0(%rip), %r14      # 0x9135
leaq 0x6abe(%rip), %rdx      # 0x913a
movq %r14, %rsi
movl $0x157c, %ecx           # imm = 0x157C
xorl %eax, %eax
callq 0x28b9
leaq 0x6ab5(%rip), %rdi      # 0x9147
pushq $0x2
popq %rsi
pushq $0x9
popq %rdx
pushq $0x4
popq %rcx
movsd 0x6965(%rip), %xmm0     # 0x9008
movb $0x1, %al
callq 0x298e
leaq 0x6ad5(%rip), %rdi      # 0x9186
leaq 0x6b0f(%rip), %rsi      # 0x91c7
leaq 0x6b14(%rip), %rcx      # 0x91d3
movl $0xa869, %edx           # imm = 0xA869
xorl %eax, %eax
callq 0x2a3d
leaq 0x6b05(%rip), %rdi      # 0x91d7
movsd 0x6936(%rip), %xmm0     # 0x9010
movq %r14, %rsi
movb $0x1, %al
callq 0x2aec
leaq 0x6b31(%rip), %rdi      # 0x921c
leaq 0x6b6d(%rip), %rsi      # 0x925f
xorl %eax, %eax
callq 0x2b9b
leaq 0x6918(%rip), %rdi      # 0x9018
callq 0x30c4
testb %al, %al
jne 0x2715
leaq 0x6b78(%rip), %rdi      # 0x9288
callq 0x282c
movl $0x2000, %edi           # imm = 0x2000
callq 0x307f
testb %al, %al
jne 0x272f
leaq 0x6b7d(%rip), %rdi      # 0x92a7
callq 0x282c
pushq $0xf
popq %rdi
callq 0x303b
testb %al, %al
jne 0x2747
leaq 0x6b89(%rip), %rdi      # 0x92cb
callq 0x282c
leaq 0x6ba0(%rip), %rdi      # 0x92ee
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2c4a
leaq 0x6bf9(%rip), %rdi      # 0x9357
leaq 0x6c22(%rip), %rsi      # 0x9387
xorl %eax, %eax
callq 0x2cf9
leaq 0x6c1e(%rip), %rdi      # 0x9391
leaq 0x6c4f(%rip), %rsi      # 0x93c9
xorl %eax, %eax
callq 0x2da8
leaq 0x6c47(%rip), %rdi      # 0x93cf
xorl %eax, %eax
callq 0x28b9
leaq 0x6c50(%rip), %rdi      # 0x93e6
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x28b9
movl %ebx, %edi
callq 0x2e5c
testb %al, %al
jne 0x27b7
leaq 0x6c6c(%rip), %rdi      # 0x941e
callq 0x282c
callq 0x289a
testb %al, %al
jne 0x27c8
callq 0x27d6
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %rbp
retq