You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


/* Editor Settings: expandtabs and use 4 spaces for indentation
 * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
 * -*- mode: c, c-basic-offset: 4 -*- */

/*
 * Copyright © BeyondTrust Software 2004 - 2019
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * BEYONDTRUST MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING TERMS AS
 * WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT WITH
 * BEYONDTRUST, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE TERMS OF THAT
 * SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE APACHE LICENSE,
 * NOTWITHSTANDING THE ABOVE NOTICE.  IF YOU HAVE QUESTIONS, OR WISH TO REQUEST
 * A COPY OF THE ALTERNATE LICENSING TERMS OFFERED BY BEYONDTRUST, PLEASE CONTACT
 * BEYONDTRUST AT beyondtrust.com/contact
 */

#include "DomainJoinConfig.h"
#include <glade/glade.h>
#include <gtk/gtk.h>

#include <time.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>

#include <lw/attrs.h>

#include "joindialog.h"
#include "joinprogress.h"
#include "joinerror.h"
#include "joinauth.h"
#include "statusdialog.h"

#include <djapi.h>
#include <djlogger.h>
#include <djmodule.h>
#include <djhostinfo.h>
#include <djauthinfo.h>
#include <ctstrutils.h>

FILE* log_handle;

JOINSTATE join_state;
JoinDialog* global_join_dialog = NULL;
StatusDialog* global_status_dialog = NULL;


// This is a hack to prevent SCIM from being
// reloaded when we switch dialogs
static gboolean
close_stale_dialogs(gpointer data)
{
    if (global_join_dialog)
    {
        joindialog_delete(global_join_dialog);
        global_join_dialog = NULL;
    }

    if (global_status_dialog)
    {
        statusdialog_delete(global_status_dialog);
        global_status_dialog = NULL;
    }

    return FALSE;
}

static void
log_begin()
{
    log_handle = tmpfile();

    if (!log_handle)
    {
        fprintf(stderr, "Could not open log file: %s\n", strerror(errno));
        exit(1);
    }

    // Log to file
    dj_init_logging_to_file_handle(LOG_LEVEL_VERBOSE, log_handle);
}

static void
log_end()
{
    dj_close_log();
    log_handle = NULL;
}

static void
log_copy(const char* dest)
{
    char buffer[2048];
    FILE* destfile = fopen(dest, "w");
    size_t amount;

    fseek(log_handle, 0, SEEK_SET);

    while ((amount = fread(buffer, 1, sizeof(buffer), log_handle)) > 0)
    {
        if (fwrite(buffer, 1, amount, destfile) != amount)
        {
           break;
        }
    }

    clearerr(log_handle);
    fseek(log_handle, 0, SEEK_END);

    fclose(destfile);
}

static char*
safe_strdup(const char* src)
{
    if (!src)
        return NULL;
    else
        return strdup(src);
}

static
void
safe_free(void** ptr)
{
    if (*ptr)
        free(*ptr);
    *ptr = NULL;
}

#define SAFE_FREE(var) safe_free((void**)(void*) &var);

static void
fill_state(JoinDialog* dialog)
{
    SAFE_FREE(join_state.computer);
    SAFE_FREE(join_state.domain);
    SAFE_FREE(join_state.ou);
    join_state.ou_active = FALSE;
    join_state.noModifyHosts = FALSE;

    join_state.computer = safe_strdup(joindialog_get_computer_name(dialog));
    join_state.domain = safe_strdup(joindialog_get_domain_name(dialog));
    join_state.ou = safe_strdup(joindialog_get_ou_name(dialog));
    join_state.ou_active = joindialog_get_ou_active(dialog);
    join_state.noModifyHosts = !joindialog_get_modify_hosts(dialog);
    join_state.prefix = safe_strdup(joindialog_get_default_prefix(dialog));
}

static void
fill_state_auth(JoinAuthDialog* auth_dialog)
{
    SAFE_FREE(join_state.user);
    SAFE_FREE(join_state.password);

    join_state.user = safe_strdup(joinauth_get_user(auth_dialog));
    join_state.password = safe_strdup(joinauth_get_password(auth_dialog));
}

static
void
free_state()
{
    SAFE_FREE(join_state.computer);
    SAFE_FREE(join_state.domain);
    SAFE_FREE(join_state.prefix);
    SAFE_FREE(join_state.ou);

    SAFE_FREE(join_state.user);
    SAFE_FREE(join_state.password);
}

static
void
free_state_computer()
{
    SAFE_FREE(join_state.computer);
}

static
void
free_state_domain()
{
    SAFE_FREE(join_state.domain);
}

static
void
free_state_password()
{
    SAFE_FREE(join_state.password);
}

/* Dirty, horrible hacks to allow use of new file chooser dialog widget
   despite old RHEL3 build machine */

#if GTK_MINOR_VERSION < 6 && !defined(HAVE_GTK_FILE_CHOOSER_DIALOG_NEW)
#define GTK_FILE_CHOOSER_ACTION_SAVE 1
typedef int GtkFileChooserAction;
static GtkWidget *(*gtk_file_chooser_dialog_new)(const gchar *title,
                                       GtkWindow            *parent,
                                       GtkFileChooserAction  action,
                                       const gchar          *first_button_text,
                                       ...);
static const gchar* (*gtk_file_chooser_get_filename)(void*);
#define GTK_FILE_CHOOSER(ptr) ((void*)(ptr))
#endif

static void
show_error_dialog(GtkWindow* parent, LWException* exc)
{
#if !defined(HAVE_GTK_FILE_CHOOSE_DIALOG_NEW)
    if(gtk_minor_version < 6)
    {
        GtkDialog* dialog = GTK_DIALOG(
            gtk_message_dialog_new(
                parent,
                GTK_DIALOG_DESTROY_WITH_PARENT,
                GTK_MESSAGE_ERROR,
                GTK_BUTTONS_CLOSE,
                "%s: %s",
                exc->shortMsg,
                exc->longMsg));
        gtk_dialog_run(dialog);
        gtk_widget_destroy(GTK_WIDGET(dialog));
        return;
    }
    else
#endif
    {
        JoinErrorDialog* error_dialog = joinerror_new(parent, exc);
        int result;

#if GTK_MINOR_VERSION < 6 && !defined(HAVE_GTK_FILE_CHOOSER_DIALOG_NEW)
        {
            void* handle = dlopen(NULL, RTLD_LAZY);

            gtk_file_chooser_dialog_new = dlsym(handle, "gtk_file_chooser_dialog_new");
            gtk_file_chooser_get_filename = dlsym(handle, "gtk_file_chooser_get_filename");

            dlclose(handle);
        }
#endif

        do
        {
            switch ((result = joinerror_run(error_dialog)))
            {
            case JOINERROR_CLOSE:
                break;
            case JOINERROR_SAVE_LOG:
            {
                GtkDialog* file_dialog;

                file_dialog = GTK_DIALOG(gtk_file_chooser_dialog_new(
                                             "Save Log", parent, GTK_FILE_CHOOSER_ACTION_SAVE,
                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                             GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL));

                if (gtk_dialog_run(file_dialog) == GTK_RESPONSE_ACCEPT)
                {
                    log_copy(
                        gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_dialog)));
                }

                gtk_widget_destroy(GTK_WIDGET(file_dialog));
                break;
            }
            }
        } while (result != JOINERROR_CLOSE);

        joinerror_delete(error_dialog);
    }
}

typedef struct JoinInfo
{
    JoinProgressDialog* dialog;
    JoinProcessOptions options;
} JoinInfo;

static
void
PrintWarning(
    const JoinProcessOptions *options,
    const char *title,
    const char *message
    )
{
    LWException *_exc = NULL;
    PSTR warningTitle = NULL;

    if(!CTAllocateStringPrintf(&warningTitle, "Warning: %s", title))
    {
        LW_RAISE_EX(&_exc, LW_ERROR_DOMAINJOIN_WARNING, warningTitle, "%s", message);
        gdk_threads_enter();
        show_error_dialog(joinprogress_get_gtk_window(
                    (JoinProgressDialog *)options->userData), _exc);
        gdk_threads_leave();
    }
    LW_HANDLE(&_exc);
    CT_SAFE_FREE_STRING(warningTitle);
}

static
void*
join_worker(
    gpointer data
    )
{
    JoinInfo *info = (JoinInfo*) data;
    JoinProgressDialog* dialog = info->dialog;
    JoinProcessOptions *options = &info->options;
    LWException* exc = NULL;
    ModuleState *hostnameState;

    LW_TRY(&exc, DJInitModuleStates(options, &LW_EXC));
    joinprogress_update(dialog, 0.0, "Joining");

    hostnameState = DJGetModuleStateByName(options, "hostname");
    if(join_state.noModifyHosts)
    {
        if(hostnameState != NULL)
            hostnameState->disposition = DisableModule;
    }
    else if(hostnameState->lastResult < FullyConfigured)
        hostnameState->disposition = EnableModule;
    options->userData = dialog;
    options->warningCallback = PrintWarning;
    LW_TRY(&exc, DJRunJoinProcess(options, &LW_EXC));

cleanup:

    if (exc)
    {
        joinprogress_raise_error(dialog, exc);
    }
    else
    {
        joinprogress_done(dialog);
    }

    return NULL;
}

static
void*
leave_worker(gpointer data)
{
    JoinProgressDialog* dialog = (JoinProgressDialog*) data;
    JoinProcessOptions options;
    LWException* exc = NULL;

    DJZeroJoinProcessOptions(&options);
    options.joiningDomain = FALSE;
    options.warningCallback = PrintWarning;
    LW_CLEANUP_CTERR(&exc, DJGetComputerName(&options.computerName));
    LW_TRY(&exc, DJInitModuleStates(&options, &LW_EXC));

    joinprogress_update(dialog, 0.0, "Leaving");

    options.userData = dialog;
    LW_TRY(&exc, DJRunJoinProcess(&options, &LW_EXC));

cleanup:

    if (exc)
    {
        joinprogress_raise_error(dialog, exc);
    }
    else
    {
        joinprogress_done(dialog);
    }
    DJFreeJoinProcessOptions(&options);

    return NULL;
}

static
void
do_join(JoinDialog* dialog, LWException** exc)
{
    JoinProgressDialog* progress_dialog = NULL;
    JoinAuthDialog* auth_dialog = NULL;

    fill_state(dialog);
    auth_dialog = joinauth_new(&join_state, joindialog_get_gtk_window(dialog));

    if (!auth_dialog)
    {
        fprintf(stderr, "Could not create window: out of memory");
        exit(1);
    }

    if (joinauth_run(auth_dialog) == JOINAUTH_OK)
    {
        JoinInfo info = {0};

        fill_state_auth(auth_dialog);

        DJZeroJoinProcessOptions(&info.options);
        info.options.username = safe_strdup(join_state.user);
        info.options.password = safe_strdup(join_state.password);
        info.options.computerName = safe_strdup(join_state.computer);
        if (join_state.ou_active)
            info.options.ouName = safe_strdup(join_state.ou);
        else
            info.options.ouName = NULL;
        info.options.domainName = safe_strdup(join_state.domain);
        info.options.joiningDomain = TRUE;
        info.options.setAssumeDefaultDomain = TRUE;
        info.options.assumeDefaultDomain = join_state.prefix != NULL;
        info.options.userDomainPrefix = safe_strdup(join_state.prefix);

        joinauth_delete(auth_dialog);

        progress_dialog = joinprogress_new(joindialog_get_gtk_window(dialog), "Joining Domain");

        if (!progress_dialog)
        {
            fprintf(stderr, "Could not create window: out of memory");
            exit(1);
        }

        info.dialog = progress_dialog;

        g_thread_create(join_worker, &info, FALSE, NULL);

        if (joinprogress_run(progress_dialog) == JOINPROGRESS_ERROR)
        {
            LWException* _exc = joinprogress_get_error(progress_dialog);

            show_error_dialog(joindialog_get_gtk_window(dialog), _exc);

            LW_HANDLE(&_exc);

            // Now that the error has been displayed, switch
            // back to running the progress dialog so the user
            // can close it.
            joinprogress_run(progress_dialog);
        }

        joinprogress_delete(progress_dialog);
        DJFreeJoinProcessOptions(&info.options);
    }
    else
    {
        // Just close the dialog
        joinauth_delete(auth_dialog);
    }
}

static
gboolean
join_mode(PJOINSTATE pJoinState, LWException** exc)
{
    JoinDialog* dialog = NULL;
    int result;
    gboolean quit = FALSE;

    g_idle_add(close_stale_dialogs, NULL);

    dialog = joindialog_new(pJoinState);

    if (!dialog)
    {
        LW_CLEANUP_CTERR(exc, ERROR_OUTOFMEMORY);
    }

    switch ((result = joindialog_run(dialog)))
    {
        case JOINDIALOG_CLOSE:
        case GTK_RESPONSE_DELETE_EVENT:
            quit = TRUE;
            break;
        case JOINDIALOG_JOIN:
            LW_TRY(exc, do_join(dialog, &LW_EXC));
            quit = FALSE;
            break;
    }

cleanup:

    if (dialog)
        global_join_dialog = dialog;

    return quit;
}

static
gboolean
status_mode(LWException** exc)
{
    StatusDialog* dialog = NULL;
    int result;
    gboolean quit = FALSE;

    g_idle_add(close_stale_dialogs, NULL);

    dialog = statusdialog_new(join_state.computer, join_state.domain);

    if (!dialog)
    {
        LW_CLEANUP_CTERR(exc, ERROR_OUTOFMEMORY);
    }

    switch ((result = statusdialog_run(dialog)))
    {
        case STATUSDIALOG_CLOSE:
        case GTK_RESPONSE_DELETE_EVENT:
            quit = TRUE;
            break;
        case STATUSDIALOG_LEAVE:
        {
            JoinProgressDialog* progress_dialog;
            progress_dialog = joinprogress_new(
                                statusdialog_get_gtk_window(dialog),
                                "Leaving Domain");

            if (!progress_dialog)
            {
                fprintf(stderr, "Could not create window: out of memory");
                exit(1);
            }

            g_thread_create(leave_worker, progress_dialog, FALSE, NULL);

            if (joinprogress_run(progress_dialog) == JOINPROGRESS_ERROR)
            {
                LWException* _exc = joinprogress_get_error(progress_dialog);

                show_error_dialog(statusdialog_get_gtk_window(dialog), _exc);
                LW_HANDLE(&_exc);

                // Now that the error has been displayed, switch
                // back to running the progress dialog so the user
                // can close it.
                joinprogress_run(progress_dialog);
            }

            joinprogress_delete(progress_dialog);

            quit = FALSE;
            break;
        }
    }

cleanup:

    if (dialog)
        global_status_dialog = dialog;

    return quit;
}

void
ensure_gtk_version(int major, int minor, int micro, LWException** exc)
{
    const char* msg;

    if ((msg = gtk_check_version(major, minor, micro)))
    {
        LW_RAISE_EX(exc, ERROR_DLL_MIGHT_BE_INCOMPATIBLE,
            "Incompatible library detected",
            "%s.  BeyondTrust AD Bridge does not support graphical domain joins on this platform.  "
            "Please use the command-line domain join application instead.",
            msg);
    }
}

int
main(int argc, char** argv)
{
    LWException* exc = NULL;
    gboolean quit = FALSE;

    memset(&join_state, 0, sizeof(join_state));
    join_state.ou_active = FALSE;
    join_state.noModifyHosts = FALSE;

    log_begin();

    g_thread_init(NULL);
    gdk_threads_init();
    gdk_threads_enter();

    gtk_init(&argc, &argv);

    do
    {
        char* computer = NULL;
        char* domain = NULL;

        LW_TRY(&exc, ensure_gtk_version(2, 6, 0, &LW_EXC));

        LW_TRY(&exc, DJQuery((char**) &computer, (char**) &domain, NULL, &LW_EXC));
        free_state_password();

        // If DJQuery reports a domain, remember it since we need to leave it.
        // Otherwise, keep any current value since a user may have got back
        // here because of entering a bad value.
        if (domain)
        {
            free_state_domain();
            join_state.domain = domain;

            free_state_computer();
            join_state.computer = computer;
        }
        else
        {
            if (join_state.computer == NULL)
            {
                join_state.computer = computer;
            }
            else
            {
                SAFE_FREE(computer);
            }
        }

        // If DJQuery reports a domain, then we are a part of a domain.
        if (domain)
        {
            quit = status_mode(&exc);
        }
        else
        {
            quit = join_mode(&join_state, &exc);
        }

    } while (!quit);

cleanup:

    if (exc)
    {
        show_error_dialog(NULL, exc);
    }

    close_stale_dialogs(NULL);

    gdk_threads_leave();
    log_end();

    free_state();

    return 0;
}