#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*/ die(char *, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ free(char *);
char *read_file(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char const *);
char *strtok(char *, char *);
void check_plugin(const char *plugin) {
  char *buf;
  char *tok;
  if (strcmp(plugin, "nop") == 0)
    return;
  buf = read_file("available_tracers", NULL);
  if (!buf)
    die("No plugins available");
  while ((tok = strtok(buf, " "))) {
    buf = NULL;
    if (strcmp(tok, plugin) == 0)
      goto out;
  }
  die("Plugin '%s' does not exist", plugin);
out:
  fprintf(stderr, "  plugin '%s'\n", plugin);
  free(buf);
}


x86 assembly (clang, -O0):
<check_plugin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118b <check_plugin+0x2b>
jmp    1238 <check_plugin+0xd8>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <read_file@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b8 <check_plugin+0x58>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1070 <die@plt>
jmp    11bd <check_plugin+0x5d>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1204 <check_plugin+0xa4>
movq   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ff <check_plugin+0x9f>
jmp    1216 <check_plugin+0xb6>
jmp    11bd <check_plugin+0x5d>
mov    -0x8(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1070 <die@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe1e(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_plugin>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d7 <check_plugin+0x77>
lea    0xe81(%rip),%rdi
xor    %esi,%esi
call   1060 <read_file@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11a0 <check_plugin+0x40>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1070 <die@plt>
lea    0xe84(%rip),%r12
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11e3 <check_plugin+0x83>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    $0x0,%ebx
test   %rax,%rax
jne    11b0 <check_plugin+0x50>
jmp    11f7 <check_plugin+0x97>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe43(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <die@plt>
mov    %rbx,%r15
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"nop\00"
@.str.1 = [18 x i8] c"available_tracers\00"
@.str.2 = [21 x i8] c"No plugins available\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [27 x i8] c"Plugin '%s' does not exist\00"
@stderr = global i32 0
@.str.5 = [15 x i8] c" plugin '%s'\0A\00"
define void @check_plugin(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
br label %36
9: ; preds = %1
%10 = call i8* @read_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* null)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
br label %16
16: ; preds = %26, %15
%17 = load i8*, i8** %3
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %18, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %27
20: ; preds = %16
store i8* null, i8** %3
%21 = load i8*, i8** %4
%22 = load i8*, i8** %2
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %30
26: ; preds = %20
br label %16
27: ; preds = %16
%28 = load i8*, i8** %2
%29 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %25
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %2
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %3
%35 = call i32 @free(i8* %34)
br label %36
36: ; preds = %30, %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"nop\00"
@.str.1 = [18 x i8] c"available_tracers\00"
@.str.2 = [21 x i8] c"No plugins available\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [27 x i8] c"Plugin '%s' does not exist\00"
@stderr = global i32 0
@.str.5 = [15 x i8] c" plugin '%s'\0A\00"
define void @check_plugin(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %24, label %4
4: ; preds = %1
%5 = tail call i8* @read_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* null)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
br label %10
10: ; preds = %9, %14
%11 = phi i8* [ null, %14 ], [ %5, %9 ]
%12 = tail call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = tail call i64 @strcmp(i8* %12, i8* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %10
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %14, %17
%20 = phi i8* [ %11, %17 ], [ null, %14 ]
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%23 = tail call i32 @free(i8* %20)
br label %24
24: ; preds = %1, %19
ret void
}