#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISLNK(int /*<<< orphan*/);
char *_PATH_MOUNTED;
int lstat(char *, struct stat *);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char *, size_t);
int mtab_needs_update(const char *mnt) {
  struct stat stbuf;
  if (strncmp(mnt, _PATH_MOUNTED, strlen(mnt)) == 0 &&
      _PATH_MOUNTED[strlen(mnt)] == '/')
    return 0;
  if (lstat(_PATH_MOUNTED, &stbuf) != -1 && S_ISLNK(stbuf.st_mode))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<mtab_needs_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11bc <mtab_needs_update+0x7c>
mov    0x2e5c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11bc <mtab_needs_update+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11fd <mtab_needs_update+0xbd>
mov    0x2e25(%rip),%rax
mov    (%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0xffffffff,%eax
je     11f6 <mtab_needs_update+0xb6>
mov    -0x18(%rbp),%edi
call   1040 <S_ISLNK@plt>
cmp    $0x0,%rax
je     11f6 <mtab_needs_update+0xb6>
movl   $0x0,-0x4(%rbp)
jmp    11fd <mtab_needs_update+0xbd>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtab_needs_update>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e95(%rip),%r15
mov    (%r15),%r14
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
mov    (%r15),%r14
test   %rax,%rax
jne    1185 <mtab_needs_update+0x45>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmpb   $0x2f,(%r14,%rcx,1)
je     11af <mtab_needs_update+0x6f>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1060 <lstat@plt>
cmp    $0xffffffff,%eax
je     11aa <mtab_needs_update+0x6a>
mov    0x8(%rsp),%edi
call   1040 <S_ISLNK@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11af <mtab_needs_update+0x6f>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@_PATH_MOUNTED = global i8* null
define i32 @mtab_needs_update(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = load i8*, i8** @_PATH_MOUNTED
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = call i64 @strncmp(i8* %5, i8* %6, i64 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %1
%12 = load i8*, i8** @_PATH_MOUNTED
%13 = load i8*, i8** %3
%14 = call i64 @strlen(i8* %13)
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %19, label %20
19: ; preds = %11
store i32 0, i32* %2
br label %31
20: ; preds = %11, %1
%21 = load i8*, i8** @_PATH_MOUNTED
%22 = call i32 @lstat(i8* %21, %struct.stat* %4)
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i64 @S_ISLNK(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %2
br label %31
30: ; preds = %24, %20
store i32 1, i32* %2
br label %31
31: ; preds = %30, %29, %19
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@_PATH_MOUNTED = global i8* null
define i32 @mtab_needs_update(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = load i8*, i8** @_PATH_MOUNTED
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strncmp(i8* %0, i8* %4, i64 %5)
%7 = icmp eq i64 %6, 0
%8 = load i8*, i8** @_PATH_MOUNTED
br i1 %7, label %9, label %14
9: ; preds = %1
%10 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %23, label %14
14: ; preds = %1, %9
%15 = call i32 @lstat(i8* %8, %struct.stat* %2)
%16 = icmp eq i32 %15, -1
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%19 = load i32, i32* %18
%20 = tail call i64 @S_ISLNK(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17, %14
br label %23
23: ; preds = %17, %9, %22
%24 = phi i32 [ 1, %22 ], [ 0, %9 ], [ 0, %17 ]
ret i32 %24
}