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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void *fork();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ sethostname(char *, int);
int /*<<< orphan*/ wait(int *);
int /*<<< orphan*/ waitpid(void *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int fd_stdin, fd_stdout, fd_stderr;
  pid_t pid;
  pid = fork();
  if (pid) {
    waitpid(pid, NULL, 0);
  } else {
    char *rc_args[] = {"/bin/sh", "/etc/rc", NULL};
    char *rc_env[] = {NULL};
    execve("/bin/sh", rc_args, rc_env);
  }
  fd_stdin = open("/dev/console", O_RDWR);
  fd_stdout = dup(fd_stdin);
  fd_stderr = dup(fd_stdin);
  pid = fork();
  if (!pid) {
    int fd;
    fd = open("/dev/tty6", O_RDWR);
    dup2(fd, STDIN_FILENO);
    dup2(fd, STDOUT_FILENO);
    dup2(fd, STDERR_FILENO);
    close(fd);
    char *rc_args[] = {"/usr/bin/lydm", NULL};
    char *rc_env[] = {NULL};
    execve("/usr/bin/lydm", rc_args, rc_env);
    exit(EXIT_FAILURE);
  }
  int fd_hostname = open("/etc/hostname", O_RDONLY);
  if (fd_hostname != -1) {
    char hostname[256];
    memset(hostname, 0, sizeof(hostname));
    int len = read(fd_hostname, hostname, sizeof(hostname));
    printf("Setting hostname to %s\n", hostname);
    sethostname(hostname, len);
    close(fd_hostname);
  }
  char *ttylist[4] = {"/dev/tty1", "/dev/tty2", "/dev/tty3", "/dev/ttyS0"};
  int i;
  for (i = 0; i < 4; i++) {
    int pid = fork();
    if (pid) {
    } else {
      close(0);
      close(1);
      close(2);
      assert(open(ttylist[i], O_RDWR) == 0);
      assert(open(ttylist[i], O_RDWR) == 1);
      assert(open(ttylist[i], O_RDWR) == 2);
      char *argv[] = {"/usr/bin/getty", NULL};
      _exit(execv("/usr/bin/getty", argv));
    }
  }
  while (1) {
    int s;
    wait(&s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1120 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1243 <main+0x43>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
jmp    1288 <main+0x88>
mov    0x2b46(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2b43(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2b40(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    0xd7d(%rip),%rdi
call   10a0 <execve@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <dup@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <dup@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1120 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1367 <main+0x167>
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
lea    0xd41(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
mov    -0x4c(%rbp),%edi
mov    0x2cf1(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
mov    -0x4c(%rbp),%edi
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
mov    -0x4c(%rbp),%edi
call   1080 <close@plt>
mov    0x2a8a(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2a87(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
lea    -0x60(%rbp),%rsi
lea    -0x68(%rbp),%rdx
lea    0xcd3(%rip),%rdi
call   10a0 <execve@plt>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    0x2c6a(%rip),%rax
mov    (%rax),%esi
lea    0xcbe(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
je     13e3 <main+0x1e3>
lea    -0x170(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    -0x6c(%rbp),%edi
lea    -0x170(%rbp),%rsi
mov    $0x100,%edx
call   1090 <read@plt>
mov    %eax,-0x174(%rbp)
lea    -0x170(%rbp),%rsi
lea    0xc7f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x170(%rbp),%rdi
mov    -0x174(%rbp),%esi
call   10c0 <sethostname@plt>
mov    -0x6c(%rbp),%edi
call   1080 <close@plt>
mov    0x29d6(%rip),%rax
mov    %rax,-0x1a0(%rbp)
mov    0x29d0(%rip),%rax
mov    %rax,-0x198(%rbp)
mov    0x29ca(%rip),%rax
mov    %rax,-0x190(%rbp)
mov    0x29c4(%rip),%rax
mov    %rax,-0x188(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x4,-0x1a4(%rbp)
jge    1542 <main+0x342>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x1a8(%rbp)
cmpl   $0x0,-0x1a8(%rbp)
je     1451 <main+0x251>
jmp    1529 <main+0x329>
xor    %edi,%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   1080 <close@plt>
mov    $0x2,%edi
call   1080 <close@plt>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
mov    0x2b5e(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
mov    0x2b31(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,8),%rdi
ff
mov    0x2b04(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
mov    0x28e6(%rip),%rax
mov    %rax,-0x1c0(%rbp)
mov    0x28e0(%rip),%rax
mov    %rax,-0x1b8(%rbp)
lea    -0x1c0(%rbp),%rsi
lea    0xb67(%rip),%rdi
call   1110 <execv@plt>
mov    %eax,%edi
call   1030 <_exit@plt>
jmp    152e <main+0x32e>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1425 <main+0x225>
jmp    1547 <main+0x347>
lea    -0x1c4(%rbp),%rdi
call   1100 <wait@plt>
jmp    1547 <main+0x347>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x118,%rsp
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
je     1227 <main+0x27>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
jmp    125e <main+0x5e>
mov    0x2b72(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0x2b56(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xdb1(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   10a0 <execve@plt>
mov    0x2d7b(%rip),%r15
mov    (%r15),%esi
lea    0xda1(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <dup@plt>
mov    %ebx,%edi
call   1060 <dup@plt>
xor    %eax,%eax
call   1120 <fork@plt>
test   %rax,%rax
je     134a <main+0x14a>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
lea    0xd91(%rip),%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     12f5 <main+0xf5>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x100,%edx
call   1090 <read@plt>
mov    %eax,%ebp
lea    0xd67(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   10c0 <sethostname@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     13de <main+0x1de>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     13cb <main+0x1cb>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     13d2 <main+0x1d2>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     13d9 <main+0x1d9>
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1100 <wait@plt>
jmp    1340 <main+0x140>
mov    (%r15),%esi
lea    0xcc9(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,%ebx
mov    0x2c56(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <dup2@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <dup2@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <dup2@plt>
mov    %ebx,%edi
call   1080 <close@plt>
movaps 0x2a17(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xc79(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   10a0 <execve@plt>
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    $0x1,%ebx
jmp    13de <main+0x1de>
mov    $0x2,%ebx
jmp    13de <main+0x1de>
mov    $0x3,%ebx
xor    %edi,%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   1080 <close@plt>
mov    $0x2,%edi
call   1080 <close@plt>
lea    0x29c0(%rip),%rax
mov    (%rax,%rbx,8),%rbx
mov    (%r15),%esi
mov    %rbx,%rdi
call   10e0 <open@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   10b0 <assert@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   10e0 <open@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   10b0 <assert@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   10e0 <open@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   10b0 <assert@plt>
movaps 0x298b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xc23(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1110 <execv@plt>
mov    %eax,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [8 x i8] c"/etc/rc\00"
@__const.main.rc_args = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@.str.3 = [10 x i8] c"/dev/tty6\00"
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.4 = [14 x i8] c"/usr/bin/lydm\00"
@__const.main.rc_args.5 = [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i8* null]
@EXIT_FAILURE = global i32 0
@.str.6 = [14 x i8] c"/etc/hostname\00"
@O_RDONLY = global i32 0
@.str.7 = [24 x i8] c"Setting hostname to %s\0A\00"
@.str.8 = [10 x i8] c"/dev/tty1\00"
@.str.9 = [10 x i8] c"/dev/tty2\00"
@.str.10 = [10 x i8] c"/dev/tty3\00"
@.str.11 = [11 x i8] c"/dev/ttyS0\00"
@__const.main.ttylist = [4 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [15 x i8] c"/usr/bin/getty\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [3 x i8*]
%11 = alloca [1 x i8*]
%12 = alloca i32
%13 = alloca [2 x i8*]
%14 = alloca [1 x i8*]
%15 = alloca i32
%16 = alloca [256 x i8]
%17 = alloca i32
%18 = alloca [4 x i8*]
%19 = alloca i32
%20 = alloca i32
%21 = alloca [2 x i8*]
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = call i8* (...) @fork()
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i8*, i8** %9
%28 = call i32 @waitpid(i8* %27, i32* null, i32 0)
br label %35
29: ; preds = %2
%30 = bitcast [3 x i8*]* %10 to i8*
%31 = bitcast [1 x i8*]* %11 to i8*
%32 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
%33 = getelementptr inbounds [1 x i8*], [1 x i8*]* %11, i64 0, i64 0
%34 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %32, i8** %33)
br label %35
35: ; preds = %29, %26
%36 = load i32, i32* @O_RDWR
%37 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %36)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = call i32 @dup(i32 %38)
store i32 %39, i32* %7
%40 = load i32, i32* %6
%41 = call i32 @dup(i32 %40)
store i32 %41, i32* %8
%42 = call i8* (...) @fork()
store i8* %42, i8** %9
%43 = load i8*, i8** %9
%44 = icmp ne i8* %43, null
br i1 %44, label %66, label %45
45: ; preds = %35
%46 = load i32, i32* @O_RDWR
%47 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %46)
store i32 %47, i32* %12
%48 = load i32, i32* %12
%49 = load i32, i32* @STDIN_FILENO
%50 = call i32 @dup2(i32 %48, i32 %49)
%51 = load i32, i32* %12
%52 = load i32, i32* @STDOUT_FILENO
%53 = call i32 @dup2(i32 %51, i32 %52)
%54 = load i32, i32* %12
%55 = load i32, i32* @STDERR_FILENO
%56 = call i32 @dup2(i32 %54, i32 %55)
%57 = load i32, i32* %12
%58 = call i32 @close(i32 %57)
%59 = bitcast [2 x i8*]* %13 to i8*
%60 = bitcast [1 x i8*]* %14 to i8*
%61 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 0
%62 = getelementptr inbounds [1 x i8*], [1 x i8*]* %14, i64 0, i64 0
%63 = call i32 @execve(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %61, i8** %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %35
%67 = load i32, i32* @O_RDONLY
%68 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %67)
store i32 %68, i32* %15
%69 = load i32, i32* %15
%70 = icmp ne i32 %69, -1
br i1 %70, label %71, label %84
71: ; preds = %66
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%73 = call i32 @memset(i8* %72, i32 0, i32 256)
%74 = load i32, i32* %15
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%76 = call i32 @read(i32 %74, i8* %75, i32 256)
store i32 %76, i32* %17
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%78 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %77)
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%80 = load i32, i32* %17
%81 = call i32 @sethostname(i8* %79, i32 %80)
%82 = load i32, i32* %15
%83 = call i32 @close(i32 %82)
br label %84
84: ; preds = %71, %66
%85 = bitcast [4 x i8*]* %18 to i8*
store i32 0, i32* %19
br label %86
86: ; preds = %131, %84
%87 = load i32, i32* %19
%88 = icmp slt i32 %87, 4
br i1 %88, label %89, label %134
89: ; preds = %86
%90 = call i8* (...) @fork()
%91 = ptrtoint i8* %90 to i32
store i32 %91, i32* %20
%92 = load i32, i32* %20
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %89
br label %130
95: ; preds = %89
%96 = call i32 @close(i32 0)
%97 = call i32 @close(i32 1)
%98 = call i32 @close(i32 2)
%99 = load i32, i32* %19
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [4 x i8*], [4 x i8*]* %18, i64 0, i64 %100
%102 = load i8*, i8** %101
%103 = load i32, i32* @O_RDWR
%104 = call i32 @open(i8* %102, i32 %103)
%105 = icmp eq i32 %104, 0
%106 = zext i1 %105 to i32
%107 = call i32 @assert(i32 %106)
%108 = load i32, i32* %19
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [4 x i8*], [4 x i8*]* %18, i64 0, i64 %109
%111 = load i8*, i8** %110
%112 = load i32, i32* @O_RDWR
%113 = call i32 @open(i8* %111, i32 %112)
%114 = icmp eq i32 %113, 1
%115 = zext i1 %114 to i32
%116 = call i32 @assert(i32 %115)
%117 = load i32, i32* %19
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [4 x i8*], [4 x i8*]* %18, i64 0, i64 %118
%120 = load i8*, i8** %119
%121 = load i32, i32* @O_RDWR
%122 = call i32 @open(i8* %120, i32 %121)
%123 = icmp eq i32 %122, 2
%124 = zext i1 %123 to i32
%125 = call i32 @assert(i32 %124)
%126 = bitcast [2 x i8*]* %21 to i8*
%127 = getelementptr inbounds [2 x i8*], [2 x i8*]* %21, i64 0, i64 0
%128 = call i32 @execv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8** %127)
%129 = call i32 @_exit(i32 %128)
unreachable
130: ; preds = %94
br label %131
131: ; preds = %130
%132 = load i32, i32* %19
%133 = add nsw i32 %132, 1
store i32 %133, i32* %19
br label %86
134: ; preds = %86
br label %135
135: ; preds = %134, %135
%136 = call i32 @wait(i32* %22)
br label %135
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [8 x i8] c"/etc/rc\00"
@__const.main.rc_args = [3 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [13 x i8] c"/dev/console\00"
@O_RDWR = global i32 0
@.str.3 = [10 x i8] c"/dev/tty6\00"
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.4 = [14 x i8] c"/usr/bin/lydm\00"
@__const.main.rc_args.5 = [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i8* null]
@EXIT_FAILURE = global i32 0
@.str.6 = [14 x i8] c"/etc/hostname\00"
@O_RDONLY = global i32 0
@.str.7 = [24 x i8] c"Setting hostname to %s\0A\00"
@.str.8 = [10 x i8] c"/dev/tty1\00"
@.str.9 = [10 x i8] c"/dev/tty2\00"
@.str.10 = [10 x i8] c"/dev/tty3\00"
@.str.11 = [11 x i8] c"/dev/ttyS0\00"
@__const.main.ttylist = [4 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [15 x i8] c"/usr/bin/getty\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i8*]
%4 = alloca [1 x i8*]
%5 = alloca [2 x i8*]
%6 = alloca [1 x i8*]
%7 = alloca [256 x i8]
%8 = alloca [2 x i8*]
%9 = alloca i32
%10 = tail call i8* (...) @fork()
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @waitpid(i8* %10, i32* null, i32 0)
br label %21
14: ; preds = %2
%15 = bitcast [3 x i8*]* %3 to i8*
%16 = bitcast [1 x i8*]* %4 to i8*
%17 = bitcast [1 x i8*]* %4 to i64*
store i64 0, i64* %17
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%19 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%20 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %18, i8** %19)
br label %21
21: ; preds = %14, %12
%22 = load i32, i32* @O_RDWR
%23 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @dup(i32 %23)
%25 = call i32 @dup(i32 %23)
%26 = call i8* (...) @fork()
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %46
28: ; preds = %21
%29 = load i32, i32* @O_RDWR
%30 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @STDIN_FILENO
%32 = call i32 @dup2(i32 %30, i32 %31)
%33 = load i32, i32* @STDOUT_FILENO
%34 = call i32 @dup2(i32 %30, i32 %33)
%35 = load i32, i32* @STDERR_FILENO
%36 = call i32 @dup2(i32 %30, i32 %35)
%37 = call i32 @close(i32 %30)
%38 = bitcast [2 x i8*]* %5 to i8*
%39 = bitcast [1 x i8*]* %6 to i8*
%40 = bitcast [1 x i8*]* %6 to i64*
store i64 0, i64* %40
%41 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%42 = getelementptr inbounds [1 x i8*], [1 x i8*]* %6, i64 0, i64 0
%43 = call i32 @execve(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %41, i8** %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %21
%47 = load i32, i32* @O_RDONLY
%48 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %57, label %50
50: ; preds = %46
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%52 = call i32 @memset(i8* %51, i32 0, i32 256)
%53 = call i32 @read(i32 %48, i8* %51, i32 256)
%54 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %51)
%55 = call i32 @sethostname(i8* %51, i32 %53)
%56 = call i32 @close(i32 %48)
br label %57
57: ; preds = %50, %46
%58 = call i8* (...) @fork()
%59 = ptrtoint i8* %58 to i64
%60 = trunc i64 %59 to i32
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %88
62: ; preds = %98, %93, %88, %57
%63 = phi i64 [ 0, %57 ], [ 1, %88 ], [ 2, %93 ], [ 3, %98 ]
%64 = call i32 @close(i32 0)
%65 = call i32 @close(i32 1)
%66 = call i32 @close(i32 2)
%67 = getelementptr inbounds [4 x i8*], [4 x i8*]* @__const.main.ttylist, i64 0, i64 %63
%68 = load i8*, i8** %67
%69 = load i32, i32* @O_RDWR
%70 = call i32 @open(i8* %68, i32 %69)
%71 = icmp eq i32 %70, 0
%72 = zext i1 %71 to i32
%73 = call i32 @assert(i32 %72)
%74 = load i32, i32* @O_RDWR
%75 = call i32 @open(i8* %68, i32 %74)
%76 = icmp eq i32 %75, 1
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = load i32, i32* @O_RDWR
%80 = call i32 @open(i8* %68, i32 %79)
%81 = icmp eq i32 %80, 2
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = bitcast [2 x i8*]* %8 to i8*
%85 = getelementptr inbounds [2 x i8*], [2 x i8*]* %8, i64 0, i64 0
%86 = call i32 @execv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8** %85)
%87 = call i32 @_exit(i32 %86)
unreachable
88: ; preds = %57
%89 = call i8* (...) @fork()
%90 = ptrtoint i8* %89 to i64
%91 = trunc i64 %90 to i32
%92 = icmp eq i32 %91, 0
br i1 %92, label %62, label %93
93: ; preds = %88
%94 = call i8* (...) @fork()
%95 = ptrtoint i8* %94 to i64
%96 = trunc i64 %95 to i32
%97 = icmp eq i32 %96, 0
br i1 %97, label %62, label %98
98: ; preds = %93
%99 = call i8* (...) @fork()
%100 = ptrtoint i8* %99 to i64
%101 = trunc i64 %100 to i32
%102 = icmp eq i32 %101, 0
br i1 %102, label %62, label %103
103: ; preds = %98
%104 = bitcast i32* %9 to i8*
br label %105
105: ; preds = %103, %105
%106 = call i32 @wait(i32* %9)
br label %105
}