#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*/ F_OK;
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *localpath_to_serverpath(char *, int);
int mkdir(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int USB_mkdir(char *localpath, int index) {
  ;
  if (access(localpath, F_OK) != 0) {
    printf("Local has no %s\n", localpath);
    return 902;
  }
  char *serverpath = localpath_to_serverpath(localpath, index);
  ;
  int res = mkdir(serverpath, S_IRWXU | S_IRWXG | S_IRWXO);
  ;
  free(serverpath);
  ;
  return res;
}


x86 assembly (clang, -O0):
<USB_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     1197 <USB_mkdir+0x47>
mov    -0x10(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x386,-0x4(%rbp)
jmp    11dd <USB_mkdir+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <localpath_to_serverpath@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    0x2e1d(%rip),%rax
or     (%rax),%esi
mov    0x2e2c(%rip),%rax
or     (%rax),%esi
call   1040 <mkdir@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USB_mkdir>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
test   %rax,%rax
je     1181 <USB_mkdir+0x31>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x386,%eax
jmp    11bd <USB_mkdir+0x6d>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <localpath_to_serverpath@plt>
mov    0x2e4e(%rip),%rcx
mov    0x2e3f(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %rax,%rbx
mov    0x2e49(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [17 x i8] c"Local has no %s\0A\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
define i32 @USB_mkdir(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = load i32, i32* @F_OK
%10 = call i64 @access(i8* %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 902, i32* %3
br label %29
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = call i8* @localpath_to_serverpath(i8* %16, i32 %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = load i32, i32* @S_IRWXU
%21 = load i32, i32* @S_IRWXG
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRWXO
%24 = or i32 %22, %23
%25 = call i32 @mkdir(i8* %19, i32 %24)
store i32 %25, i32* %7
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %7
store i32 %28, i32* %3
br label %29
29: ; preds = %15, %12
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str = [17 x i8] c"Local has no %s\0A\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
define i32 @USB_mkdir(i8* %0, i32 %1) {
%3 = load i32, i32* @F_OK
%4 = tail call i64 @access(i8* %0, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %17
8: ; preds = %2
%9 = tail call i8* @localpath_to_serverpath(i8* %0, i32 %1)
%10 = load i32, i32* @S_IRWXU
%11 = load i32, i32* @S_IRWXG
%12 = or i32 %11, %10
%13 = load i32, i32* @S_IRWXO
%14 = or i32 %12, %13
%15 = tail call i32 @mkdir(i8* %9, i32 %14)
%16 = tail call i32 @free(i8* %9)
br label %17
17: ; preds = %8, %6
%18 = phi i32 [ 902, %6 ], [ %15, %8 ]
ret i32 %18
}