#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*/ filter_files(char *, char, int);
int /*<<< orphan*/ strcmp(char const *, char *);
void check_run_files(const char *action, const char *prev, const char *run) {
  char buf[4] = "rc0";
  if (!strcmp(action, "boot")) {
    filter_files("rcS", 'S', 0);
  } else if (!strcmp(action, "start")) {
    buf[2] = *prev;
    filter_files(buf, 'S', 1);
    buf[2] = *run;
    filter_files(buf, 'S', 0);
  } else {
    buf[2] = *prev;
    filter_files(buf, 'K', 1);
    buf[2] = *run;
    filter_files(buf, 'K', 0);
  }
}


x86 assembly (clang, -O0):
<check_run_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xec6(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    116e <check_run_files+0x4e>
lea    0xeac(%rip),%rdi
mov    $0x53,%esi
xor    %edx,%edx
call   1030 <filter_files@plt>
jmp    11fb <check_run_files+0xdb>
mov    -0x8(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <check_run_files+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x53,%esi
mov    $0x1,%edx
call   1030 <filter_files@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x53,%esi
xor    %edx,%edx
call   1030 <filter_files@plt>
jmp    11f6 <check_run_files+0xd6>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x4b,%esi
mov    $0x1,%edx
call   1030 <filter_files@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x4b,%esi
xor    %edx,%edx
call   1030 <filter_files@plt>
jmp    11fb <check_run_files+0xdb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_run_files>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x306372,0xc(%rsp)
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     118c <check_run_files+0x6c>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    (%r15),%cl
mov    %cl,0xe(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
test   %eax,%eax
je     11a8 <check_run_files+0x88>
mov    $0x4b,%esi
mov    $0x1,%edx
call   1030 <filter_files@plt>
mov    (%r14),%al
mov    %al,0xe(%rsp)
mov    %rbx,%rdi
mov    $0x4b,%esi
jmp    11c6 <check_run_files+0xa6>
lea    0xe72(%rip),%rdi
mov    $0x53,%esi
xor    %edx,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <filter_files@plt>
mov    $0x53,%esi
mov    $0x1,%edx
call   1030 <filter_files@plt>
mov    (%r14),%al
mov    %al,0xe(%rsp)
mov    %rbx,%rdi
mov    $0x53,%esi
xor    %edx,%edx
call   1030 <filter_files@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.check_run_files.buf = [4 x i8] c"rc0\00"
@.str = [5 x i8] c"boot\00"
@.str.1 = [4 x i8] c"rcS\00"
@.str.2 = [6 x i8] c"start\00"
define void @check_run_files(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [4 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = bitcast [4 x i8]* %7 to i8*
%9 = load i8*, i8** %4
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = call i32 @filter_files(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 83, i32 0)
br label %41
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %29, label %18
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %20, i8* %21
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%23 = call i32 @filter_files(i8* %22, i8 signext 83, i32 1)
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %25, i8* %26
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%28 = call i32 @filter_files(i8* %27, i8 signext 83, i32 0)
br label %40
29: ; preds = %14
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %31, i8* %32
%33 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%34 = call i32 @filter_files(i8* %33, i8 signext 75, i32 1)
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %36, i8* %37
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%39 = call i32 @filter_files(i8* %38, i8 signext 75, i32 0)
br label %40
40: ; preds = %29, %18
br label %41
41: ; preds = %40, %12
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"boot\00"
@.str.1 = [4 x i8] c"rcS\00"
@.str.2 = [6 x i8] c"start\00"
define void @check_run_files(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 3171186, i32* %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @filter_files(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext 83, i32 0)
br label %24
10: ; preds = %3
%11 = bitcast i32* %4 to [4 x i8]*
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = load i8, i8* %1
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 2
store i8 %14, i8* %15
br i1 %13, label %16, label %20
16: ; preds = %10
%17 = call i32 @filter_files(i8* %5, i8 signext 83, i32 1)
%18 = load i8, i8* %2
store i8 %18, i8* %15
%19 = call i32 @filter_files(i8* %5, i8 signext 83, i32 0)
br label %24
20: ; preds = %10
%21 = call i32 @filter_files(i8* %5, i8 signext 75, i32 1)
%22 = load i8, i8* %2
store i8 %22, i8* %15
%23 = call i32 @filter_files(i8* %5, i8 signext 75, i32 0)
br label %24
24: ; preds = %16, %20, %8
ret void
}