#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 */

/* Variables and functions */
int /*<<< orphan*/ MS_BIND;
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char *);
scalar_t__ mount(char *, char *, int /*<<< orphan*/ *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int open(char *, int, int);
void bindnode(char *src, char *dst) {
  int fd;
  if ((fd = open(dst, O_WRONLY | O_CREAT, 0600)) >= 0)
    close(fd);
  if (mount(src, dst, NULL, MS_BIND, NULL) < 0)
    error(1, 0, "Failed to bind %s into new /dev filesystem", src);
}


x86 assembly (clang, -O0):
<bindnode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    0x2e94(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     1184 <bindnode+0x44>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e4d(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
call   1030 <mount@plt>
cmp    $0x0,%rax
jge    11c3 <bindnode+0x83>
mov    -0x8(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe42(%rip),%rdx
call   1050 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bindnode>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e77(%rip),%rax
mov    0x2ea0(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x180,%edx
call   1060 <open@plt>
test   %eax,%eax
js     1174 <bindnode+0x34>
mov    %eax,%edi
call   1040 <close@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %r8d,%r8d
call   1030 <mount@plt>
test   %rax,%rax
js     119a <bindnode+0x5a>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe5f(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <error@plt>

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@MS_BIND = global i32 0
@.str = [43 x i8] c"Failed to bind %s into new /dev filesystem\00"
define void @bindnode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = call i32 @open(i8* %6, i32 %9, i32 384)
store i32 %10, i32* %5
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* %5
%14 = call i32 @close(i32 %13)
br label %15
15: ; preds = %12, %2
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = load i32, i32* @MS_BIND
%19 = call i64 @mount(i8* %16, i8* %17, i32* null, i32 %18, i32* null)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %15
ret void
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@MS_BIND = global i32 0
@.str = [43 x i8] c"Failed to bind %s into new /dev filesystem\00"
define void @bindnode(i8* %0, i8* %1) {
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* %1, i32 %5, i32 384)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @close(i32 %6)
br label %10
10: ; preds = %8, %2
%11 = load i32, i32* @MS_BIND
%12 = tail call i64 @mount(i8* %0, i8* %1, i32* null, i32 %11, i32* null)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
16: ; preds = %14, %10
ret void
}