#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, int);
int handle_lock_level(int devfd, int nodeid, int level) {
  int ret;
  ret = send_then_recv(devfd, 'X', ">N%03dSS98,1,%d", nodeid, level);
  if (ret != 0)
    info(0,
         "node %d returned X%03x for LOCK/UNLOCK "
         "command\n",
         nodeid, ret);
  return -ret;
}


x86 assembly (clang, -O0):
<handle_lock_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x58,%esi
lea    0xeb9(%rip),%rdx
call   1030 <send_then_recv@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116d <handle_lock_level+0x4d>
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
xor    %edi,%edi
lea    0xea8(%rip),%rsi
call   1040 <info@plt>
xor    %eax,%eax
sub    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_lock_level>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%r8d
mov    %esi,%ebx
lea    0xed1(%rip),%rdx
mov    $0x58,%esi
mov    %ebx,%ecx
call   1030 <send_then_recv@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1153 <handle_lock_level+0x33>
lea    0xec8(%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 = [16 x i8] c">N%03dSS98,1,%d\00"
@.str.1 = [48 x i8] c"node %d returned X%03x for LOCK/UNLOCK command\0A\00"
define i32 @handle_lock_level(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @send_then_recv(i32 %8, i8 signext 88, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i32, i32* %7
%17 = call i32 @info(i32 0, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
br label %18
18: ; preds = %14, %3
%19 = load i32, i32* %7
%20 = sub nsw i32 0, %19
ret i32 %20
}

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