#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 EINVAL;
scalar_t__ strcmp(char const *, char *);
int touch(char *);
__attribute__((visibility("hidden"))) int sd_readahead(const char *action) {
  if (!action)
    return -EINVAL;
  if (strcmp(action, "cancel") == 0)
    return touch("/run/systemd/readahead/cancel");
  else if (strcmp(action, "done") == 0)
    return touch("/run/systemd/readahead/done");
  else if (strcmp(action, "noreplay") == 0)
    return touch("/run/systemd/readahead/noreplay");
  return -EINVAL;
}


x86 assembly (clang, -O0):
<sd_readahead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <sd_readahead+0x2a>
xor    %eax,%eax
mov    0x2ea0(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11ec <sd_readahead+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1178 <sd_readahead+0x58>
lea    0xe95(%rip),%rdi
call   1030 <touch@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <sd_readahead+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <sd_readahead+0x86>
lea    0xe85(%rip),%rdi
call   1030 <touch@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <sd_readahead+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d4 <sd_readahead+0xb4>
lea    0xe73(%rip),%rdi
call   1030 <touch@plt>
mov    %eax,-0x4(%rbp)
jmp    11ec <sd_readahead+0xcc>
jmp    11d9 <sd_readahead+0xb9>
jmp    11de <sd_readahead+0xbe>
xor    %eax,%eax
mov    0x2df9(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_readahead>:
push   %rbx
test   %rdi,%rdi
je     1162 <sd_readahead+0x42>
mov    %rdi,%rbx
lea    0xee7(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116f <sd_readahead+0x4f>
lea    0xef4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117c <sd_readahead+0x5c>
lea    0xefc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1189 <sd_readahead+0x69>
mov    0x2e77(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rbx
ret
lea    0xe8a(%rip),%rdi
pop    %rbx
jmp    1030 <touch@plt>
lea    0xe9b(%rip),%rdi
pop    %rbx
jmp    1030 <touch@plt>
lea    0xeaa(%rip),%rdi
pop    %rbx
jmp    1030 <touch@plt>

LLVM IR (-O0):
@EINVAL = global i32 0
@.str = [7 x i8] c"cancel\00"
@.str.1 = [30 x i8] c"/run/systemd/readahead/cancel\00"
@.str.2 = [5 x i8] c"done\00"
@.str.3 = [28 x i8] c"/run/systemd/readahead/done\00"
@.str.4 = [9 x i8] c"noreplay\00"
@.str.5 = [32 x i8] c"/run/systemd/readahead/noreplay\00"
define hidden i32 @sd_readahead(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @EINVAL
%8 = sub nsw i32 0, %7
store i32 %8, i32* %2
br label %32
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @touch(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 %14, i32* %2
br label %32
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @touch(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 %20, i32* %2
br label %32
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @touch(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
store i32 %26, i32* %2
br label %32
27: ; preds = %21
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = load i32, i32* @EINVAL
%31 = sub nsw i32 0, %30
store i32 %31, i32* %2
br label %32
32: ; preds = %29, %25, %19, %13, %6
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@EINVAL = global i32 0
@.str = [7 x i8] c"cancel\00"
@.str.1 = [30 x i8] c"/run/systemd/readahead/cancel\00"
@.str.2 = [5 x i8] c"done\00"
@.str.3 = [28 x i8] c"/run/systemd/readahead/done\00"
@.str.4 = [9 x i8] c"noreplay\00"
@.str.5 = [32 x i8] c"/run/systemd/readahead/noreplay\00"
define hidden i32 @sd_readahead(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @EINVAL
%5 = sub nsw i32 0, %4
br label %24
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @touch(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %24
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @touch(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %24
16: ; preds = %11
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @touch(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %24
21: ; preds = %16
%22 = load i32, i32* @EINVAL
%23 = sub nsw i32 0, %22
br label %24
24: ; preds = %21, %19, %14, %9, %3
%25 = phi i32 [ %10, %9 ], [ %15, %14 ], [ %20, %19 ], [ %23, %21 ], [ %5, %3 ]
ret i32 %25
}