#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 EEXIST;
int /*<<< orphan*/ exit(int);
int mkdir(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ substr(char *, char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ unlink(char *);
void make_dir_(char *filename, int *len_file) {
  int status, errno;
  char file[*len_file];
  substr(file, filename, 0, *len_file);
  status = mkdir(file, 0777);
  if ((status == -1) && (errno != EEXIST)) {
    perror("mkdir Error");
    unlink(file);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<make_dir_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
xor    %edx,%edx
call   1050 <substr@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11e6 <make_dir_+0x96>
mov    -0x18(%rbp),%eax
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%eax
je     11e6 <make_dir_+0x96>
lea    0xe32(%rip),%rdi
call   1060 <perror@plt>
mov    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_dir_>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%rax
mov    (%rsi),%ecx
mov    %rsp,%rbx
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
sub    %rdx,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1040 <substr@plt>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EEXIST = global i32 0
@.str = [12 x i8] c"mkdir Error\00"
define void @make_dir_(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %3
store i32* %1, i32** %4
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i8, i64 %11
store i64 %11, i64* %8
%14 = load i8*, i8** %3
%15 = load i32*, i32** %4
%16 = load i32, i32* %15
%17 = call i32 @substr(i8* %13, i8* %14, i32 0, i32 %16)
%18 = call i32 @mkdir(i8* %13, i32 511)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = load i32, i32* %6
%23 = load i32, i32* @EEXIST
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @unlink(i8* %13)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %21, %2
%30 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@EEXIST = global i32 0
define void @make_dir_(i8* %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @substr(i8* %5, i8* %0, i32 0, i32 %3)
%7 = call i32 @mkdir(i8* %5, i32 511)
ret void
}