#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ battery_is_charging(char const *, char const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int get_battery_level(char const *);
scalar_t__ is_program_running(char *, scalar_t__ *, int);
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ report_unknown_argument(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char const *);
int /*<<< orphan*/ write_to_log(char *, int);
int main(int argc, char **argv) {
  const char battery_path_capacity[] = "/sys/class/power_supply/BAT0/capacity";
  const char battery_path_status[] = "/sys/class/power_supply/BAT0/status";
  const char shutdown_command[] = "systemctl poweroff";
  const char charging_string[] = "Charging";
  int i, battery_level = 0;
  bool single_mode = true;
  bool kill_x = false;
  pid_t pids[20];
  while (argc-- > 1) {
    if (**(++argv) != '-')
      report_unknown_argument(*argv);
    else {
      while (*(++(*argv))) {
        switch (**argv) {
        case 'x':
          kill_x = true;
          break;
        case 'c':
          single_mode = false;
          break;
        default:
          report_unknown_argument(*argv);
        }
      }
    }
  }
  for (i = 0; i < 20; i++)
    pids[i] = 0;
  do {
    if (!battery_is_charging(battery_path_status, charging_string)) {
      battery_level = get_battery_level(battery_path_capacity);
      if (battery_level < 16) {
        if (battery_level < 12) {
          write_to_log("Shutting down system due to low battery", false);
          system(shutdown_command);
        } else if (kill_x) {
          if (is_program_running("Xorg", pids, 20)) {
            write_to_log("Exiting graphical environment due to low battery",
                         false);
            i = 0;
            while (pids[i] && i < 20)
              kill(pids[i++], SIGTERM);
          }
        }
      }
    }
    if (!single_mode)
      sleep(60);
  } while (!single_mode);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x26,%edx
call   1070 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
mov    0xe76(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xe6a(%rip),%ax
mov    %ax,-0x80(%rbp)
mov    0xe62(%rip),%al
mov    %al,-0x7e(%rbp)
mov    0xe59(%rip),%rax
mov    %rax,-0x99(%rbp)
mov    0xe54(%rip),%al
mov    %al,-0x91(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x1,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x1,%eax
jle    131a <main+0x17a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     128f <main+0xef>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <report_unknown_argument@plt>
jmp    1315 <main+0x175>
jmp    1294 <main+0xf4>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
cmpb   $0x0,0x1(%rax)
je     1310 <main+0x170>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x154(%rbp)
sub    $0x63,%eax
je     12f0 <main+0x150>
jmp    12cd <main+0x12d>
mov    -0x154(%rbp),%eax
sub    $0x78,%eax
jne    12ff <main+0x15f>
jmp    12e1 <main+0x141>
movl   $0x1,-0xac(%rbp)
jmp    130b <main+0x16b>
movl   $0x0,-0xa8(%rbp)
jmp    130b <main+0x16b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <report_unknown_argument@plt>
jmp    1294 <main+0xf4>
jmp    1315 <main+0x175>
jmp    124b <main+0xab>
movl   $0x0,-0xa0(%rbp)
cmpl   $0x14,-0xa0(%rbp)
jge    1358 <main+0x1b8>
movslq -0xa0(%rbp),%rax
movq   $0x0,-0x150(%rbp,%rax,8)
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    1324 <main+0x184>
jmp    135d <main+0x1bd>
lea    -0x70(%rbp),%rdi
lea    -0x99(%rbp),%rsi
call   10a0 <battery_is_charging@plt>
cmp    $0x0,%eax
jne    148d <main+0x2ed>
lea    -0x40(%rbp),%rdi
call   1090 <get_battery_level@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x10,-0xa4(%rbp)
jge    1488 <main+0x2e8>
cmpl   $0xc,-0xa4(%rbp)
jge    13be <main+0x21e>
lea    0xcd6(%rip),%rdi
xor    %esi,%esi
call   1030 <write_to_log@plt>
lea    -0x90(%rbp),%rdi
call   1040 <system@plt>
jmp    1483 <main+0x2e3>
cmpl   $0x0,-0xac(%rbp)
je     147e <main+0x2de>
lea    -0x150(%rbp),%rsi
lea    0xccb(%rip),%rdi
mov    $0x14,%edx
call   1060 <is_program_running@plt>
cmp    $0x0,%rax
je     1479 <main+0x2d9>
lea    0xcb5(%rip),%rdi
xor    %esi,%esi
call   1030 <write_to_log@plt>
movl   $0x0,-0xa0(%rbp)
movslq -0xa0(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,-0x150(%rbp,%rcx,8)
mov    %al,-0x155(%rbp)
je     1433 <main+0x293>
cmpl   $0x14,-0xa0(%rbp)
setl   %al
mov    %al,-0x155(%rbp)
mov    -0x155(%rbp),%al
test   $0x1,%al
jne    1446 <main+0x2a6>
jmp    1474 <main+0x2d4>
mov    -0xa0(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xa0(%rbp)
cltq
mov    -0x150(%rbp,%rax,8),%rdi
ff
mov    0x2b80(%rip),%rax
mov    (%rax),%esi
call   1080 <kill@plt>
jmp    1405 <main+0x265>
jmp    1479 <main+0x2d9>
jmp    147e <main+0x2de>
jmp    1483 <main+0x2e3>
jmp    1488 <main+0x2e8>
jmp    148d <main+0x2ed>
cmpl   $0x0,-0xa8(%rbp)
jne    14a4 <main+0x304>
mov    $0x3c,%edi
call   10c0 <sleep@plt>
jmp    14a9 <main+0x309>
cmpl   $0x0,-0xa8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    135d <main+0x1bd>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
movaps 0xe68(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe4c(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movabs $0x79746963617061,%rax
mov    %rax,0x7e(%rsp)
movaps 0xe71(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe55(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x737574,0x50(%rsp)
movaps 0xe71(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x66666f,0x1f(%rsp)
movabs $0x676e696772616843,%rax
69 6e 67
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jl     1297 <main+0x107>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    $0x1,%r12d
xor    %ebp,%ebp
jmp    1245 <main+0xb5>
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1050 <report_unknown_argument@plt>
lea    -0x1(%r14),%eax
cmp    $0x2,%r14d
mov    %eax,%r14d
jle    129f <main+0x10f>
mov    0x8(%rbx),%rax
add    $0x8,%rbx
cmpb   $0x2d,(%rax)
jne    1230 <main+0xa0>
lea    0x1(%rax),%rdi
mov    %rdi,(%rbx)
mov    0x1(%rax),%al
jmp    1276 <main+0xe6>
xchg   %ax,%ax
call   1050 <report_unknown_argument@plt>
mov    (%rbx),%rdi
lea    0x1(%rdi),%rcx
mov    %rcx,(%rbx)
movzbl 0x1(%rdi),%eax
mov    %rcx,%rdi
test   %al,%al
je     1238 <main+0xa8>
movsbl %al,%eax
cmp    $0x78,%eax
je     1290 <main+0x100>
cmp    $0x63,%eax
jne    1260 <main+0xd0>
xor    %r12d,%r12d
jmp    1268 <main+0xd8>
nopl   0x0(%rax)
mov    $0x1,%ebp
jmp    1268 <main+0xd8>
xor    %ebp,%ebp
mov    $0x1,%r12d
xorps  %xmm0,%xmm0
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
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)
lea    0x30(%rsp),%r14
mov    %rsp,%rbx
mov    0x2ce7(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <battery_is_charging@plt>
test   %eax,%eax
jne    13d0 <main+0x240>
lea    0x60(%rsp),%rdi
call   1080 <get_battery_level@plt>
cmp    $0xf,%eax
jg     13d0 <main+0x240>
cmp    $0xb,%eax
jg     1355 <main+0x1c5>
lea    0xd3a(%rip),%rdi
xor    %esi,%esi
call   1030 <write_to_log@plt>
lea    0x10(%rsp),%rdi
call   1040 <system@plt>
jmp    13d0 <main+0x240>
test   %ebp,%ebp
je     13d0 <main+0x240>
lea    0xd44(%rip),%rdi
lea    0x90(%rsp),%rsi
mov    $0x14,%edx
call   1060 <is_program_running@plt>
test   %rax,%rax
je     13d0 <main+0x240>
lea    0xd2b(%rip),%rdi
xor    %esi,%esi
call   1030 <write_to_log@plt>
mov    0x90(%rsp),%rdi
test   %rdi,%rdi
je     13d0 <main+0x240>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%esi
call   1070 <kill@plt>
mov    0x98(%rsp,%r15,8),%rdi
test   %rdi,%rdi
je     13d0 <main+0x240>
lea    0x1(%r15),%rax
cmp    $0x13,%r15
mov    %rax,%r15
jb     13a0 <main+0x210>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %r12d,%r12d
jne    13e4 <main+0x254>
mov    $0x3c,%edi
call   10b0 <sleep@plt>
jmp    1310 <main+0x180>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@__const.main.battery_path_capacity = [38 x i8] c"/sys/class/power_supply/BAT0/capacity\00"
@__const.main.battery_path_status = [36 x i8] c"/sys/class/power_supply/BAT0/status\00"
@__const.main.shutdown_command = [19 x i8] c"systemctl poweroff\00"
@__const.main.charging_string = [9 x i8] c"Charging\00"
@.str = [40 x i8] c"Shutting down system due to low battery\00"
@.str.1 = [5 x i8] c"Xorg\00"
@.str.2 = [49 x i8] c"Exiting graphical environment due to low battery\00"
@SIGTERM = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [38 x i8]
%7 = alloca [36 x i8]
%8 = alloca [19 x i8]
%9 = alloca [9 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [20 x i64]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [38 x i8]* %6 to i8*
%16 = bitcast [36 x i8]* %7 to i8*
%17 = bitcast [19 x i8]* %8 to i8*
%18 = bitcast [9 x i8]* %9 to i8*
store i32 0, i32* %11
store i32 1, i32* %12
store i32 0, i32* %13
br label %19
19: ; preds = %54, %2
%20 = load i32, i32* %4
%21 = add nsw i32 %20, -1
store i32 %21, i32* %4
%22 = icmp sgt i32 %20, 1
br i1 %22, label %23, label %55
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %5
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 45
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 @report_unknown_argument(i8* %32)
br label %54
34: ; preds = %23
br label %35
35: ; preds = %52, %34
%36 = load i8**, i8*** %5
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %36
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %41, label %53
41: ; preds = %35
%42 = load i8**, i8*** %5
%43 = load i8*, i8** %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
switch i32 %45, label %48 [
i32 120, label %46
i32 99, label %47
]
46: ; preds = %41
store i32 1, i32* %13
br label %52
47: ; preds = %41
store i32 0, i32* %12
br label %52
48: ; preds = %41
%49 = load i8**, i8*** %5
%50 = load i8*, i8** %49
%51 = call i32 @report_unknown_argument(i8* %50)
br label %52
52: ; preds = %48, %47, %46
br label %35
53: ; preds = %35
br label %54
54: ; preds = %53, %30
br label %19
55: ; preds = %19
store i32 0, i32* %10
br label %56
56: ; preds = %63, %55
%57 = load i32, i32* %10
%58 = icmp slt i32 %57, 20
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [20 x i64], [20 x i64]* %14, i64 0, i64 %61
store i64 0, i64* %62
br label %63
63: ; preds = %59
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
br label %56
66: ; preds = %56
br label %67
67: ; preds = %123, %66
%68 = getelementptr inbounds [36 x i8], [36 x i8]* %7, i64 0, i64 0
%69 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%70 = call i32 @battery_is_charging(i8* %68, i8* %69)
%71 = icmp ne i32 %70, 0
br i1 %71, label %117, label %72
72: ; preds = %67
%73 = getelementptr inbounds [38 x i8], [38 x i8]* %6, i64 0, i64 0
%74 = call i32 @get_battery_level(i8* %73)
store i32 %74, i32* %11
%75 = load i32, i32* %11
%76 = icmp slt i32 %75, 16
br i1 %76, label %77, label %116
77: ; preds = %72
%78 = load i32, i32* %11
%79 = icmp slt i32 %78, 12
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = call i32 @write_to_log(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 0)
%82 = getelementptr inbounds [19 x i8], [19 x i8]* %8, i64 0, i64 0
%83 = call i32 @system(i8* %82)
br label %115
84: ; preds = %77
%85 = load i32, i32* %13
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %114
87: ; preds = %84
%88 = getelementptr inbounds [20 x i64], [20 x i64]* %14, i64 0, i64 0
%89 = call i64 @is_program_running(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %88, i32 20)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %113
91: ; preds = %87
%92 = call i32 @write_to_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 0)
store i32 0, i32* %10
br label %93
93: ; preds = %104, %91
%94 = load i32, i32* %10
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [20 x i64], [20 x i64]* %14, i64 0, i64 %95
%97 = load i64, i64* %96
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %93
%100 = load i32, i32* %10
%101 = icmp slt i32 %100, 20
br label %102
102: ; preds = %99, %93
%103 = phi i1 [ false, %93 ], [ %101, %99 ]
br i1 %103, label %104, label %112
104: ; preds = %102
%105 = load i32, i32* %10
%106 = add nsw i32 %105, 1
store i32 %106, i32* %10
%107 = sext i32 %105 to i64
%108 = getelementptr inbounds [20 x i64], [20 x i64]* %14, i64 0, i64 %107
%109 = load i64, i64* %108
%110 = load i32, i32* @SIGTERM
%111 = call i32 @kill(i64 %109, i32 %110)
br label %93
112: ; preds = %102
br label %113
113: ; preds = %112, %87
br label %114
114: ; preds = %113, %84
br label %115
115: ; preds = %114, %80
br label %116
116: ; preds = %115, %72
br label %117
117: ; preds = %116, %67
%118 = load i32, i32* %12
%119 = icmp ne i32 %118, 0
br i1 %119, label %122, label %120
120: ; preds = %117
%121 = call i32 @sleep(i32 60)
br label %122
122: ; preds = %120, %117
br label %123
123: ; preds = %122
%124 = load i32, i32* %12
%125 = icmp ne i32 %124, 0
%126 = xor i1 %125, true
br i1 %126, label %67, label %127
127: ; preds = %123
%128 = load i32, i32* @EXIT_SUCCESS
%129 = call i32 @exit(i32 %128)
unreachable
}

LLVM IR (-O2):
@__const.main.battery_path_capacity = [38 x i8] c"/sys/class/power_supply/BAT0/capacity\00"
@__const.main.battery_path_status = [36 x i8] c"/sys/class/power_supply/BAT0/status\00"
@__const.main.shutdown_command = [19 x i8] c"systemctl poweroff\00"
@__const.main.charging_string = [9 x i8] c"Charging\00"
@.str = [40 x i8] c"Shutting down system due to low battery\00"
@.str.1 = [5 x i8] c"Xorg\00"
@.str.2 = [49 x i8] c"Exiting graphical environment due to low battery\00"
@SIGTERM = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [38 x i8]
%4 = alloca [36 x i8]
%5 = alloca [19 x i8]
%6 = alloca [9 x i8]
%7 = alloca [20 x i64]
%8 = bitcast [20 x i64]* %7 to i8*
%9 = getelementptr inbounds [38 x i8], [38 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [36 x i8], [36 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [19 x i8], [19 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%13 = icmp sgt i32 %0, 1
br i1 %13, label %20, label %14
14: ; preds = %53, %2
%15 = phi i32 [ 1, %2 ], [ %54, %53 ]
%16 = phi i32 [ 0, %2 ], [ %55, %53 ]
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds [20 x i64], [20 x i64]* %7, i64 0, i64 0
%19 = icmp eq i32 %15, 0
br label %57
20: ; preds = %2, %53
%21 = phi i32 [ %25, %53 ], [ %0, %2 ]
%22 = phi i32 [ %55, %53 ], [ 0, %2 ]
%23 = phi i32 [ %54, %53 ], [ 1, %2 ]
%24 = phi i8** [ %26, %53 ], [ %1, %2 ]
%25 = add nsw i32 %21, -1
%26 = getelementptr inbounds i8*, i8** %24, i64 1
%27 = load i8*, i8** %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 45
br i1 %29, label %30, label %34
30: ; preds = %20
%31 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %31, i8** %26
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %53, label %36
34: ; preds = %20
%35 = tail call i32 @report_unknown_argument(i8* %27)
br label %53
36: ; preds = %30, %46
%37 = phi i8 [ %51, %46 ], [ %32, %30 ]
%38 = phi i8* [ %50, %46 ], [ %31, %30 ]
%39 = phi i32 [ %49, %46 ], [ %22, %30 ]
%40 = phi i32 [ %48, %46 ], [ %23, %30 ]
%41 = sext i8 %37 to i32
switch i32 %41, label %43 [
i32 120, label %46
i32 99, label %42
]
42: ; preds = %36
br label %46
43: ; preds = %36
%44 = tail call i32 @report_unknown_argument(i8* %38)
%45 = load i8*, i8** %26
br label %46
46: ; preds = %36, %43, %42
%47 = phi i8* [ %45, %43 ], [ %38, %42 ], [ %38, %36 ]
%48 = phi i32 [ %40, %43 ], [ 0, %42 ], [ %40, %36 ]
%49 = phi i32 [ %39, %43 ], [ %39, %42 ], [ 1, %36 ]
%50 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %50, i8** %26
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %36
53: ; preds = %46, %30, %34
%54 = phi i32 [ %23, %34 ], [ %23, %30 ], [ %48, %46 ]
%55 = phi i32 [ %22, %34 ], [ %22, %30 ], [ %49, %46 ]
%56 = icmp sgt i32 %21, 2
br i1 %56, label %20, label %14
57: ; preds = %14, %88
%58 = call i32 @battery_is_charging(i8* %10, i8* %12)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %87
60: ; preds = %57
%61 = call i32 @get_battery_level(i8* %9)
%62 = icmp slt i32 %61, 16
br i1 %62, label %63, label %87
63: ; preds = %60
%64 = icmp slt i32 %61, 12
br i1 %64, label %65, label %68
65: ; preds = %63
%66 = call i32 @write_to_log(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 0)
%67 = call i32 @system(i8* %11)
br label %87
68: ; preds = %63
br i1 %17, label %87, label %69
69: ; preds = %68
%70 = call i64 @is_program_running(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %18, i32 20)
%71 = icmp eq i64 %70, 0
br i1 %71, label %87, label %72
72: ; preds = %69
%73 = call i32 @write_to_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 0)
%74 = load i64, i64* %18
%75 = icmp eq i64 %74, 0
br i1 %75, label %87, label %76
76: ; preds = %72, %76
%77 = phi i64 [ %79, %76 ], [ 0, %72 ]
%78 = phi i64 [ %83, %76 ], [ %74, %72 ]
%79 = add nuw nsw i64 %77, 1
%80 = load i32, i32* @SIGTERM
%81 = call i32 @kill(i64 %78, i32 %80)
%82 = getelementptr inbounds [20 x i64], [20 x i64]* %7, i64 0, i64 %79
%83 = load i64, i64* %82
%84 = icmp ne i64 %83, 0
%85 = icmp ult i64 %77, 19
%86 = select i1 %84, i1 %85, i1 false
br i1 %86, label %76, label %87
87: ; preds = %76, %72, %60, %68, %69, %65, %57
br i1 %19, label %88, label %90
88: ; preds = %87
%89 = call i32 @sleep(i32 60)
br label %57
90: ; preds = %87
%91 = load i32, i32* @EXIT_SUCCESS
%92 = call i32 @exit(i32 %91)
unreachable
}