#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*/ get_dev_and_path(char *, short *, short *, char *);
int mx_rmdir(short, char *, char *);
int /*<<< orphan*/ relpath_to_abspath(char const *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int u_rmdir(const char *path) {
  char localpath[256], abspath[256];
  short device, fs;
  if (*path != '/')
    relpath_to_abspath(path, abspath);
  else
    strncpy(abspath, path, 256);
  get_dev_and_path(abspath, &device, &fs, (char *)&localpath);
  switch (fs) {
  case 1:
    return mx_rmdir(device, abspath, localpath);
  case 2:
    return -1;
  case 3:
    return -1;
  case 0:
    return -1;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<u_rmdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1174 <u_rmdir+0x34>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1040 <relpath_to_abspath@plt>
jmp    1189 <u_rmdir+0x49>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    -0x210(%rbp),%rdi
lea    -0x212(%rbp),%rsi
lea    -0x214(%rbp),%rdx
lea    -0x110(%rbp),%rcx
call   1060 <get_dev_and_path@plt>
movswl -0x214(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x220(%rbp)
sub    $0x3,%eax
ja     1223 <u_rmdir+0xe3>
mov    -0x220(%rbp),%rax
lea    0xe2f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x212(%rbp),%ax
lea    -0x210(%rbp),%rsi
lea    -0x110(%rbp),%rdx
movswl %ax,%edi
call   1050 <mx_rmdir@plt>
mov    %eax,-0x4(%rbp)
jmp    122a <u_rmdir+0xea>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <u_rmdir+0xea>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <u_rmdir+0xea>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <u_rmdir+0xea>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u_rmdir>:
sub    $0x218,%rsp
mov    %rdi,%rax
cmpb   $0x2f,(%rdi)
jne    1163 <u_rmdir+0x23>
lea    0x10(%rsp),%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
jmp    1170 <u_rmdir+0x30>
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1040 <relpath_to_abspath@plt>
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x110(%rsp),%rcx
call   1060 <get_dev_and_path@plt>
mov    $0xffffffff,%eax
cmpw   $0x1,0xc(%rsp)
jne    11b0 <u_rmdir+0x70>
movswl 0xe(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x110(%rsp),%rdx
call   1050 <mx_rmdir@plt>
add    $0x218,%rsp
ret

LLVM IR (-O0):
define i32 @u_rmdir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca i16
%7 = alloca i16
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 47
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @relpath_to_abspath(i8* %13, i8* %14)
br label %20
16: ; preds = %1
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = call i32 @strncpy(i8* %17, i8* %18, i32 256)
br label %20
20: ; preds = %16, %12
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%22 = bitcast [256 x i8]* %4 to i8*
%23 = call i32 @get_dev_and_path(i8* %21, i16* %6, i16* %7, i8* %22)
%24 = load i16, i16* %7
%25 = sext i16 %24 to i32
switch i32 %25, label %34 [
i32 1, label %26
i32 2, label %31
i32 3, label %32
i32 0, label %33
]
26: ; preds = %20
%27 = load i16, i16* %6
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%30 = call i32 @mx_rmdir(i16 signext %27, i8* %28, i8* %29)
store i32 %30, i32* %2
br label %35
31: ; preds = %20
store i32 -1, i32* %2
br label %35
32: ; preds = %20
store i32 -1, i32* %2
br label %35
33: ; preds = %20
store i32 -1, i32* %2
br label %35
34: ; preds = %20
store i32 -1, i32* %2
br label %35
35: ; preds = %34, %33, %32, %31, %26
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @u_rmdir(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i16
%5 = alloca i16
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = bitcast i16* %4 to i8*
%9 = bitcast i16* %5 to i8*
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 47
br i1 %11, label %14, label %12
12: ; preds = %1
%13 = call i32 @relpath_to_abspath(i8* %0, i8* %7)
br label %16
14: ; preds = %1
%15 = call i32 @strncpy(i8* %7, i8* %0, i32 256)
br label %16
16: ; preds = %14, %12
%17 = call i32 @get_dev_and_path(i8* %7, i16* %4, i16* %5, i8* %6)
%18 = load i16, i16* %5
%19 = icmp eq i16 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i16, i16* %4
%22 = call i32 @mx_rmdir(i16 signext %21, i8* %7, i8* %6)
br label %23
23: ; preds = %16, %20
%24 = phi i32 [ %22, %20 ], [ -1, %16 ]
ret i32 %24
}