#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 handle_off(int, int, char *);
int handle_on(int, int, char *);
int handle_status_quiet(int, int, char *);
int handle_toggle(int devfd, int nodeid, char *arg) {
  int ret;
  ret = handle_status_quiet(devfd, nodeid, arg);
  if (ret < 0)
    return ret;
  if (ret == 0)
    return handle_on(devfd, nodeid, arg);
  else
    return handle_off(devfd, nodeid, arg);
}


x86 assembly (clang, -O0):
<handle_toggle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <handle_status_quiet@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1169 <handle_toggle+0x39>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119c <handle_toggle+0x6c>
cmpl   $0x0,-0x1c(%rbp)
jne    118a <handle_toggle+0x5a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <handle_on@plt>
mov    %eax,-0x4(%rbp)
jmp    119c <handle_toggle+0x6c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <handle_off@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_toggle>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <handle_status_quiet@plt>
test   %eax,%eax
js     1156 <handle_toggle+0x26>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14,%rdx
je     115b <handle_toggle+0x2b>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <handle_off@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <handle_on@plt>

LLVM IR (-O0):
define i32 @handle_toggle(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = load i8*, i8** %7
%12 = call i32 @handle_status_quiet(i32 %9, i32 %10, i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i32, i32* %8
store i32 %16, i32* %4
br label %30
17: ; preds = %3
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = load i8*, i8** %7
%24 = call i32 @handle_on(i32 %21, i32 %22, i8* %23)
store i32 %24, i32* %4
br label %30
25: ; preds = %17
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = load i8*, i8** %7
%29 = call i32 @handle_off(i32 %26, i32 %27, i8* %28)
store i32 %29, i32* %4
br label %30
30: ; preds = %25, %20, %15
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @handle_toggle(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @handle_status_quiet(i32 %0, i32 %1, i8* %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = icmp eq i32 %4, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @handle_on(i32 %0, i32 %1, i8* %2)
br label %12
10: ; preds = %6
%11 = tail call i32 @handle_off(i32 %0, i32 %1, i8* %2)
br label %12
12: ; preds = %3, %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ], [ %4, %3 ]
ret i32 %13
}