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


x86 assembly (clang, -O0):
<handle_scene>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
lea    0xeb1(%rip),%rdx
mov    $0xe8,%ecx
call   1050 <parse_uint@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xfffffffe,-0x8(%rbp)
jne    1187 <handle_scene+0x57>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    $0x58,%esi
lea    0xe95(%rip),%rdx
mov    $0x0,%al
call   1030 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
jmp    11a7 <handle_scene+0x77>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    $0x58,%esi
lea    0xe77(%rip),%rdx
mov    $0x0,%al
call   1030 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11c5 <handle_scene+0x95>
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %edi,%edi
lea    0xe5e(%rip),%rsi
call   1040 <info@plt>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_scene>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xebf(%rip),%rdx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe8,%ecx
call   1050 <parse_uint@plt>
cmp    $0xfffffffe,%ebx
jne    116e <handle_scene+0x3e>
lea    0xeb1(%rip),%rdx
mov    %ebp,%edi
mov    $0x58,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <send_then_recv@plt>
jmp    1188 <handle_scene+0x58>
lea    0xe9f(%rip),%rdx
mov    %ebp,%edi
mov    $0x58,%esi
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <send_then_recv@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11a0 <handle_scene+0x70>
lea    0xe89(%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 = [13 x i8] c"scene number\00"
@.str.1 = [7 x i8] c">N,S%d\00"
@.str.2 = [10 x i8] c">N%03dS%d\00"
@.str.3 = [42 x i8] c"node %d returned X%03x for SCENE command\0A\00"
define i32 @handle_scene(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = call i32 @parse_uint(i8* %9, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 232)
store i32 %10, i32* %8
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -2
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i32, i32* %8
%16 = call i32 (i32, i8, i8*, i32, ...) @send_then_recv(i32 %14, i8 signext 88, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 %16, i32* %7
br label %22
17: ; preds = %3
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %8
%21 = call i32 (i32, i8, i8*, i32, ...) @send_then_recv(i32 %18, i8 signext 88, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20)
store i32 %21, i32* %7
br label %22
22: ; preds = %17, %13
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %5
%27 = load i32, i32* %7
%28 = call i32 @info(i32 0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27)
br label %29
29: ; preds = %25, %22
%30 = load i32, i32* %7
%31 = sub nsw i32 0, %30
ret i32 %31
}

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