#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 */
typedef int int32_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ EspDrv_sendCmdGet(char *, char *, char *, char *, int);
int atoi(char *);
scalar_t__ isDigit(char);
int32_t EspDrv_getCurrentRSSI() {
  int ret;
  char buf[10];
  ;
  ret = 0;
  EspDrv_sendCmdGet("AT+CWJAP?", ",-", "\n\r", buf, sizeof(buf));
  if (isDigit(buf[0])) {
    ret = -atoi(buf);
  }
  return ret;
}


x86 assembly (clang, -O0):
<EspDrv_getCurrentRSSI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe(%rbp),%rcx
lea    0xeb6(%rip),%rdi
lea    0xeb9(%rip),%rsi
lea    0xeb5(%rip),%rdx
mov    $0xa,%r8d
call   1030 <EspDrv_sendCmdGet@plt>
movsbl -0xe(%rbp),%edi
call   1040 <isDigit@plt>
cmp    $0x0,%rax
je     1188 <EspDrv_getCurrentRSSI+0x58>
lea    -0xe(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EspDrv_getCurrentRSSI>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0xec8(%rip),%rsi
lea    0xec4(%rip),%rdx
lea    0xe(%rsp),%rcx
mov    $0xa,%r8d
call   1030 <EspDrv_sendCmdGet@plt>
movsbl 0xe(%rsp),%edi
call   1040 <isDigit@plt>
test   %rax,%rax
je     1179 <EspDrv_getCurrentRSSI+0x49>
lea    0xe(%rsp),%rdi
call   1050 <atoi@plt>
neg    %eax
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"AT+CWJAP?\00"
@.str.1 = [3 x i8] c",-\00"
@.str.2 = [3 x i8] c"\0A\0D\00"
define i32 @EspDrv_getCurrentRSSI() {
%1 = alloca i32
%2 = alloca [10 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @EspDrv_sendCmdGet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 10)
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = load i8, i8* %5
%7 = call i64 @isDigit(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 @atoi(i8* %10)
%12 = sub nsw i32 0, %11
store i32 %12, i32* %1
br label %13
13: ; preds = %9, %0
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [10 x i8] c"AT+CWJAP?\00"
@.str.1 = [3 x i8] c",-\00"
@.str.2 = [3 x i8] c"\0A\0D\00"
define i32 @EspDrv_getCurrentRSSI() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @EspDrv_sendCmdGet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 10)
%4 = load i8, i8* %2
%5 = call i64 @isDigit(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @atoi(i8* %2)
%9 = sub nsw i32 0, %8
br label %10
10: ; preds = %7, %0
%11 = phi i32 [ %9, %7 ], [ 0, %0 ]
ret i32 %11
}