#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);
int handle_fan(int devfd, int nodeid, char *arg) {
  int ret;
  int enable = parse_uint(arg, 0, "fan enable", 1);
  ret = send_then_recv(devfd, 'X', ">N%03dSE68,1,%d", nodeid, enable);
  if (ret != 0)
    info(0, "node %d returned X%03x for FAN command\n", nodeid, ret);
  return ret;
}


x86 assembly (clang, -O0):
<handle_fan>:
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    $0x1,%ecx
call   1050 <parse_uint@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    $0x58,%esi
lea    0xe99(%rip),%rdx
call   1030 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1198 <handle_fan+0x68>
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %edi,%edi
lea    0xe88(%rip),%rsi
call   1040 <info@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_fan>:
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    $0x1,%ecx
call   1050 <parse_uint@plt>
lea    0xeb4(%rip),%rdx
mov    %ebp,%edi
mov    $0x58,%esi
mov    %ebx,%ecx
mov    %eax,%r8d
call   1030 <send_then_recv@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1180 <handle_fan+0x50>
lea    0xea6(%rip),%rsi
xor    %edi,%edi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <info@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"fan enable\00"
@.str.1 = [16 x i8] c">N%03dSE68,1,%d\00"
@.str.2 = [40 x i8] c"node %d returned X%03x for FAN command\0A\00"
define i32 @handle_fan(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 ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %10, i32* %8
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = load i32, i32* %8
%14 = call i32 @send_then_recv(i32 %11, i8 signext 88, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i32, i32* %5
%19 = load i32, i32* %7
%20 = call i32 @info(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %17, %3
%22 = load i32, i32* %7
ret i32 %22
}

LLVM IR (-O2):
@.str = [11 x i8] c"fan enable\00"
@.str.1 = [16 x i8] c">N%03dSE68,1,%d\00"
@.str.2 = [40 x i8] c"node %d returned X%03x for FAN command\0A\00"
define i32 @handle_fan(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @parse_uint(i8* %2, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%5 = tail call i32 @send_then_recv(i32 %0, i8 signext 88, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @info(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %5)
br label %9
9: ; preds = %7, %3
ret i32 %5
}