// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x138, %rsp            # imm = 0x138
movl $0x0, 0x134(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x29c0
testb $0x1, %al
jne 0x25c1
callq 0x2860
movl %eax, 0x134(%rsp)
jmp 0x2843
movw $0xf0, 0x28(%rsp)
movl $0x4500, 0x2c(%rsp)     # imm = 0x4500
movw $0xf, 0x30(%rsp)
movl $0x4500, 0x34(%rsp)     # imm = 0x4500
movw $0x0, 0x38(%rsp)
movl $0x100000, 0x3c(%rsp)   # imm = 0x100000
leaq 0x28(%rsp), %rax
addq $0xe8, %rax
movq %rax, 0x10(%rsp)
movq 0x13c5b(%rip), %rax     # 0x16260
movq %rax, 0x18(%rsp)
movq 0x13c4f(%rip), %rdi     # 0x16260
movl $0x20, %esi
callq 0x21d0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
movl $0x20, %esi
callq 0x83d0
leaq 0x28(%rsp), %rdi
callq 0x29e0
testb $0x1, %al
jne 0x2651
callq 0x2860
movl %eax, 0x134(%rsp)
jmp 0x2843
movq 0x13c10(%rip), %rdi     # 0x16268
callq 0xc7a0
leaq 0xd9ce(%rip), %rdi      # 0x10032
movl $0xff, %esi
movl $0x1400, %edx           # imm = 0x1400
callq 0x3360
movl %eax, 0x24(%rsp)
xorl %eax, %eax
cmpl 0x24(%rsp), %eax
jne 0x2690
callq 0x2860
movl %eax, 0x134(%rsp)
jmp 0x2843
leaq 0xd9ae(%rip), %rdi      # 0x10045
leaq 0xd9c1(%rip), %rsi      # 0x1005f
movb $0x0, %al
callq 0x2a70
leaq 0xd9cf(%rip), %rdi      # 0x1007b
movb $0x0, %al
callq 0x2a70
leaq 0xd9fc(%rip), %rdi      # 0x100b6
movb $0x0, %al
callq 0x2a70
leaq 0xda0f(%rip), %rdi      # 0x100d7
leaq 0xda66(%rip), %rsi      # 0x10135
leaq 0xda64(%rip), %rdx      # 0x1013a
movl $0x157c, %ecx           # imm = 0x157C
movb $0x0, %al
callq 0x2a70
leaq 0xda5e(%rip), %rdi      # 0x10147
movl $0x2, %esi
movl $0x9, %edx
movl $0x4, %ecx
movsd 0xd910(%rip), %xmm0     # 0x10010
movb $0x1, %al
callq 0x2bf0
leaq 0xda78(%rip), %rdi      # 0x10186
leaq 0xdab2(%rip), %rsi      # 0x101c7
movl $0xa869, %edx           # imm = 0xA869
leaq 0xdab2(%rip), %rcx      # 0x101d3
movb $0x0, %al
callq 0x2d00
leaq 0xdaa8(%rip), %rdi      # 0x101d7
leaq 0xd9ff(%rip), %rsi      # 0x10135
movsd 0xd8ca(%rip), %xmm0     # 0x10008
movb $0x1, %al
callq 0x2e10
leaq 0xdad0(%rip), %rdi      # 0x1021c
leaq 0xdb0c(%rip), %rsi      # 0x1025f
movb $0x0, %al
callq 0x2f20
movq 0x13aff(%rip), %rdi     # 0x16260
callq 0x3870
testb $0x1, %al
jne 0x2776
leaq 0xdb17(%rip), %rdi      # 0x10288
callq 0x28b0
movl $0x2000, %edi           # imm = 0x2000
callq 0x3810
testb $0x1, %al
jne 0x2790
leaq 0xdb1c(%rip), %rdi      # 0x102a7
callq 0x28b0
movl $0xf, %edi
callq 0x37b0
testb $0x1, %al
jne 0x27aa
leaq 0xdb26(%rip), %rdi      # 0x102cb
callq 0x28b0
leaq 0xdb3d(%rip), %rdi      # 0x102ee
movb $0x0, %al
callq 0x3030
leaq 0xdb98(%rip), %rdi      # 0x10357
leaq 0xdbc1(%rip), %rsi      # 0x10387
movb $0x0, %al
callq 0x3140
leaq 0xdbbd(%rip), %rdi      # 0x10391
leaq 0xdbee(%rip), %rsi      # 0x103c9
movb $0x0, %al
callq 0x3250
leaq 0xdbe6(%rip), %rdi      # 0x103cf
movb $0x0, %al
callq 0x2a70
leaq 0xdbef(%rip), %rdi      # 0x103e6
movl $0x1, %esi
movb $0x0, %al
callq 0x2a70
movl 0x24(%rsp), %edi
callq 0x3390
testb $0x1, %al
jne 0x281c
leaq 0xdc07(%rip), %rdi      # 0x1041e
callq 0x28b0
callq 0x2a00
testb $0x1, %al
jne 0x2827
jmp 0x282f
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x2838
callq 0x2860
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x134(%rsp)
movl 0x134(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
retq
nopw %cs:(%rax,%rax)