#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*/ portRead(char *, int, int);
scalar_t__ portWrite(char *);
char *strstr(char *, char *);
int get_TemmaBOTHcorrspeed(char *local_buffer) {
  if (portWrite("lg") < 0)
    return -1;
  portRead(local_buffer, -1, 1);
  if (strstr(local_buffer, "lg") == local_buffer) {
    return 0;
  } else
    return -1;
}


x86 assembly (clang, -O0):
<get_TemmaBOTHcorrspeed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <portWrite@plt>
cmp    $0x0,%rax
jge    115e <get_TemmaBOTHcorrspeed+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <get_TemmaBOTHcorrspeed+0x6e>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x1,%edx
call   1040 <portRead@plt>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1050 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1197 <get_TemmaBOTHcorrspeed+0x67>
movl   $0x0,-0x4(%rbp)
jmp    119e <get_TemmaBOTHcorrspeed+0x6e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_TemmaBOTHcorrspeed>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1040 <portWrite@plt>
test   %rax,%rax
js     1171 <get_TemmaBOTHcorrspeed+0x41>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x1,%edx
call   1050 <portRead@plt>
lea    0xea2(%rip),%rsi
mov    $0x2,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
neg    %eax
sbb    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"lg\00"
define i32 @get_TemmaBOTHcorrspeed(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i64 @portWrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 -1, i32* %2
br label %16
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @portRead(i8* %8, i32 -1, i32 1)
%10 = load i8*, i8** %3
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 0, i32* %2
br label %16
15: ; preds = %7
store i32 -1, i32* %2
br label %16
16: ; preds = %15, %14, %6
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [3 x i8] c"lg\00"
define i32 @get_TemmaBOTHcorrspeed(i8* %0) {
%2 = tail call i64 @portWrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @portRead(i8* %0, i32 -1, i32 1)
%6 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2)
%7 = icmp ne i32 %6, 0
%8 = sext i1 %7 to i32
br label %9
9: ; preds = %4, %1
%10 = phi i32 [ -1, %1 ], [ %8, %4 ]
ret i32 %10
}