#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*/ *strstr(char const *, char *);
int detect_partition(const char *ptr) {
  if (strstr(ptr, "boot") != NULL || strstr(ptr, "kernel") != NULL) {
    return 1;
  } else if (strstr(ptr, "recovery") != NULL) {
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<detect_partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
jne    1150 <detect_partition+0x40>
mov    -0x10(%rbp),%rdi
lea    0xec4(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     115c <detect_partition+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    1189 <detect_partition+0x79>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1182 <detect_partition+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1189 <detect_partition+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detect_partition>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
call   1030 <strstr@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1155 <detect_partition+0x45>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
jne    1155 <detect_partition+0x45>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
cmp    $0x1,%rax
sbb    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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