#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*/ snprintf(char *, int, char *, int, char *);
int /*<<< orphan*/ system(char *);
void send_notification(int battery_level, int timeout) {
  char command[100];
  char *message;
  switch (battery_level) {
  case 15:
    message = "'Battery Notification' 'Battery level is LOW, charge soon'";
    break;
  case 10:
    message = "'Battery Notification' 'Battery level is CRITICAL, charge no!'";
    break;
  default:
    message = "'Battery Notification' 'Battery is nominal'";
    break;
  }
  snprintf(command, 100, "notify-send -u critical -t %i %s", timeout, message);
  system(command);
}


x86 assembly (clang, -O0):
<send_notification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x7c(%rbp)
sub    $0xa,%eax
je     1166 <send_notification+0x46>
jmp    1145 <send_notification+0x25>
mov    -0x7c(%rbp),%eax
sub    $0xf,%eax
jne    1176 <send_notification+0x56>
jmp    1156 <send_notification+0x36>
lea    0xea3(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    1181 <send_notification+0x61>
lea    0xece(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    1181 <send_notification+0x61>
lea    0xefd(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0x78(%rbp),%r8
mov    $0x64,%esi
lea    0xf0e(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <system@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_notification>:
push   %rbx
sub    $0x70,%rsp
mov    %esi,%ecx
cmp    $0xa,%edi
lea    0xf0a(%rip),%rax
lea    0xf42(%rip),%rdx
cmove  %rax,%rdx
cmp    $0xf,%edi
lea    0xeba(%rip),%r8
cmovne %rdx,%r8
lea    0xf55(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [59 x i8] c"'Battery Notification' 'Battery level is LOW, charge soon'\00"
@.str.1 = [63 x i8] c"'Battery Notification' 'Battery level is CRITICAL, charge no!'\00"
@.str.2 = [44 x i8] c"'Battery Notification' 'Battery is nominal'\00"
@.str.3 = [33 x i8] c"notify-send -u critical -t %i %s\00"
define void @send_notification(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
switch i32 %7, label %10 [
i32 15, label %8
i32 10, label %9
]
8: ; preds = %2
store i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8** %6
br label %11
9: ; preds = %2
store i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %11
10: ; preds = %2
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %11
11: ; preds = %10, %9, %8
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* %4
%14 = load i8*, i8** %6
%15 = call i32 @snprintf(i8* %12, i32 100, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%17 = call i32 @system(i8* %16)
ret void
}

LLVM IR (-O2):
@.str = [59 x i8] c"'Battery Notification' 'Battery level is LOW, charge soon'\00"
@.str.1 = [63 x i8] c"'Battery Notification' 'Battery level is CRITICAL, charge no!'\00"
@.str.2 = [44 x i8] c"'Battery Notification' 'Battery is nominal'\00"
@.str.3 = [33 x i8] c"notify-send -u critical -t %i %s\00"
define void @send_notification(i32 %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 10
%6 = select i1 %5, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0)
%7 = icmp eq i32 %0, 15
%8 = select i1 %7, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %6
%9 = call i32 @snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %1, i8* %8)
%10 = call i32 @system(i8* %4)
ret void
}