#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);
int portWrite(char *);
char *strstr(char *, char *);
int get_TemmaVERSION(char *local_buffer) {
  int err;
  if ((err = portWrite("v")) < 0) {
    return err;
  }
  portRead(local_buffer, -1, 1);
  if (strstr(local_buffer, "ver") == local_buffer) {
    return 0;
  } else
    return (-3);
}


x86 assembly (clang, -O0):
<get_TemmaVERSION>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <portWrite@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    115f <get_TemmaVERSION+0x2f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <get_TemmaVERSION+0x6f>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x1,%edx
call   1040 <portRead@plt>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1050 <strstr@plt>
cmp    -0x10(%rbp),%rax
jne    1198 <get_TemmaVERSION+0x68>
movl   $0x0,-0x4(%rbp)
jmp    119f <get_TemmaVERSION+0x6f>
movl   $0xfffffffd,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_TemmaVERSION>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1040 <portWrite@plt>
test   %eax,%eax
js     1177 <get_TemmaVERSION+0x47>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x1,%edx
call   1050 <portRead@plt>
lea    0xea5(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,2),%eax
add    $0xfffffffd,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"v\00"
@.str.1 = [4 x i8] c"ver\00"
define i32 @get_TemmaVERSION(i8* %0) {
%2 = tail call i32 @portWrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i32 %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(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 0, i32 -3
br label %9
9: ; preds = %4, %1
%10 = phi i32 [ %2, %1 ], [ %8, %4 ]
ret i32 %10
}