#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*/ LINUX_REBOOT_CMD_RESTART2;
int /*<<< orphan*/ LINUX_REBOOT_MAGIC1;
int /*<<< orphan*/ LINUX_REBOOT_MAGIC2;
int /*<<< orphan*/ MS_MOVE;
int RB_AUTOBOOT;
int RB_HALT_SYSTEM;
int RB_POWER_OFF;
int /*<<< orphan*/ SYS_reboot;
int /*<<< orphan*/ die(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getpid();
int /*<<< orphan*/ kmsg(char *, ...);
scalar_t__ mkdir(char *, int);
scalar_t__ mount(char *, char *, int /*<<< orphan*/ *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
long reboot(int);
scalar_t__ sc_read_reboot_arg(char *, int);
scalar_t__ sc_streq(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int /*<<< orphan*/ sync();
long syscall(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/, char *);
scalar_t__ umount_all();
int main(int argc, char *argv[]) {
  char reboot_arg[256] = {0};
  errno = 0;
  if (getpid() != 1) {
    fprintf(stderr,
            "This is a shutdown helper program; don't call it directly.\n");
    exit(1);
  }
  kmsg("started.");
  if (mkdir("/writable", 0755) < 0) {
    die("cannot create directory /writable");
  }
  if (sc_read_reboot_arg(reboot_arg, sizeof reboot_arg) < 0) {
    kmsg("no reboot parameter");
  }
  if (umount_all()) {
    kmsg("- found no hard-to-unmount writable partition.");
  } else {
    if (mount("/oldroot/writable", "/writable", NULL, MS_MOVE, NULL) < 0) {
      die("cannot move writable out of the way");
    }
    if (umount_all()) {
      kmsg("- was able to unmount writable cleanly");
    } else {
      kmsg("* was *NOT* able to unmount writable cleanly");
      sync();
    }
  }
  int cmd = RB_HALT_SYSTEM;
  if (argc < 2) {
    kmsg("* called without verb; halting.");
  } else {
    if (sc_streq("reboot", argv[1])) {
      cmd = RB_AUTOBOOT;
      kmsg("- rebooting.");
    } else if (sc_streq("poweroff", argv[1])) {
      cmd = RB_POWER_OFF;
      kmsg("- powering off.");
    } else if (sc_streq("halt", argv[1])) {
      kmsg("- halting.");
    } else {
      kmsg("* called with unsupported verb %s; halting.", argv[1]);
    }
  }
  long ret;
  if (cmd == RB_AUTOBOOT && reboot_arg[0] != '\0') {
    ret = syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
                  LINUX_REBOOT_CMD_RESTART2, reboot_arg);
  } else {
    ret = reboot(cmd);
  }
  if (ret == -1) {
    kmsg("cannot reboot the system: %s", strerror(errno));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    0x2d95(%rip),%rax
movq   $0x0,(%rax)
mov    $0x0,%al
call   1050 <getpid@plt>
cmp    $0x1,%eax
je     1259 <main+0x69>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
lea    0xdef(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
jge    128e <main+0x9e>
lea    0xdbc(%rip),%rdi
call   10d0 <die@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <sc_read_reboot_arg@plt>
cmp    $0x0,%rax
jge    12b7 <main+0xc7>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
mov    $0x0,%al
call   1030 <umount_all@plt>
cmp    $0x0,%rax
je     12db <main+0xeb>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    1353 <main+0x163>
mov    0x2cde(%rip),%rax
mov    (%rax),%ecx
lea    0xdbf(%rip),%rdi
lea    0xd6b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
call   1060 <mount@plt>
cmp    $0x0,%rax
jge    1315 <main+0x125>
lea    0xdac(%rip),%rdi
call   10d0 <die@plt>
mov    $0x0,%al
call   1030 <umount_all@plt>
cmp    $0x0,%rax
je     1339 <main+0x149>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    134e <main+0x15e>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
mov    $0x0,%al
call   10b0 <sync@plt>
jmp    1353 <main+0x163>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    137f <main+0x18f>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    1455 <main+0x265>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdc6(%rip),%rdi
call   10c0 <sc_streq@plt>
cmp    $0x0,%rax
je     13bf <main+0x1cf>
mov    0x2bf4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    1450 <main+0x260>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd9a(%rip),%rdi
call   10c0 <sc_streq@plt>
cmp    $0x0,%rax
je     13ff <main+0x20f>
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    144b <main+0x25b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd73(%rip),%rdi
call   10c0 <sc_streq@plt>
cmp    $0x0,%rax
je     1430 <main+0x240>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    1446 <main+0x256>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
jmp    144b <main+0x25b>
jmp    1450 <main+0x260>
jmp    1455 <main+0x265>
mov    -0x114(%rbp),%eax
mov    0x2b36(%rip),%rcx
cmp    (%rcx),%eax
jne    14b6 <main+0x2c6>
movsbl -0x110(%rbp),%eax
cmp    $0x0,%eax
je     14b6 <main+0x2c6>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
mov    0x2b56(%rip),%rax
mov    (%rax),%esi
mov    0x2b1d(%rip),%rax
mov    (%rax),%edx
mov    0x2b2c(%rip),%rax
mov    (%rax),%ecx
lea    -0x110(%rbp),%r8
call   1090 <syscall@plt>
mov    %rax,-0x120(%rbp)
jmp    14c8 <main+0x2d8>
mov    -0x114(%rbp),%edi
call   1100 <reboot@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0xffffffffffffffff,-0x120(%rbp)
ff
jne    14f6 <main+0x306>
mov    0x2adb(%rip),%rax
mov    (%rax),%rdi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xcce(%rip),%rdi
mov    $0x0,%al
call   10f0 <kmsg@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2d55(%rip),%r15
movq   $0x0,(%r15)
xor    %eax,%eax
call   1050 <getpid@plt>
cmp    $0x1,%eax
jne    1463 <main+0x283>
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
lea    0xdce(%rip),%rdi
mov    $0x1ed,%esi
call   1040 <mkdir@plt>
test   %rax,%rax
jns    12aa <main+0xca>
lea    0xda0(%rip),%rdi
call   10c0 <die@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
call   1090 <sc_read_reboot_arg@plt>
test   %rax,%rax
jns    12ca <main+0xea>
lea    0xda4(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
xor    %eax,%eax
call   1030 <umount_all@plt>
test   %rax,%rax
je     12df <main+0xff>
lea    0xd9e(%rip),%rdi
jmp    1324 <main+0x144>
mov    0x2cda(%rip),%rax
mov    (%rax),%ecx
lea    0xdbb(%rip),%rdi
lea    0xd67(%rip),%rsi
xor    %edx,%edx
xor    %r8d,%r8d
call   1060 <mount@plt>
test   %rax,%rax
jns    1311 <main+0x131>
lea    0xdb0(%rip),%rdi
call   10c0 <die@plt>
xor    %eax,%eax
call   1030 <umount_all@plt>
test   %rax,%rax
je     1393 <main+0x1b3>
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%ebx
cmp    $0x1,%ebp
jg     1345 <main+0x165>
lea    0xdf4(%rip),%rdi
jmp    13ca <main+0x1ea>
mov    0x8(%r14),%rsi
lea    0xe04(%rip),%rdi
call   10b0 <sc_streq@plt>
test   %rax,%rax
je     136c <main+0x18c>
mov    0x2c37(%rip),%rax
mov    (%rax),%ebx
lea    0xdf1(%rip),%rdi
jmp    13ca <main+0x1ea>
mov    0x8(%r14),%rsi
lea    0xdf1(%rip),%rdi
call   10b0 <sc_streq@plt>
test   %rax,%rax
je     13aa <main+0x1ca>
mov    0x2c68(%rip),%rax
mov    (%rax),%ebx
lea    0xde0(%rip),%rdi
jmp    13ca <main+0x1ea>
lea    0xd6d(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
xor    %eax,%eax
call   10a0 <sync@plt>
jmp    132b <main+0x14b>
mov    0x8(%r14),%rsi
lea    0xdcc(%rip),%rdi
call   10b0 <sc_streq@plt>
test   %rax,%rax
je     144c <main+0x26c>
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
mov    0x2bc0(%rip),%rax
cmp    (%rax),%ebx
jne    1416 <main+0x236>
cmpb   $0x0,(%rsp)
je     1416 <main+0x236>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
mov    0x2bee(%rip),%rax
mov    (%rax),%esi
mov    0x2bb5(%rip),%rax
mov    (%rax),%edx
mov    0x2bc4(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r8
call   1080 <syscall@plt>
cmp    $0xffffffffffffffff,%rax
jne    143c <main+0x25c>
jmp    1423 <main+0x243>
mov    %ebx,%edi
call   10f0 <reboot@plt>
cmp    $0xffffffffffffffff,%rax
jne    143c <main+0x25c>
mov    (%r15),%rdi
call   1100 <strerror@plt>
lea    0xd8b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10e0 <kmsg@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r14),%rsi
lea    0xd3a(%rip),%rdi
xor    %eax,%eax
call   10e0 <kmsg@plt>
jmp    13d1 <main+0x1f1>
mov    0x2b66(%rip),%rax
mov    (%rax),%edi
lea    0xb8d(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@stderr = global i32 0
@.str = [60 x i8] c"This is a shutdown helper program; don't call it directly.\0A\00"
@.str.1 = [9 x i8] c"started.\00"
@.str.2 = [10 x i8] c"/writable\00"
@.str.3 = [34 x i8] c"cannot create directory /writable\00"
@.str.4 = [20 x i8] c"no reboot parameter\00"
@.str.5 = [47 x i8] c"- found no hard-to-unmount writable partition.\00"
@.str.6 = [18 x i8] c"/oldroot/writable\00"
@MS_MOVE = global i32 0
@.str.7 = [36 x i8] c"cannot move writable out of the way\00"
@.str.8 = [39 x i8] c"- was able to unmount writable cleanly\00"
@.str.9 = [45 x i8] c"* was *NOT* able to unmount writable cleanly\00"
@RB_HALT_SYSTEM = global i32 0
@.str.10 = [32 x i8] c"* called without verb; halting.\00"
@.str.11 = [7 x i8] c"reboot\00"
@RB_AUTOBOOT = global i32 0
@.str.12 = [13 x i8] c"- rebooting.\00"
@.str.13 = [9 x i8] c"poweroff\00"
@RB_POWER_OFF = global i32 0
@.str.14 = [16 x i8] c"- powering off.\00"
@.str.15 = [5 x i8] c"halt\00"
@.str.16 = [11 x i8] c"- halting.\00"
@.str.17 = [44 x i8] c"* called with unsupported verb %s; halting.\00"
@SYS_reboot = global i32 0
@LINUX_REBOOT_MAGIC1 = global i32 0
@LINUX_REBOOT_MAGIC2 = global i32 0
@LINUX_REBOOT_CMD_RESTART2 = global i32 0
@.str.18 = [29 x i8] c"cannot reboot the system: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [256 x i8]* %6 to i8*
store i64 0, i64* @errno
%10 = call i32 (...) @getpid()
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 493)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = call i64 @sc_read_reboot_arg(i8* %23, i32 256)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = call i64 (...) @umount_all()
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %48
33: ; preds = %28
%34 = load i32, i32* @MS_MOVE
%35 = call i64 @mount(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* null, i32 %34, i32* null)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
%40 = call i64 (...) @umount_all()
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %47
44: ; preds = %39
%45 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%46 = call i32 (...) @sync()
br label %47
47: ; preds = %44, %42
br label %48
48: ; preds = %47, %31
%49 = load i32, i32* @RB_HALT_SYSTEM
store i32 %49, i32* %7
%50 = load i32, i32* %4
%51 = icmp slt i32 %50, 2
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
br label %88
54: ; preds = %48
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @sc_streq(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i32, i32* @RB_AUTOBOOT
store i32 %61, i32* %7
%62 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %87
63: ; preds = %54
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i64 @sc_streq(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %63
%70 = load i32, i32* @RB_POWER_OFF
store i32 %70, i32* %7
%71 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %86
72: ; preds = %63
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 1
%75 = load i8*, i8** %74
%76 = call i64 @sc_streq(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i8* %75)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0))
br label %85
80: ; preds = %72
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0), i8* %83)
br label %85
85: ; preds = %80, %78
br label %86
86: ; preds = %85, %69
br label %87
87: ; preds = %86, %60
br label %88
88: ; preds = %87, %52
%89 = load i32, i32* %7
%90 = load i32, i32* @RB_AUTOBOOT
%91 = icmp eq i32 %89, %90
br i1 %91, label %92, label %104
92: ; preds = %88
%93 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %104
97: ; preds = %92
%98 = load i32, i32* @SYS_reboot
%99 = load i32, i32* @LINUX_REBOOT_MAGIC1
%100 = load i32, i32* @LINUX_REBOOT_MAGIC2
%101 = load i32, i32* @LINUX_REBOOT_CMD_RESTART2
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%103 = call i64 @syscall(i32 %98, i32 %99, i32 %100, i32 %101, i8* %102)
store i64 %103, i64* %8
br label %107
104: ; preds = %92, %88
%105 = load i32, i32* %7
%106 = call i64 @reboot(i32 %105)
store i64 %106, i64* %8
br label %107
107: ; preds = %104, %97
%108 = load i64, i64* %8
%109 = icmp eq i64 %108, -1
br i1 %109, label %110, label %114
110: ; preds = %107
%111 = load i64, i64* @errno
%112 = call i8* @strerror(i64 %111)
%113 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %110, %107
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@stderr = global i32 0
@.str = [60 x i8] c"This is a shutdown helper program; don't call it directly.\0A\00"
@.str.1 = [9 x i8] c"started.\00"
@.str.2 = [10 x i8] c"/writable\00"
@.str.3 = [34 x i8] c"cannot create directory /writable\00"
@.str.4 = [20 x i8] c"no reboot parameter\00"
@.str.5 = [47 x i8] c"- found no hard-to-unmount writable partition.\00"
@.str.6 = [18 x i8] c"/oldroot/writable\00"
@MS_MOVE = global i32 0
@.str.7 = [36 x i8] c"cannot move writable out of the way\00"
@.str.8 = [39 x i8] c"- was able to unmount writable cleanly\00"
@.str.9 = [45 x i8] c"* was *NOT* able to unmount writable cleanly\00"
@RB_HALT_SYSTEM = global i32 0
@.str.10 = [32 x i8] c"* called without verb; halting.\00"
@.str.11 = [7 x i8] c"reboot\00"
@RB_AUTOBOOT = global i32 0
@.str.12 = [13 x i8] c"- rebooting.\00"
@.str.13 = [9 x i8] c"poweroff\00"
@RB_POWER_OFF = global i32 0
@.str.14 = [16 x i8] c"- powering off.\00"
@.str.15 = [5 x i8] c"halt\00"
@.str.16 = [11 x i8] c"- halting.\00"
@.str.17 = [44 x i8] c"* called with unsupported verb %s; halting.\00"
@SYS_reboot = global i32 0
@LINUX_REBOOT_MAGIC1 = global i32 0
@LINUX_REBOOT_MAGIC2 = global i32 0
@LINUX_REBOOT_CMD_RESTART2 = global i32 0
@.str.18 = [29 x i8] c"cannot reboot the system: %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i64 0, i64* @errno
%5 = tail call i32 (...) @getpid()
%6 = icmp eq i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = tail call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i64 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 493)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @die(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = call i64 @sc_read_reboot_arg(i8* %4, i32 256)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i64 (...) @umount_all()
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %41
27: ; preds = %22
%28 = load i32, i32* @MS_MOVE
%29 = call i64 @mount(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* null, i32 %28, i32* null)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @die(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = call i64 (...) @umount_all()
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %41
38: ; preds = %33
%39 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%40 = call i32 (...) @sync()
br label %41
41: ; preds = %36, %38, %25
%42 = load i32, i32* @RB_HALT_SYSTEM
%43 = icmp slt i32 %0, 2
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
br label %70
46: ; preds = %41
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = call i64 @sc_streq(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %46
%52 = load i32, i32* @RB_AUTOBOOT
%53 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %70
54: ; preds = %46
%55 = load i8*, i8** %47
%56 = call i64 @sc_streq(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = load i32, i32* @RB_POWER_OFF
%60 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %70
61: ; preds = %54
%62 = load i8*, i8** %47
%63 = call i64 @sc_streq(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i8* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0))
br label %70
67: ; preds = %61
%68 = load i8*, i8** %47
%69 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.17, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %51, %65, %67, %58, %44
%71 = phi i32 [ %42, %44 ], [ %52, %51 ], [ %59, %58 ], [ %42, %65 ], [ %42, %67 ]
%72 = load i32, i32* @RB_AUTOBOOT
%73 = icmp eq i32 %71, %72
%74 = load i8, i8* %4
%75 = icmp ne i8 %74, 0
%76 = select i1 %73, i1 %75, i1 false
br i1 %76, label %77, label %83
77: ; preds = %70
%78 = load i32, i32* @SYS_reboot
%79 = load i32, i32* @LINUX_REBOOT_MAGIC1
%80 = load i32, i32* @LINUX_REBOOT_MAGIC2
%81 = load i32, i32* @LINUX_REBOOT_CMD_RESTART2
%82 = call i64 @syscall(i32 %78, i32 %79, i32 %80, i32 %81, i8* %4)
br label %85
83: ; preds = %70
%84 = call i64 @reboot(i32 %71)
br label %85
85: ; preds = %83, %77
%86 = phi i64 [ %82, %77 ], [ %84, %83 ]
%87 = icmp eq i64 %86, -1
br i1 %87, label %88, label %92
88: ; preds = %85
%89 = load i64, i64* @errno
%90 = call i8* @strerror(i64 %89)
%91 = call i32 (i8*, ...) @kmsg(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %88, %85
ret i32 0
}