#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 */
char *strchr(char const *, char);
int /*<<< orphan*/ strncmp(char *, char *, int);
int get_ses_fru_identify_state(const char *buf) {
  char *fault;
  char *ident;
  fault = strchr(buf, 'o');
  if (!fault)
    return -1;
  fault++;
  ident = strchr(fault, 'o');
  if (!ident)
    return -1;
  return !strncmp(ident, "on", 2);
}


x86 assembly (clang, -O0):
<get_ses_fru_identify_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1155 <get_ses_fru_identify_state+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11af <get_ses_fru_identify_state+0x8f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118a <get_ses_fru_identify_state+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11af <get_ses_fru_identify_state+0x8f>
mov    -0x20(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ses_fru_identify_state>:
push   %rbx
mov    $0x6f,%esi
call   1040 <strchr@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     1166 <get_ses_fru_identify_state+0x46>
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x6f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1166 <get_ses_fru_identify_state+0x46>
lea    0xeae(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
define i32 @get_ses_fru_identify_state(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strchr(i8* %6, i8 signext 111)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 -1, i32* %2
br label %25
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i8* @strchr(i8* %14, i8 signext 111)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %11
store i32 -1, i32* %2
br label %25
19: ; preds = %11
%20 = load i8*, i8** %5
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %2
br label %25
25: ; preds = %19, %18, %10
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
define i32 @get_ses_fru_identify_state(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 111)
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = tail call i8* @strchr(i8* %5, i8 signext 111)
%7 = icmp eq i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %4, %1, %8
%13 = phi i32 [ %11, %8 ], [ -1, %1 ], [ -1, %4 ]
ret i32 %13
}