#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
int FRESHPLAYERPLUGIN(void) {
  FILE *DIR = NULL;
  char aux[1000];
  DIR = popen("cd ~ && ls", "r");
  fgets(aux, 1000, DIR);
  while (!feof(DIR)) {
    if (strstr(aux, "freshplayerplugin") != NULL) {
      return 1;
      break;
    }
    fgets(aux, 1000, DIR);
  }
  pclose(DIR);
  return 0;
}


x86 assembly (clang, -O0):
<FRESHPLAYERPLUGIN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xe96(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ad <FRESHPLAYERPLUGIN+0x5d>
jmp    11f0 <FRESHPLAYERPLUGIN+0xa0>
lea    -0x400(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11d6 <FRESHPLAYERPLUGIN+0x86>
movl   $0x1,-0x4(%rbp)
jmp    1200 <FRESHPLAYERPLUGIN+0xb0>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
jmp    118f <FRESHPLAYERPLUGIN+0x3f>
mov    -0x10(%rbp),%rdi
call   1030 <pclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FRESHPLAYERPLUGIN>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
lea    0xe9d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11cc <FRESHPLAYERPLUGIN+0x7c>
lea    0xe78(%rip),%r14
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11d8 <FRESHPLAYERPLUGIN+0x88>
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     11a0 <FRESHPLAYERPLUGIN+0x50>
mov    %rbx,%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
jmp    11dd <FRESHPLAYERPLUGIN+0x8d>
mov    $0x1,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"cd ~ && ls\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"freshplayerplugin\00"
define i32 @FRESHPLAYERPLUGIN() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1000 x i8]
store i32* null, i32** %2
%4 = call i32* @popen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = load i32*, i32** %2
%7 = call i32 @fgets(i8* %5, i32 1000, i32* %6)
br label %8
8: ; preds = %18, %0
%9 = load i32*, i32** %2
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%15 = call i32* @strstr(i8* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %1
br label %25
18: ; preds = %13
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i32 @fgets(i8* %19, i32 1000, i32* %20)
br label %8
22: ; preds = %8
%23 = load i32*, i32** %2
%24 = call i32 @pclose(i32* %23)
store i32 0, i32* %1
br label %25
25: ; preds = %22, %17
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [11 x i8] c"cd ~ && ls\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"freshplayerplugin\00"
define i32 @FRESHPLAYERPLUGIN() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @popen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @fgets(i8* %2, i32 1000, i32* %3)
%5 = call i32 @feof(i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0, %10
%8 = call i32* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = call i32 @fgets(i8* %2, i32 1000, i32* %3)
%12 = call i32 @feof(i32* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %10, %0
%15 = call i32 @pclose(i32* %3)
br label %16
16: ; preds = %7, %14
%17 = phi i32 [ 0, %14 ], [ 1, %7 ]
ret i32 %17
}