#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*/ info(int /*<<< orphan*/, char *, int, int);
int send_then_recv(int, char, char *, ...);
int handle_on(int devfd, int nodeid, char *arg) {
  int ret;
  if (nodeid == -2)
    ret = send_then_recv(devfd, 'X', ">N,ON");
  else
    ret = send_then_recv(devfd, 'X', ">N%03dON", nodeid);
  if (ret != 0)
    info(0, "node %d returned X%03x for ON command\n", nodeid, ret);
  return -ret;
}


x86 assembly (clang, -O0):
<handle_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0xfffffffe,-0x8(%rbp)
jne    115a <handle_on+0x3a>
mov    -0x4(%rbp),%edi
mov    $0x58,%esi
lea    0xeb5(%rip),%rdx
mov    $0x0,%al
call   1030 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
jmp    1176 <handle_on+0x56>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
mov    $0x58,%esi
lea    0xe9a(%rip),%rdx
mov    $0x0,%al
call   1030 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1194 <handle_on+0x74>
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %edi,%edi
lea    0xe80(%rip),%rsi
call   1040 <info@plt>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_on>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    $0xfffffffe,%esi
jne    113f <handle_on+0x1f>
lea    0xecf(%rip),%rdx
mov    $0x58,%esi
xor    %eax,%eax
call   1030 <send_then_recv@plt>
jmp    1154 <handle_on+0x34>
lea    0xec0(%rip),%rdx
mov    $0x58,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <send_then_recv@plt>
mov    %eax,%ebp
test   %eax,%eax
je     116c <handle_on+0x4c>
lea    0xeae(%rip),%rsi
xor    %edi,%edi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <info@plt>
neg    %ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c">N,ON\00"
@.str.1 = [9 x i8] c">N%03dON\00"
@.str.2 = [39 x i8] c"node %d returned X%03x for ON command\0A\00"
define i32 @handle_on(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, -2
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* %4
%12 = call i32 (i32, i8, i8*, ...) @send_then_recv(i32 %11, i8 signext 88, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %7
br label %17
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 (i32, i8, i8*, ...) @send_then_recv(i32 %14, i8 signext 88, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 %16, i32* %7
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = call i32 @info(i32 0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
br label %24
24: ; preds = %20, %17
%25 = load i32, i32* %7
%26 = sub nsw i32 0, %25
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c">N,ON\00"
@.str.1 = [9 x i8] c">N%03dON\00"
@.str.2 = [39 x i8] c"node %d returned X%03x for ON command\0A\00"
define i32 @handle_on(i32 %0, i32 %1, i8* nocapture readnone %2) {
%4 = icmp eq i32 %1, -2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i32, i8, i8*, ...) @send_then_recv(i32 %0, i8 signext 88, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %3
%8 = tail call i32 (i32, i8, i8*, ...) @send_then_recv(i32 %0, i8 signext 88, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @info(i32 0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %10)
br label %14
14: ; preds = %12, %9
%15 = sub nsw i32 0, %10
ret i32 %15
}