#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 */
scalar_t__ EEXIST;
scalar_t__ ENOENT;
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int mkdir(char *, int /*<<< orphan*/);
int test_vfs_dot_dir(void) {
  assert(mkdir("/tmp"
               "/test/.",
               0) == -1 &&
         errno == ENOENT);
  assert(mkdir("/.", 0) == -1 && errno == EEXIST);
  assert(mkdir("/tmp"
               "/.",
               0) == -1 &&
         errno == EEXIST);
  return 0;
}


x86 assembly (clang, -O0):
<test_vfs_dot_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x1(%rbp)
jne    1160 <test_vfs_dot_dir+0x40>
mov    0x2e8b(%rip),%rax
mov    (%rax),%rax
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe9c(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x2(%rbp)
jne    11a5 <test_vfs_dot_dir+0x85>
mov    0x2e46(%rip),%rax
mov    (%rax),%rax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe53(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x3(%rbp)
jne    11ea <test_vfs_dot_dir+0xca>
mov    0x2e01(%rip),%rax
mov    (%rax),%rax
mov    0x2dff(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x3(%rbp)
mov    -0x3(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_vfs_dot_dir>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    0x2e99(%rip),%r14
mov    (%r14),%rcx
mov    0x2e7f(%rip),%rdx
cmp    (%rdx),%rcx
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xeb0(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    (%r14),%rcx
mov    0x2e69(%rip),%rbx
cmp    (%rbx),%rcx
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
lea    0xe7e(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    (%r14),%rcx
cmp    (%rbx),%rcx
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"/tmp/test/.\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [3 x i8] c"/.\00"
@EEXIST = global i64 0
@.str.2 = [7 x i8] c"/tmp/.\00"
define i32 @test_vfs_dot_dir() {
%1 = call i32 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = load i64, i64* @errno
%5 = load i64, i64* @ENOENT
%6 = icmp eq i64 %4, %5
br label %7
7: ; preds = %3, %0
%8 = phi i1 [ false, %0 ], [ %6, %3 ]
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @mkdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i64, i64* @errno
%15 = load i64, i64* @EEXIST
%16 = icmp eq i64 %14, %15
br label %17
17: ; preds = %13, %7
%18 = phi i1 [ false, %7 ], [ %16, %13 ]
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i64, i64* @errno
%25 = load i64, i64* @EEXIST
%26 = icmp eq i64 %24, %25
br label %27
27: ; preds = %23, %17
%28 = phi i1 [ false, %17 ], [ %26, %23 ]
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"/tmp/test/.\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [3 x i8] c"/.\00"
@EEXIST = global i64 0
@.str.2 = [7 x i8] c"/tmp/.\00"
define i32 @test_vfs_dot_dir() {
%1 = tail call i32 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq i32 %1, -1
%3 = load i64, i64* @errno
%4 = load i64, i64* @ENOENT
%5 = icmp eq i64 %3, %4
%6 = select i1 %2, i1 %5, i1 false
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @mkdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0)
%10 = icmp eq i32 %9, -1
%11 = load i64, i64* @errno
%12 = load i64, i64* @EEXIST
%13 = icmp eq i64 %11, %12
%14 = select i1 %10, i1 %13, i1 false
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%18 = icmp eq i32 %17, -1
%19 = load i64, i64* @errno
%20 = load i64, i64* @EEXIST
%21 = icmp eq i64 %19, %20
%22 = select i1 %18, i1 %21, i1 false
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
ret i32 0
}