#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*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int get_sa(char *, char *);
int /*<<< orphan*/ parse_lsshut_options(int, char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int strrd(char *, char *);
int lsshut(int argc, char *argv[]) {
  int rc;
  char tmp[1024];
  char cmd[1024];
  parse_lsshut_options(argc, argv);
  printf("Trigger          Action\n");
  printf("========================\n");
  if (access("/sys/firmware/shutdown_actions/on_halt", R_OK) == 0) {
    rc = get_sa(tmp, "on_halt");
    if (rc != -1) {
      if (strncmp(tmp, "vmcmd", strlen("vmcmd")) == 0) {
        rc = strrd(cmd, "/sys/firmware/vmcmd/on_halt");
        if (rc != 0)
          exit(1);
        printf("Halt             %s (\"%s\")\n", tmp, cmd);
      } else
        printf("Halt             %s\n", tmp);
    }
  }
  if (access("/sys/firmware/shutdown_actions/on_panic", R_OK) == 0) {
    rc = get_sa(tmp, "on_panic");
    if (rc != -1) {
      if (strncmp(tmp, "vmcmd", strlen("vmcmd")) == 0) {
        rc = strrd(cmd, "/sys/firmware/vmcmd/on_panic");
        if (rc != 0)
          exit(1);
        printf("Panic            %s (\"%s\")\n", tmp, cmd);
      } else
        printf("Panic            %s\n", tmp);
    }
  }
  if (access("/sys/firmware/shutdown_actions/on_poff", R_OK) == 0) {
    rc = get_sa(tmp, "on_poff");
    if (rc != -1) {
      if (strncmp(tmp, "vmcmd", strlen("vmcmd")) == 0) {
        rc = strrd(cmd, "/sys/firmware/vmcmd/on_poff");
        if (rc != 0)
          exit(1);
        printf("Power off        %s (\"%s\")\n", tmp, cmd);
      } else
        printf("Power off        %s\n", tmp);
    }
  }
  if (access("/sys/firmware/shutdown_actions/on_reboot", R_OK) == 0) {
    rc = get_sa(tmp, "on_reboot");
    if (rc != -1) {
      if (strncmp(tmp, "vmcmd", strlen("vmcmd")) == 0) {
        rc = strrd(cmd, "/sys/firmware/vmcmd/"
                        "on_reboot");
        if (rc != 0)
          exit(1);
        printf("Reboot           %s (\"%s\")\n", tmp, cmd);
      } else
        printf("Reboot           %s\n", tmp);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<lsshut>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <parse_lsshut_options@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdi
call   1070 <access@plt>
cmp    $0x0,%rax
jne    129c <lsshut+0x11c>
lea    -0x420(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <get_sa@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1297 <lsshut+0x117>
lea    -0x420(%rbp),%rax
mov    %rax,-0x828(%rbp)
lea    0xe4c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x828(%rbp),%rdi
mov    %eax,%edx
lea    0xe37(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    127d <lsshut+0xfd>
lea    -0x820(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   10a0 <strrd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     125c <lsshut+0xdc>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x420(%rbp),%rsi
lea    -0x820(%rbp),%rdx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1292 <lsshut+0x112>
lea    -0x420(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1297 <lsshut+0x117>
jmp    129c <lsshut+0x11c>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
lea    0xe01(%rip),%rdi
call   1070 <access@plt>
cmp    $0x0,%rax
jne    137e <lsshut+0x1fe>
lea    -0x420(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1060 <get_sa@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1379 <lsshut+0x1f9>
lea    -0x420(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    0xd6a(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x830(%rbp),%rdi
mov    %eax,%edx
lea    0xd55(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    135f <lsshut+0x1df>
lea    -0x820(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   10a0 <strrd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     133e <lsshut+0x1be>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x420(%rbp),%rsi
lea    -0x820(%rbp),%rdx
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1374 <lsshut+0x1f4>
lea    -0x420(%rbp),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1379 <lsshut+0x1f9>
jmp    137e <lsshut+0x1fe>
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
lea    0xd95(%rip),%rdi
call   1070 <access@plt>
cmp    $0x0,%rax
jne    1460 <lsshut+0x2e0>
lea    -0x420(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   1060 <get_sa@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     145b <lsshut+0x2db>
lea    -0x420(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    0xc88(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x838(%rbp),%rdi
mov    %eax,%edx
lea    0xc73(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1441 <lsshut+0x2c1>
lea    -0x820(%rbp),%rdi
lea    0xd46(%rip),%rsi
call   10a0 <strrd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1420 <lsshut+0x2a0>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x420(%rbp),%rsi
lea    -0x820(%rbp),%rdx
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1456 <lsshut+0x2d6>
lea    -0x420(%rbp),%rsi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    145b <lsshut+0x2db>
jmp    1460 <lsshut+0x2e0>
mov    0x2b79(%rip),%rax
mov    (%rax),%esi
lea    0xd27(%rip),%rdi
call   1070 <access@plt>
cmp    $0x0,%rax
jne    1542 <lsshut+0x3c2>
lea    -0x420(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1060 <get_sa@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     153d <lsshut+0x3bd>
lea    -0x420(%rbp),%rax
mov    %rax,-0x840(%rbp)
lea    0xba6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x840(%rbp),%rdi
mov    %eax,%edx
lea    0xb91(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1523 <lsshut+0x3a3>
lea    -0x820(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   10a0 <strrd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1502 <lsshut+0x382>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x420(%rbp),%rsi
lea    -0x820(%rbp),%rdx
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1538 <lsshut+0x3b8>
lea    -0x420(%rbp),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    153d <lsshut+0x3bd>
jmp    1542 <lsshut+0x3c2>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsshut>:
push   %r14
push   %rbx
sub    $0x808,%rsp
call   10a0 <parse_lsshut_options@plt>
lea    0x1036(%rip),%rdi
call   1040 <puts@plt>
lea    0x1042(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e22(%rip),%r14
mov    (%r14),%esi
lea    0xe38(%rip),%rdi
call   1080 <access@plt>
test   %rax,%rax
je     1227 <lsshut+0x97>
mov    (%r14),%esi
lea    0xe9e(%rip),%rdi
call   1080 <access@plt>
test   %rax,%rax
je     1276 <lsshut+0xe6>
mov    (%r14),%esi
lea    0xefc(%rip),%rdi
call   1080 <access@plt>
test   %rax,%rax
je     12c9 <lsshut+0x139>
mov    (%r14),%esi
lea    0xf58(%rip),%rdi
call   1080 <access@plt>
test   %rax,%rax
je     131c <lsshut+0x18c>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe13(%rip),%rsi
mov    %rsp,%rdi
call   1070 <get_sa@plt>
cmp    $0xffffffff,%eax
je     11d2 <lsshut+0x42>
lea    0xde5(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     136f <lsshut+0x1df>
lea    0xdfe(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d2 <lsshut+0x42>
lea    0xe39(%rip),%rsi
mov    %rsp,%rdi
call   1070 <get_sa@plt>
cmp    $0xffffffff,%eax
je     11ea <lsshut+0x5a>
lea    0xd92(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13a9 <lsshut+0x219>
lea    0xe21(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11ea <lsshut+0x5a>
lea    0xe5b(%rip),%rsi
mov    %rsp,%rdi
call   1070 <get_sa@plt>
cmp    $0xffffffff,%eax
je     1202 <lsshut+0x72>
lea    0xd3f(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13e3 <lsshut+0x253>
lea    0xe42(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1202 <lsshut+0x72>
lea    0xe7e(%rip),%rsi
mov    %rsp,%rdi
call   1070 <get_sa@plt>
cmp    $0xffffffff,%eax
je     121a <lsshut+0x8a>
lea    0xcec(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1419 <lsshut+0x289>
lea    0xe67(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    121a <lsshut+0x8a>
lea    0xcb7(%rip),%rsi
lea    0x400(%rsp),%rdi
call   10b0 <strrd@plt>
test   %eax,%eax
jne    144f <lsshut+0x2bf>
lea    0xcb7(%rip),%rdi
mov    %rsp,%rsi
lea    0x400(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d2 <lsshut+0x42>
lea    0xcf2(%rip),%rsi
lea    0x400(%rsp),%rdi
call   10b0 <strrd@plt>
test   %eax,%eax
jne    144f <lsshut+0x2bf>
lea    0xcf3(%rip),%rdi
mov    %rsp,%rsi
lea    0x400(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11ea <lsshut+0x5a>
lea    0xd2d(%rip),%rsi
lea    0x400(%rsp),%rdi
call   10b0 <strrd@plt>
test   %eax,%eax
jne    144f <lsshut+0x2bf>
lea    0xd31(%rip),%rdi
mov    %rsp,%rsi
lea    0x400(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1202 <lsshut+0x72>
lea    0xd6d(%rip),%rsi
lea    0x400(%rsp),%rdi
call   10b0 <strrd@plt>
test   %eax,%eax
jne    144f <lsshut+0x2bf>
lea    0xd73(%rip),%rdi
mov    %rsp,%rsi
lea    0x400(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    121a <lsshut+0x8a>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Trigger Action\0A\00"
@.str.1 = [26 x i8] c"========================\0A\00"
@.str.2 = [39 x i8] c"/sys/firmware/shutdown_actions/on_halt\00"
@R_OK = global i32 0
@.str.3 = [8 x i8] c"on_halt\00"
@.str.4 = [6 x i8] c"vmcmd\00"
@.str.5 = [28 x i8] c"/sys/firmware/vmcmd/on_halt\00"
@.str.6 = [28 x i8] c"Halt %s (\22%s\22)\0A\00"
@.str.7 = [21 x i8] c"Halt %s\0A\00"
@.str.8 = [40 x i8] c"/sys/firmware/shutdown_actions/on_panic\00"
@.str.9 = [9 x i8] c"on_panic\00"
@.str.10 = [29 x i8] c"/sys/firmware/vmcmd/on_panic\00"
@.str.11 = [28 x i8] c"Panic %s (\22%s\22)\0A\00"
@.str.12 = [21 x i8] c"Panic %s\0A\00"
@.str.13 = [39 x i8] c"/sys/firmware/shutdown_actions/on_poff\00"
@.str.14 = [8 x i8] c"on_poff\00"
@.str.15 = [28 x i8] c"/sys/firmware/vmcmd/on_poff\00"
@.str.16 = [28 x i8] c"Power off %s (\22%s\22)\0A\00"
@.str.17 = [21 x i8] c"Power off %s\0A\00"
@.str.18 = [41 x i8] c"/sys/firmware/shutdown_actions/on_reboot\00"
@.str.19 = [10 x i8] c"on_reboot\00"
@.str.20 = [30 x i8] c"/sys/firmware/vmcmd/on_reboot\00"
@.str.21 = [28 x i8] c"Reboot %s (\22%s\22)\0A\00"
@.str.22 = [21 x i8] c"Reboot %s\0A\00"
define i32 @lsshut(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = load i8**, i8*** %4
%10 = call i32 @parse_lsshut_options(i32 %8, i8** %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @R_OK
%14 = call i64 @access(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %42
16: ; preds = %2
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i32 @get_sa(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %41
21: ; preds = %16
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%24 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%28 = call i32 @strrd(i8* %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %26
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %34, i8* %35)
br label %40
37: ; preds = %21
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40, %16
br label %42
42: ; preds = %41, %2
%43 = load i32, i32* @R_OK
%44 = call i64 @access(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i32 %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %72
46: ; preds = %42
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%48 = call i32 @get_sa(i8* %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
store i32 %48, i32* %5
%49 = load i32, i32* %5
%50 = icmp ne i32 %49, -1
br i1 %50, label %51, label %71
51: ; preds = %46
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%53 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%54 = call i64 @strncmp(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %51
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%58 = call i32 @strrd(i8* %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
store i32 %58, i32* %5
%59 = load i32, i32* %5
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %56
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %64, i8* %65)
br label %70
67: ; preds = %51
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %67, %63
br label %71
71: ; preds = %70, %46
br label %72
72: ; preds = %71, %42
%73 = load i32, i32* @R_OK
%74 = call i64 @access(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %73)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %102
76: ; preds = %72
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%78 = call i32 @get_sa(i8* %77, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
store i32 %78, i32* %5
%79 = load i32, i32* %5
%80 = icmp ne i32 %79, -1
br i1 %80, label %81, label %101
81: ; preds = %76
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%83 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%84 = call i64 @strncmp(i8* %82, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %83)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %97
86: ; preds = %81
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%88 = call i32 @strrd(i8* %87, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0))
store i32 %88, i32* %5
%89 = load i32, i32* %5
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %86
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %86
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %94, i8* %95)
br label %100
97: ; preds = %81
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* %98)
br label %100
100: ; preds = %97, %93
br label %101
101: ; preds = %100, %76
br label %102
102: ; preds = %101, %72
%103 = load i32, i32* @R_OK
%104 = call i64 @access(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0), i32 %103)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %132
106: ; preds = %102
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%108 = call i32 @get_sa(i8* %107, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0))
store i32 %108, i32* %5
%109 = load i32, i32* %5
%110 = icmp ne i32 %109, -1
br i1 %110, label %111, label %131
111: ; preds = %106
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%113 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%114 = call i64 @strncmp(i8* %112, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %113)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %127
116: ; preds = %111
%117 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%118 = call i32 @strrd(i8* %117, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.20, i64 0, i64 0))
store i32 %118, i32* %5
%119 = load i32, i32* %5
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %116
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %116
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.21, i64 0, i64 0), i8* %124, i8* %125)
br label %130
127: ; preds = %111
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %128)
br label %130
130: ; preds = %127, %123
br label %131
131: ; preds = %130, %106
br label %132
132: ; preds = %131, %102
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [39 x i8] c"/sys/firmware/shutdown_actions/on_halt\00"
@R_OK = global i32 0
@.str.3 = [8 x i8] c"on_halt\00"
@.str.4 = [6 x i8] c"vmcmd\00"
@.str.5 = [28 x i8] c"/sys/firmware/vmcmd/on_halt\00"
@.str.6 = [28 x i8] c"Halt %s (\22%s\22)\0A\00"
@.str.7 = [21 x i8] c"Halt %s\0A\00"
@.str.8 = [40 x i8] c"/sys/firmware/shutdown_actions/on_panic\00"
@.str.9 = [9 x i8] c"on_panic\00"
@.str.10 = [29 x i8] c"/sys/firmware/vmcmd/on_panic\00"
@.str.11 = [28 x i8] c"Panic %s (\22%s\22)\0A\00"
@.str.12 = [21 x i8] c"Panic %s\0A\00"
@.str.13 = [39 x i8] c"/sys/firmware/shutdown_actions/on_poff\00"
@.str.14 = [8 x i8] c"on_poff\00"
@.str.15 = [28 x i8] c"/sys/firmware/vmcmd/on_poff\00"
@.str.16 = [28 x i8] c"Power off %s (\22%s\22)\0A\00"
@.str.17 = [21 x i8] c"Power off %s\0A\00"
@.str.18 = [41 x i8] c"/sys/firmware/shutdown_actions/on_reboot\00"
@.str.19 = [10 x i8] c"on_reboot\00"
@.str.20 = [30 x i8] c"/sys/firmware/vmcmd/on_reboot\00"
@.str.21 = [28 x i8] c"Reboot %s (\22%s\22)\0A\00"
@.str.22 = [21 x i8] c"Reboot %s\0A\00"
@str = [24 x i8] c"Trigger Action\00"
@str.23 = [25 x i8] c"========================\00"
define i32 @lsshut(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @parse_lsshut_options(i32 %0, i8** %1)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.23, i64 0, i64 0))
%10 = load i32, i32* @R_OK
%11 = tail call i64 @access(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %2
%14 = call i32 @get_sa(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, -1
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = call i32 @strrd(i8* %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %5, i8* %6)
br label %29
27: ; preds = %16
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %5)
br label %29
29: ; preds = %13, %27, %25, %2
%30 = load i32, i32* @R_OK
%31 = call i64 @access(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %49
33: ; preds = %29
%34 = call i32 @get_sa(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%35 = icmp eq i32 %34, -1
br i1 %35, label %49, label %36
36: ; preds = %33
%37 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%38 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = call i32 @strrd(i8* %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %40
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %40
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8* %5, i8* %6)
br label %49
47: ; preds = %36
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %5)
br label %49
49: ; preds = %33, %47, %45, %29
%50 = load i32, i32* @R_OK
%51 = call i64 @access(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0), i32 %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %69
53: ; preds = %49
%54 = call i32 @get_sa(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0))
%55 = icmp eq i32 %54, -1
br i1 %55, label %69, label %56
56: ; preds = %53
%57 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%58 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = call i32 @strrd(i8* %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0))
%62 = icmp eq i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %60
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %5, i8* %6)
br label %69
67: ; preds = %56
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* %5)
br label %69
69: ; preds = %53, %67, %65, %49
%70 = load i32, i32* @R_OK
%71 = call i64 @access(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0), i32 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %89
73: ; preds = %69
%74 = call i32 @get_sa(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0))
%75 = icmp eq i32 %74, -1
br i1 %75, label %89, label %76
76: ; preds = %73
%77 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%78 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %87
80: ; preds = %76
%81 = call i32 @strrd(i8* %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.20, i64 0, i64 0))
%82 = icmp eq i32 %81, 0
br i1 %82, label %85, label %83
83: ; preds = %80
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %80
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.21, i64 0, i64 0), i8* %5, i8* %6)
br label %89
87: ; preds = %76
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %5)
br label %89
89: ; preds = %73, %87, %85, %69
ret i32 0
}