#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 /*<<< orphan*/ create_auto_login(int, int, char *);
int /*<<< orphan*/ create_login(int);
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ idle();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setpsname(char *);
void main() {
  int pid = fork();
  if (pid == 0) {
    char *args[] = {"/bin/swapper", 0};
    execv(args[0], args);
    printf("init: Error while trying to launch /bin/swapper\n");
    exit(1);
  }
  printf("swapper launched in background. output at console 10\n\n");
  int i;
  create_auto_login(0, 1000, "xyz");
  create_auto_login(1, 0, "xyz");
  for (i = 2; i < 5; i++)
    create_login(i);
  setpsname("[idle]");
  for (;;) {
    idle();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11d5 <main+0x55>
mov    0x2c6d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c6a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <execv@plt>
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x3e8,%esi
lea    0xe86(%rip),%rdx
call   1070 <create_auto_login@plt>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe73(%rip),%rdx
call   1070 <create_auto_login@plt>
movl   $0x2,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    122e <main+0xae>
mov    -0x24(%rbp),%edi
call   1030 <create_login@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <main+0x8e>
lea    0xe44(%rip),%rdi
call   1040 <setpsname@plt>
mov    $0x0,%al
call   1060 <idle@plt>
jmp    123a <main+0xba>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   10a0 <fork@plt>
test   %eax,%eax
je     11f9 <main+0x79>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5d(%rip),%rbx
xor    %edi,%edi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1070 <create_auto_login@plt>
mov    $0x1,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <create_auto_login@plt>
mov    $0x2,%edi
call   1030 <create_login@plt>
mov    $0x3,%edi
call   1030 <create_login@plt>
mov    $0x4,%edi
call   1030 <create_login@plt>
lea    0xe1e(%rip),%rdi
call   1050 <setpsname@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <idle@plt>
jmp    11f0 <main+0x70>
movaps 0x2c10(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe59(%rip),%rdi
mov    %rsp,%rsi
call   1090 <execv@plt>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/bin/swapper\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [49 x i8] c"init: Error while trying to launch /bin/swapper\0A\00"
@.str.2 = [55 x i8] c"swapper launched in background. output at console 10\0A\0A\00"
@.str.3 = [4 x i8] c"xyz\00"
@.str.4 = [7 x i8] c"[idle]\00"
define void @main() {
%1 = alloca i32
%2 = alloca [2 x i8*]
%3 = alloca i32
%4 = call i32 (...) @fork()
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = bitcast [2 x i8*]* %2 to i8*
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%10 = load i8*, i8** %9
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%12 = call i32 @execv(i8* %10, i8** %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @create_auto_login(i32 0, i32 1000, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @create_auto_login(i32 1, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %19
19: ; preds = %25, %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %3
%24 = call i32 @create_login(i32 %23)
br label %25
25: ; preds = %22
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %19
28: ; preds = %19
%29 = call i32 @setpsname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %30, %28
%31 = call i32 (...) @idle()
br label %30
}

LLVM IR (-O2):
@.str = [13 x i8] c"/bin/swapper\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.3 = [4 x i8] c"xyz\00"
@.str.4 = [7 x i8] c"[idle]\00"
@str = [54 x i8] c"swapper launched in background. output at console 10\0A\00"
@str.5 = [48 x i8] c"init: Error while trying to launch /bin/swapper\00"
define void @main() {
%1 = alloca [2 x i8*]
%2 = tail call i32 (...) @fork()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = bitcast [2 x i8*]* %1 to i8*
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%7 = call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %6)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.5, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @create_auto_login(i32 0, i32 1000, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @create_auto_login(i32 1, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @create_login(i32 2)
%15 = tail call i32 @create_login(i32 3)
%16 = tail call i32 @create_login(i32 4)
%17 = tail call i32 @setpsname(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %18, %10
%19 = tail call i32 (...) @idle()
br label %18
}