#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
bool isMounted(char *name) {
  FILE *log = fopen("/dtv/usb/log", "r");
  if (log == NULL)
    return false;
  unsigned int lineL = 100;
  char line[lineL];
  while (fgets(line, lineL, log) != NULL) {
    if (strstr(line, name) != NULL)
      return true;
  }
  fclose(log);
  return false;
}


x86 assembly (clang, -O0):
<isMounted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117a <isMounted+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    120e <isMounted+0xce>
movl   $0x64,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11f0 <isMounted+0xb0>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11eb <isMounted+0xab>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1207 <isMounted+0xc7>
jmp    11a7 <isMounted+0x67>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isMounted>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xeab(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11ac <isMounted+0x6c>
mov    %rax,%r15
mov    %rsp,%r12
mov    %rsp,%rbx
add    $0xffffffffffffff90,%rbx
mov    %rbx,%rsp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11b0 <isMounted+0x70>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1180 <isMounted+0x40>
mov    $0x1,%eax
jmp    11ba <isMounted+0x7a>
xor    %eax,%eax
jmp    11bd <isMounted+0x7d>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
mov    %r12,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dtv/usb/log\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @isMounted(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %3
%9 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %34
13: ; preds = %1
store i32 100, i32* %5
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i8, i64 %15
store i64 %15, i64* %7
br label %18
18: ; preds = %28, %13
%19 = load i32, i32* %5
%20 = load i32*, i32** %4
%21 = call i32* @fgets(i8* %17, i32 %19, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32* @strstr(i8* %17, i8* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %2
store i32 1, i32* %8
br label %32
28: ; preds = %23
br label %18
29: ; preds = %18
%30 = load i32*, i32** %4
%31 = call i32 @fclose(i32* %30)
store i32 0, i32* %2
store i32 1, i32* %8
br label %32
32: ; preds = %29, %27
%33 = load i8*, i8** %6
br label %34
34: ; preds = %32, %12
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dtv/usb/log\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @isMounted(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %18, label %4
4: ; preds = %1
%5 = tail call i8* @llvm.stacksave()
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
br label %8
8: ; preds = %11, %4
%9 = call i32* @fgets(i8* %7, i32 100, i32* %2)
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = call i32* @strstr(i8* %7, i8* dereferenceable(1) %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %8, label %16
14: ; preds = %8
%15 = call i32 @fclose(i32* %2)
br label %16
16: ; preds = %11, %14
%17 = phi i32 [ 0, %14 ], [ 1, %11 ]
br label %18
18: ; preds = %1, %16
%19 = phi i32 [ %17, %16 ], [ 0, %1 ]
ret i32 %19
}