#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
scalar_t__ isspace(char);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, char *, int);
char *tracecmd_get_tracing_file(char *);
int /*<<< orphan*/ tracecmd_put_tracing_file(char *);
int functions_filtered(void) {
  char buf[1] = {'#'};
  char *path;
  int fd;
  path = tracecmd_get_tracing_file("set_ftrace_filter");
  fd = open(path, O_RDONLY);
  tracecmd_put_tracing_file(path);
  if (fd < 0)
    return 0;
  read(fd, buf, 1);
  close(fd);
  if (buf[0] == '#' || isspace(buf[0]))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<functions_filtered>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xe92(%rip),%al
mov    %al,-0x5(%rbp)
lea    0xe89(%rip),%rdi
call   1070 <tracecmd_get_tracing_file@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <tracecmd_put_tracing_file@plt>
cmpl   $0x0,-0x14(%rbp)
jge    11b5 <functions_filtered+0x55>
movl   $0x0,-0x4(%rbp)
jmp    1201 <functions_filtered+0xa1>
mov    -0x14(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x23,%eax
je     11ee <functions_filtered+0x8e>
movsbl -0x5(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11fa <functions_filtered+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    1201 <functions_filtered+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<functions_filtered>:
push   %rbp
push   %rbx
push   %rax
movb   $0x23,0x7(%rsp)
lea    0xe91(%rip),%rdi
call   1070 <tracecmd_get_tracing_file@plt>
mov    %rax,%rbx
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <tracecmd_put_tracing_file@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
js     11c8 <functions_filtered+0x68>
lea    0x7(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x7(%rsp),%al
cmp    $0x23,%al
je     11c8 <functions_filtered+0x68>
movsbl %al,%edi
call   1050 <isspace@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.functions_filtered.buf = [1 x i8] c"#"
@.str = [18 x i8] c"set_ftrace_filter\00"
@O_RDONLY = global i32 0
define i32 @functions_filtered() {
%1 = alloca i32
%2 = alloca [1 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = bitcast [1 x i8]* %2 to i8*
%6 = call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = load i32, i32* @O_RDONLY
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %4
%10 = load i8*, i8** %3
%11 = call i32 @tracecmd_put_tracing_file(i8* %10)
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %0
store i32 0, i32* %1
br label %32
15: ; preds = %0
%16 = load i32, i32* %4
%17 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%18 = call i32 @read(i32 %16, i8* %17, i32 1)
%19 = load i32, i32* %4
%20 = call i32 @close(i32 %19)
%21 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 35
br i1 %24, label %30, label %25
25: ; preds = %15
%26 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%27 = load i8, i8* %26
%28 = call i64 @isspace(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25, %15
store i32 0, i32* %1
br label %32
31: ; preds = %25
store i32 1, i32* %1
br label %32
32: ; preds = %31, %30, %14
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [18 x i8] c"set_ftrace_filter\00"
@O_RDONLY = global i32 0
define i32 @functions_filtered() {
%1 = alloca [1 x i8]
%2 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
store i8 35, i8* %2
%3 = tail call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* %3, i32 %4)
%6 = tail call i32 @tracecmd_put_tracing_file(i8* %3)
%7 = icmp slt i32 %5, 0
br i1 %7, label %17, label %8
8: ; preds = %0
%9 = call i32 @read(i32 %5, i8* %2, i32 1)
%10 = tail call i32 @close(i32 %5)
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 35
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call i64 @isspace(i8 signext %11)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %8, %0
%18 = phi i32 [ 0, %0 ], [ 0, %8 ], [ %16, %13 ]
ret i32 %18
}