#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ get_options(int, char **);
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ lprintf(char *);
int /*<<< orphan*/ open_log();
int /*<<< orphan*/ set_text_mode();
int /*<<< orphan*/ set_tty();
int /*<<< orphan*/ setup_xauth();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ start_X_server();
int /*<<< orphan*/ start_dbus_session_bus();
int /*<<< orphan*/ start_desktop_session();
int /*<<< orphan*/ start_gconf();
int /*<<< orphan*/ stop_dbus_session_bus();
int /*<<< orphan*/ switch_to_user();
int /*<<< orphan*/ wait_for_X_exit();
int /*<<< orphan*/ wait_for_X_signal();
int main(int argc, char **argv) {
  open_log();
  get_options(argc, argv);
  setup_xauth();
  set_tty();
  switch_to_user();
  start_X_server();
  start_dbus_session_bus();
  start_gconf();
  wait_for_X_signal();
  start_desktop_session();
  wait_for_X_exit();
  set_text_mode();
  stop_dbus_session_bus();
  sleep(2);
  lprintf("Terminating uxlaunch and all children");
  kill(0, SIGKILL);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <open_log@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10e0 <get_options@plt>
mov    $0x0,%al
call   1070 <setup_xauth@plt>
mov    $0x0,%al
call   1080 <set_tty@plt>
mov    $0x0,%al
call   10b0 <switch_to_user@plt>
mov    $0x0,%al
call   1100 <start_X_server@plt>
mov    $0x0,%al
call   1050 <start_dbus_session_bus@plt>
mov    $0x0,%al
call   10d0 <start_gconf@plt>
mov    $0x0,%al
call   1040 <wait_for_X_signal@plt>
mov    $0x0,%al
call   1120 <start_desktop_session@plt>
mov    $0x0,%al
call   10c0 <wait_for_X_exit@plt>
mov    $0x0,%al
call   1030 <set_text_mode@plt>
mov    $0x0,%al
call   10a0 <stop_dbus_session_bus@plt>
mov    $0x2,%edi
call   1110 <sleep@plt>
lea    0xd79(%rip),%rdi
call   10f0 <lprintf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1090 <kill@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <open_log@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   10e0 <get_options@plt>
xor    %eax,%eax
call   1070 <setup_xauth@plt>
xor    %eax,%eax
call   1080 <set_tty@plt>
xor    %eax,%eax
call   10b0 <switch_to_user@plt>
xor    %eax,%eax
call   1100 <start_X_server@plt>
xor    %eax,%eax
call   1050 <start_dbus_session_bus@plt>
xor    %eax,%eax
call   10d0 <start_gconf@plt>
xor    %eax,%eax
call   1040 <wait_for_X_signal@plt>
xor    %eax,%eax
call   1120 <start_desktop_session@plt>
xor    %eax,%eax
call   10c0 <wait_for_X_exit@plt>
xor    %eax,%eax
call   1030 <set_text_mode@plt>
xor    %eax,%eax
call   10a0 <stop_dbus_session_bus@plt>
mov    $0x2,%edi
call   1110 <sleep@plt>
lea    0xd89(%rip),%rdi
call   10f0 <lprintf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1090 <kill@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Terminating uxlaunch and all children\00"
@SIGKILL = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @open_log()
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @get_options(i32 %7, i8** %8)
%10 = call i32 (...) @setup_xauth()
%11 = call i32 (...) @set_tty()
%12 = call i32 (...) @switch_to_user()
%13 = call i32 (...) @start_X_server()
%14 = call i32 (...) @start_dbus_session_bus()
%15 = call i32 (...) @start_gconf()
%16 = call i32 (...) @wait_for_X_signal()
%17 = call i32 (...) @start_desktop_session()
%18 = call i32 (...) @wait_for_X_exit()
%19 = call i32 (...) @set_text_mode()
%20 = call i32 (...) @stop_dbus_session_bus()
%21 = call i32 @sleep(i32 2)
%22 = call i32 @lprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @SIGKILL
%24 = call i32 @kill(i32 0, i32 %23)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}

LLVM IR (-O2):
@.str = [38 x i8] c"Terminating uxlaunch and all children\00"
@SIGKILL = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (...) @open_log()
%4 = tail call i32 @get_options(i32 %0, i8** %1)
%5 = tail call i32 (...) @setup_xauth()
%6 = tail call i32 (...) @set_tty()
%7 = tail call i32 (...) @switch_to_user()
%8 = tail call i32 (...) @start_X_server()
%9 = tail call i32 (...) @start_dbus_session_bus()
%10 = tail call i32 (...) @start_gconf()
%11 = tail call i32 (...) @wait_for_X_signal()
%12 = tail call i32 (...) @start_desktop_session()
%13 = tail call i32 (...) @wait_for_X_exit()
%14 = tail call i32 (...) @set_text_mode()
%15 = tail call i32 (...) @stop_dbus_session_bus()
%16 = tail call i32 @sleep(i32 2)
%17 = tail call i32 @lprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @SIGKILL
%19 = tail call i32 @kill(i32 0, i32 %18)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}