#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 notify_handler_async_real(int, int, int);
int /*<<< orphan*/ system(char *);
int notify_handler_async(int subsystemid, int action, int subaction) {
  if (subsystemid == 14010 || subsystemid == 4037) {
    if (action == 902)
      system("/app/bin/led_hijack"
             "/net.down");
    else if (action == 901)
      system("/app/bin/led_hijack"
             "/net.up");
  }
  return notify_handler_async_real(subsystemid, action, subaction);
}


x86 assembly (clang, -O0):
<notify_handler_async>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x36ba,-0x4(%rbp)
je     114b <notify_handler_async+0x2b>
cmpl   $0xfc5,-0x4(%rbp)
jne    118c <notify_handler_async+0x6c>
cmpl   $0x386,-0x8(%rbp)
jne    1169 <notify_handler_async+0x49>
lea    0xea1(%rip),%rdi
call   1030 <system@plt>
jmp    1187 <notify_handler_async+0x67>
cmpl   $0x385,-0x8(%rbp)
jne    1182 <notify_handler_async+0x62>
lea    0xea0(%rip),%rdi
call   1030 <system@plt>
jmp    1187 <notify_handler_async+0x67>
jmp    118c <notify_handler_async+0x6c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <notify_handler_async_real@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<notify_handler_async>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
cmp    $0x36ba,%edi
je     113b <notify_handler_async+0x1b>
cmp    $0xfc5,%ebx
jne    1160 <notify_handler_async+0x40>
cmp    $0x386,%ebp
je     1154 <notify_handler_async+0x34>
cmp    $0x385,%ebp
jne    1160 <notify_handler_async+0x40>
lea    0xecb(%rip),%rdi
jmp    115b <notify_handler_async+0x3b>
lea    0xea5(%rip),%rdi
call   1030 <system@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <notify_handler_async_real@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"/app/bin/led_hijack/net.down\00"
@.str.1 = [27 x i8] c"/app/bin/led_hijack/net.up\00"
define i32 @notify_handler_async(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 14010
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 4037
br i1 %11, label %12, label %24
12: ; preds = %9, %3
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 902
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %23
17: ; preds = %12
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 901
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @system(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
br label %23
23: ; preds = %22, %15
br label %24
24: ; preds = %23, %9
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @notify_handler_async_real(i32 %25, i32 %26, i32 %27)
ret i32 %28
}

LLVM IR (-O2):
@.str = [29 x i8] c"/app/bin/led_hijack/net.down\00"
@.str.1 = [27 x i8] c"/app/bin/led_hijack/net.up\00"
define i32 @notify_handler_async(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %9 [
i32 14010, label %4
i32 4037, label %4
]
4: ; preds = %3, %3
switch i32 %1, label %9 [
i32 902, label %6
i32 901, label %5
]
5: ; preds = %4
br label %6
6: ; preds = %4, %5
%7 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), %4 ]
%8 = tail call i32 @system(i8* %7)
br label %9
9: ; preds = %6, %4, %3
%10 = tail call i32 @notify_handler_async_real(i32 %0, i32 %1, i32 %2)
ret i32 %10
}