#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 *, char);
char *get_ses_fru_location(char *buf) {
  char *fru;
  char *space;
  fru = strchr(buf, 'P');
  if (!fru) {
    fru = strchr(buf, '-');
    if (!fru)
      return NULL;
  }
  space = strchr(fru, ' ');
  if (!space)
    return NULL;
  *space = '\0';
  return fru;
}


x86 assembly (clang, -O0):
<get_ses_fru_location>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x50,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1168 <get_ses_fru_location+0x58>
mov    -0x10(%rbp),%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <get_ses_fru_location+0x53>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <get_ses_fru_location+0x91>
jmp    1168 <get_ses_fru_location+0x58>
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1192 <get_ses_fru_location+0x82>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <get_ses_fru_location+0x91>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ses_fru_location>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x50,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    113e <get_ses_fru_location+0x2e>
mov    %r14,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1155 <get_ses_fru_location+0x45>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1155 <get_ses_fru_location+0x45>
movb   $0x0,(%rax)
jmp    1157 <get_ses_fru_location+0x47>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @get_ses_fru_location(i8* %0) {
%2 = alloca i8*
%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 80)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %17, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @strchr(i8* %11, i8 signext 45)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %10
store i8* null, i8** %2
br label %26
16: ; preds = %10
br label %17
17: ; preds = %16, %1
%18 = load i8*, i8** %4
%19 = call i8* @strchr(i8* %18, i8 signext 32)
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %17
store i8* null, i8** %2
br label %26
23: ; preds = %17
%24 = load i8*, i8** %5
store i8 0, i8* %24
%25 = load i8*, i8** %4
store i8* %25, i8** %2
br label %26
26: ; preds = %23, %22, %15
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
define i8* @get_ses_fru_location(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 80)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4, %1
%8 = phi i8* [ %2, %1 ], [ %5, %4 ]
%9 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 32)
%10 = icmp eq i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %7
store i8 0, i8* %9
br label %12
12: ; preds = %7, %4, %11
%13 = phi i8* [ %8, %11 ], [ null, %4 ], [ null, %7 ]
ret i8* %13
}