#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 fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int route_wlan1() {
  char buffer[512];
  FILE *read_fp;
  int chars_read;
  int ret = 0;
  memset(buffer, 0, 512);
  read_fp = popen("route | grep wlan1", "r");
  if (read_fp != NULL) {
    chars_read = fread(buffer, sizeof(char), 512 - 1, read_fp);
    if (chars_read > 0) {
      ret = 1;
    } else {
      ret = 0;
    }
    pclose(read_fp);
  }
  return ret;
}


x86 assembly (clang, -O0):
<route_wlan1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x210(%rbp)
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    0xe91(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x208(%rbp)
cmpq   $0x0,-0x208(%rbp)
je     11e5 <route_wlan1+0xa5>
lea    -0x200(%rbp),%rdi
mov    -0x208(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1ff,%edx
call   1030 <fread@plt>
mov    %eax,-0x20c(%rbp)
cmpl   $0x0,-0x20c(%rbp)
jle    11cf <route_wlan1+0x8f>
movl   $0x1,-0x210(%rbp)
jmp    11d9 <route_wlan1+0x99>
movl   $0x0,-0x210(%rbp)
mov    -0x208(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x210(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<route_wlan1>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    0xe9e(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <popen@plt>
test   %rax,%rax
je     119a <route_wlan1+0x5a>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1ff,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
xor    %ebx,%ebx
test   %eax,%eax
setg   %bl
mov    %r14,%rdi
call   1040 <pclose@plt>
mov    %ebx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"route | grep wlan1\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @route_wlan1() {
%1 = alloca [512 x i8]
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %4
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 512)
%7 = call i32* @popen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %21
10: ; preds = %0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32 @fread(i8* %11, i32 1, i32 511, i32* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 1, i32* %4
br label %18
17: ; preds = %10
store i32 0, i32* %4
br label %18
18: ; preds = %17, %16
%19 = load i32*, i32** %2
%20 = call i32 @pclose(i32* %19)
br label %21
21: ; preds = %18, %0
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [19 x i8] c"route | grep wlan1\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @route_wlan1() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 512)
%4 = call i32* @popen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = call i32 @fread(i8* %2, i32 1, i32 511, i32* %4)
%8 = icmp sgt i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @pclose(i32* %4)
br label %11
11: ; preds = %6, %0
%12 = phi i32 [ %9, %6 ], [ 0, %0 ]
ret i32 %12
}