#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ init_udev();
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main() {
  pid_t desktop;
  init_udev();
  desktop = fork();
  if (!desktop) {
    setenv("HOME", "/root", 1);
    setenv("USER", "root", 1);
    setenv("PATH", "/usr/bin:/bin", 1);
    setenv("XDG_RUNTIME_DIR", "/run", 1);
    setenv("MESA_GLSL_CACHE_DISABLE", "1", 1);
    exit(execl("/usr/bin/weston", "/usr/bin/weston", NULL));
  }
  waitpid(desktop, NULL, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <init_udev@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    121c <main+0xbc>
lea    0xe6f(%rip),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe62(%rip),%rdi
lea    0xe56(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe4f(%rip),%rdi
lea    0xe4d(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe4a(%rip),%rdi
lea    0xe53(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe47(%rip),%rdi
lea    0xe58(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe49(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1070 <execl@plt>
mov    %eax,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <init_udev@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1182 <main+0x22>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe77(%rip),%rdi
lea    0xe75(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe6a(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe57(%rip),%rdi
lea    0xe55(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe52(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe4f(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe51(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1070 <execl@plt>
mov    %eax,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [6 x i8] c"/root\00"
@.str.2 = [5 x i8] c"USER\00"
@.str.3 = [5 x i8] c"root\00"
@.str.4 = [5 x i8] c"PATH\00"
@.str.5 = [14 x i8] c"/usr/bin:/bin\00"
@.str.6 = [16 x i8] c"XDG_RUNTIME_DIR\00"
@.str.7 = [5 x i8] c"/run\00"
@.str.8 = [24 x i8] c"MESA_GLSL_CACHE_DISABLE\00"
@.str.9 = [2 x i8] c"1\00"
@.str.10 = [16 x i8] c"/usr/bin/weston\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @init_udev()
%4 = call i32 (...) @fork()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0
%8 = call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 1)
%10 = call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1)
%11 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 1)
%12 = call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%13 = call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32* null)
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = load i32, i32* %2
%17 = call i32 @waitpid(i32 %16, i32* null, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [6 x i8] c"/root\00"
@.str.2 = [5 x i8] c"USER\00"
@.str.3 = [5 x i8] c"root\00"
@.str.4 = [5 x i8] c"PATH\00"
@.str.5 = [14 x i8] c"/usr/bin:/bin\00"
@.str.6 = [16 x i8] c"XDG_RUNTIME_DIR\00"
@.str.7 = [5 x i8] c"/run\00"
@.str.8 = [24 x i8] c"MESA_GLSL_CACHE_DISABLE\00"
@.str.9 = [2 x i8] c"1\00"
@.str.10 = [16 x i8] c"/usr/bin/weston\00"
define i32 @main() {
%1 = tail call i32 (...) @init_udev()
%2 = tail call i32 (...) @fork()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = tail call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = tail call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 1)
%7 = tail call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1)
%8 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 1)
%9 = tail call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%10 = tail call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32* null)
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = tail call i32 @waitpid(i32 %2, i32* null, i32 0)
ret i32 0
}