#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*/ fc8180_read(void *, int, ...);
unsigned int fc8180_get_rssi(void *handle, signed int *rssi) {
  signed char tmp = 0;
  unsigned char adj = 0;
  fc8180_read(handle, 0xf0, &adj);
  fc8180_read(handle, 0xf8, &tmp);
  *rssi = tmp;
  if (adj > 5) {
    if (tmp < 0)
      *rssi -= 3;
  } else {
    if (tmp < 0)
      *rssi += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fc8180_get_rssi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xf0,%esi
lea    -0x12(%rbp),%rdx
mov    $0x0,%al
call   1030 <fc8180_read@plt>
mov    -0x8(%rbp),%rdi
mov    $0xf8,%esi
lea    -0x11(%rbp),%rdx
mov    $0x0,%al
call   1030 <fc8180_read@plt>
movsbl -0x11(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movzbl -0x12(%rbp),%eax
cmp    $0x5,%eax
jle    1184 <fc8180_get_rssi+0x74>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jge    117f <fc8180_get_rssi+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x3,%ecx
mov    %ecx,(%rax)
jmp    11a1 <fc8180_get_rssi+0x91>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jge    119c <fc8180_get_rssi+0x8c>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11a1 <fc8180_get_rssi+0x91>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8180_get_rssi>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,0x7(%rsp)
movb   $0x0,0x6(%rsp)
lea    0x6(%rsp),%rdx
mov    $0xf0,%esi
xor    %eax,%eax
call   1030 <fc8180_read@plt>
lea    0x7(%rsp),%rdx
mov    %rbx,%rdi
mov    $0xf8,%esi
xor    %eax,%eax
call   1030 <fc8180_read@plt>
movsbl 0x7(%rsp),%eax
mov    %eax,(%r14)
test   %eax,%eax
jns    1168 <fc8180_get_rssi+0x58>
xor    %ecx,%ecx
cmpb   $0x6,0x6(%rsp)
setb   %cl
lea    (%rax,%rcx,4),%eax
add    $0xfffffffd,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @fc8180_get_rssi(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i32* %1, i32** %4
store i8 0, i8* %5
store i8 0, i8* %6
%7 = load i8*, i8** %3
%8 = call i32 (i8*, i32, ...) @fc8180_read(i8* %7, i32 240, i8* %6)
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i32, ...) @fc8180_read(i8* %9, i32 248, i8* %5)
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = load i32*, i32** %4
store i32 %12, i32* %13
%14 = load i8, i8* %6
%15 = zext i8 %14 to i32
%16 = icmp sgt i32 %15, 5
br i1 %16, label %17, label %26
17: ; preds = %2
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = sub nsw i32 %23, 3
store i32 %24, i32* %22
br label %25
25: ; preds = %21, %17
br label %35
26: ; preds = %2
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
br label %34
34: ; preds = %30, %26
br label %35
35: ; preds = %34, %25
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8180_get_rssi(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8
%4 = alloca i8
store i8 0, i8* %3
store i8 0, i8* %4
%5 = call i32 (i8*, i32, ...) @fc8180_read(i8* %0, i32 240, i8* %4)
%6 = call i32 (i8*, i32, ...) @fc8180_read(i8* %0, i32 248, i8* %3)
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
store i32 %8, i32* %1
%9 = icmp slt i8 %7, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8, i8* %4
%12 = icmp ugt i8 %11, 5
%13 = select i1 %12, i32 -3, i32 1
%14 = add nsw i32 %13, %8
store i32 %14, i32* %1
br label %15
15: ; preds = %2, %10
ret i32 0
}