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

/* Variables and functions */
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *, char *,
                         int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int nagbar_warn(void) {
  pid_t pid = fork();
  if (pid == 0) {
    execl("/usr/bin/i3-nagbar", "i3-nagbar", "-t", "warning", "-m",
          "Battery level is low.", NULL);
    perror("exec");
  } else if (pid == -1) {
    perror("fork");
    return -1;
  }
  sleep(10);
  kill(pid, SIGTERM);
  wait(NULL);
  return 0;
}


x86 assembly (clang, -O0):
<nagbar_warn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11c6 <nagbar_warn+0x66>
lea    0xe7d(%rip),%rdi
lea    0xe7f(%rip),%rsi
lea    0xe82(%rip),%rdx
lea    0xe7e(%rip),%rcx
lea    0xe7f(%rip),%r8
lea    0xe7b(%rip),%r9
xor    %eax,%eax
movq   $0x0,(%rsp)
call   1050 <execl@plt>
lea    0xe7b(%rip),%rdi
call   1040 <perror@plt>
jmp    11ed <nagbar_warn+0x8d>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11e8 <nagbar_warn+0x88>
lea    0xe65(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1218 <nagbar_warn+0xb8>
jmp    11ed <nagbar_warn+0x8d>
mov    $0xa,%edi
call   1060 <sleep@plt>
mov    -0x8(%rbp),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nagbar_warn>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <fork@plt>
cmp    $0xffffffff,%eax
je     11a2 <nagbar_warn+0x42>
mov    %eax,%ebx
test   %eax,%eax
je     11b5 <nagbar_warn+0x55>
mov    $0xa,%edi
call   1060 <sleep@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1030 <kill@plt>
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <wait@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe93(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%ebx
jmp    119a <nagbar_warn+0x3a>
movq   $0x0,(%rsp)
lea    0xe3c(%rip),%rdi
lea    0xe3e(%rip),%rsi
lea    0xe41(%rip),%rdx
lea    0xe3d(%rip),%rcx
lea    0xe3e(%rip),%r8
lea    0xe3a(%rip),%r9
call   1050 <execl@plt>
lea    0xe44(%rip),%rdi
call   1040 <perror@plt>
jmp    1177 <nagbar_warn+0x17>

LLVM IR (-O0):
@.str = [19 x i8] c"/usr/bin/i3-nagbar\00"
@.str.1 = [10 x i8] c"i3-nagbar\00"
@.str.2 = [3 x i8] c"-t\00"
@.str.3 = [8 x i8] c"warning\00"
@.str.4 = [3 x i8] c"-m\00"
@.str.5 = [22 x i8] c"Battery level is low.\00"
@.str.6 = [5 x i8] c"exec\00"
@.str.7 = [5 x i8] c"fork\00"
@SIGTERM = global i32 0
define i32 @nagbar_warn() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @fork()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32* null)
%8 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %15
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %21
14: ; preds = %9
br label %15
15: ; preds = %14, %6
%16 = call i32 @sleep(i32 10)
%17 = load i32, i32* %2
%18 = load i32, i32* @SIGTERM
%19 = call i32 @kill(i32 %17, i32 %18)
%20 = call i32 @wait(i32* null)
store i32 0, i32* %1
br label %21
21: ; preds = %15, %12
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [19 x i8] c"/usr/bin/i3-nagbar\00"
@.str.1 = [10 x i8] c"i3-nagbar\00"
@.str.2 = [3 x i8] c"-t\00"
@.str.3 = [8 x i8] c"warning\00"
@.str.4 = [3 x i8] c"-m\00"
@.str.5 = [22 x i8] c"Battery level is low.\00"
@.str.6 = [5 x i8] c"exec\00"
@.str.7 = [5 x i8] c"fork\00"
@SIGTERM = global i32 0
define i32 @nagbar_warn() {
%1 = tail call i32 (...) @fork()
switch i32 %1, label %7 [
i32 0, label %2
i32 -1, label %5
]
2: ; preds = %0
%3 = tail call i32 @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32* null)
%4 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %12
7: ; preds = %0, %2
%8 = tail call i32 @sleep(i32 10)
%9 = load i32, i32* @SIGTERM
%10 = tail call i32 @kill(i32 %1, i32 %9)
%11 = tail call i32 @wait(i32* null)
br label %12
12: ; preds = %7, %5
%13 = phi i32 [ 0, %7 ], [ -1, %5 ]
ret i32 %13
}