#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 dummy;
};

/* Variables and functions */
#define ENODEV 130
#define ENOENT 129
#define ENXIO 128
int _mount_error(char const *, int);
int errno;
scalar_t__ mount(char const *, char const *, char const *, int, char const *);
int /*<<< orphan*/ stat(char const *, struct stat *);
int _mount_do_mount(char const *type, int flags, char const *special,
                    char const *node, void *data, size_t datalen) {
  struct stat st;
  struct {
    char const *fspec;
  } *d = data;
  if (mount(special, node, type, flags, d->fspec) == 0)
    return 0;
  switch (errno) {
  case ENOENT:
    if (stat(node, &st) == 0)
      return -_mount_error(special, 1);
    return -_mount_error(node, 1);
  case ENODEV:
  case ENXIO:
    return -_mount_error(special, 1);
  default:
    return -_mount_error(node, 1);
  }
}


x86 assembly (clang, -O0):
<_mount_do_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    (%rax),%r8
call   1030 <mount@plt>
cmp    $0x0,%rax
jne    1188 <_mount_do_mount+0x58>
movl   $0x0,-0x4(%rbp)
jmp    124b <_mount_do_mount+0x11b>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x80,%eax
je     1218 <_mount_do_mount+0xe8>
jmp    11a4 <_mount_do_mount+0x74>
mov    -0x4c(%rbp),%eax
sub    $0x81,%eax
je     11ca <_mount_do_mount+0x9a>
jmp    11b7 <_mount_do_mount+0x87>
mov    -0x4c(%rbp),%eax
sub    $0x82,%eax
je     1218 <_mount_do_mount+0xe8>
jmp    1234 <_mount_do_mount+0x104>
mov    -0x28(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%eax
jne    11fc <_mount_do_mount+0xcc>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1050 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    124b <_mount_do_mount+0x11b>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1050 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    124b <_mount_do_mount+0x11b>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1050 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    124b <_mount_do_mount+0x11b>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1050 <_mount_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mount_do_mount>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %esi,%ecx
mov    %rdi,%rdx
mov    (%r8),%r8
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mount@plt>
test   %rax,%rax
je     1183 <_mount_do_mount+0x53>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
cmp    $0x80,%eax
je     1187 <_mount_do_mount+0x57>
cmp    $0x82,%eax
je     1187 <_mount_do_mount+0x57>
cmp    $0x81,%eax
jne    118a <_mount_do_mount+0x5a>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
test   %eax,%eax
cmove  %r14,%rbx
jmp    118a <_mount_do_mount+0x5a>
xor    %eax,%eax
jmp    1199 <_mount_do_mount+0x69>
mov    %r14,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <_mount_error@plt>
neg    %eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.anon = type { i8* }
@errno = global i32 0
define i32 @_mount_do_mount(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i64 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca %struct.stat
%15 = alloca %struct.anon*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i64 %5, i64* %13
%16 = load i8*, i8** %12
%17 = bitcast i8* %16 to %struct.anon*
store %struct.anon* %17, %struct.anon** %15
%18 = load i8*, i8** %10
%19 = load i8*, i8** %11
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = load %struct.anon*, %struct.anon** %15
%23 = getelementptr inbounds %struct.anon, %struct.anon* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i64 @mount(i8* %18, i8* %19, i8* %20, i32 %21, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %6
store i32 0, i32* %7
br label %50
28: ; preds = %6
%29 = load i32, i32* @errno
switch i32 %29, label %46 [
i32 129, label %30
i32 130, label %42
i32 128, label %42
]
30: ; preds = %28
%31 = load i8*, i8** %11
%32 = call i32 @stat(i8* %31, %struct.stat* %14)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i8*, i8** %10
%36 = call i32 @_mount_error(i8* %35, i32 1)
%37 = sub nsw i32 0, %36
store i32 %37, i32* %7
br label %50
38: ; preds = %30
%39 = load i8*, i8** %11
%40 = call i32 @_mount_error(i8* %39, i32 1)
%41 = sub nsw i32 0, %40
store i32 %41, i32* %7
br label %50
42: ; preds = %28, %28
%43 = load i8*, i8** %10
%44 = call i32 @_mount_error(i8* %43, i32 1)
%45 = sub nsw i32 0, %44
store i32 %45, i32* %7
br label %50
46: ; preds = %28
%47 = load i8*, i8** %11
%48 = call i32 @_mount_error(i8* %47, i32 1)
%49 = sub nsw i32 0, %48
store i32 %49, i32* %7
br label %50
50: ; preds = %46, %42, %38, %34, %27
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@errno = global i32 0
define i32 @_mount_do_mount(i8* %0, i32 %1, i8* %2, i8* %3, i8* nocapture %4, i64 %5) {
%7 = alloca %struct.stat
%8 = bitcast %struct.stat* %7 to i8*
%9 = bitcast i8* %4 to i8**
%10 = load i8*, i8** %9
%11 = tail call i64 @mount(i8* %2, i8* %3, i8* %0, i32 %1, i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %6
%14 = load i32, i32* @errno
switch i32 %14, label %19 [
i32 129, label %15
i32 130, label %20
i32 128, label %20
]
15: ; preds = %13
%16 = call i32 @stat(i8* %3, %struct.stat* %7)
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* %2, i8* %3
br label %20
19: ; preds = %13
br label %20
20: ; preds = %13, %13, %15, %19
%21 = phi i8* [ %3, %19 ], [ %18, %15 ], [ %2, %13 ], [ %2, %13 ]
%22 = tail call i32 @_mount_error(i8* %21, i32 1)
%23 = sub nsw i32 0, %22
br label %24
24: ; preds = %20, %6
%25 = phi i32 [ 0, %6 ], [ %23, %20 ]
ret i32 %25
}