#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_mkdir(short, char *, int);
int /*<<< orphan*/ relpath_to_abspath(char const *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int u_mkdir(const char *path, int mode) {
  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_mkdir(device, localpath, mode);
  case 2:
    return -1;
  case 3:
    return -1;
  case 0:
    return -1;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<u_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1177 <u_mkdir+0x37>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <relpath_to_abspath@plt>
jmp    118c <u_mkdir+0x4c>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rdi
lea    -0x222(%rbp),%rsi
lea    -0x224(%rbp),%rdx
lea    -0x120(%rbp),%rcx
call   1050 <get_dev_and_path@plt>
movswl -0x224(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x230(%rbp)
sub    $0x3,%eax
ja     1222 <u_mkdir+0xe2>
mov    -0x230(%rbp),%rax
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x222(%rbp),%ax
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
movswl %ax,%edi
call   1060 <mx_mkdir@plt>
mov    %eax,-0x4(%rbp)
jmp    1229 <u_mkdir+0xe9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <u_mkdir+0xe9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <u_mkdir+0xe9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <u_mkdir+0xe9>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u_mkdir>:
push   %rbx
sub    $0x210,%rsp
mov    %esi,%ebx
mov    %rdi,%rax
cmpb   $0x2f,(%rdi)
jne    1166 <u_mkdir+0x26>
lea    0x10(%rsp),%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
jmp    1173 <u_mkdir+0x33>
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   1050 <get_dev_and_path@plt>
mov    $0xffffffff,%eax
cmpw   $0x1,0xc(%rsp)
jne    11b0 <u_mkdir+0x70>
movswl 0xe(%rsp),%edi
lea    0x110(%rsp),%rsi
mov    %ebx,%edx
call   1060 <mx_mkdir@plt>
add    $0x210,%rsp
pop    %rbx
ret

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

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