#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 S_IROTH;
int S_IRWXG;
int S_IRWXU;
int S_IXOTH;
char *getenv(char *);
char *malloc(int);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int mkdir_one(char *path, char *dir) {
  char *tmp_path;
  char *homedir;
  homedir = malloc(512 * sizeof(char));
  tmp_path = malloc(512 * sizeof(char));
  strcpy(tmp_path, path);
  sprintf(homedir, "%s", getenv("HOME"));
  strcat(homedir, "/.local/share/secapp/");
  strcpy(tmp_path, strcat(homedir, tmp_path));
  mkdir(tmp_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  strcat(tmp_path, dir);
  mkdir(tmp_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  return 0;
}


x86 assembly (clang, -O0):
<mkdir_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe5b(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rdx
lea    0xe45(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
mov    0x2dd3(%rip),%rax
or     (%rax),%esi
mov    0x2dba(%rip),%rax
or     (%rax),%esi
mov    0x2dc9(%rip),%rax
or     (%rax),%esi
call   1050 <mkdir@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
mov    0x2d99(%rip),%rax
or     (%rax),%esi
mov    0x2d80(%rip),%rax
or     (%rax),%esi
mov    0x2d8f(%rip),%rax
or     (%rax),%esi
call   1050 <mkdir@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkdir_one>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x200,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x200,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xe63(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
movabs $0x2f707061636573,%rcx
mov    %rcx,0xe(%rbx,%rax,1)
movups 0xe3a(%rip),%xmm0
movups %xmm0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    0x2dfc(%rip),%r12
mov    0x2de5(%rip),%rbx
mov    (%rbx),%esi
or     (%r12),%esi
mov    0x2dc8(%rip),%r13
or     0x0(%r13),%esi
mov    0x2dd5(%rip),%rbp
or     0x0(%rbp),%esi
mov    %r15,%rdi
call   1050 <mkdir@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    (%rbx),%esi
or     (%r12),%esi
or     0x0(%r13),%esi
or     0x0(%rbp),%esi
mov    %r15,%rdi
call   1050 <mkdir@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [22 x i8] c"/.local/share/secapp/\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define i32 @mkdir_one(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i8* @malloc(i32 512)
store i8* %7, i8** %6
%8 = call i8* @malloc(i32 512)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %6
%13 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %6
%16 = call i8* @strcat(i8* %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%17 = load i8*, i8** %5
%18 = load i8*, i8** %6
%19 = load i8*, i8** %5
%20 = call i8* @strcat(i8* %18, i8* %19)
%21 = call i32 @strcpy(i8* %17, i8* %20)
%22 = load i8*, i8** %5
%23 = load i32, i32* @S_IRWXU
%24 = load i32, i32* @S_IRWXG
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IROTH
%27 = or i32 %25, %26
%28 = load i32, i32* @S_IXOTH
%29 = or i32 %27, %28
%30 = call i32 @mkdir(i8* %22, i32 %29)
%31 = load i8*, i8** %5
%32 = load i8*, i8** %4
%33 = call i8* @strcat(i8* %31, i8* %32)
%34 = load i8*, i8** %5
%35 = load i32, i32* @S_IRWXU
%36 = load i32, i32* @S_IRWXG
%37 = or i32 %35, %36
%38 = load i32, i32* @S_IROTH
%39 = or i32 %37, %38
%40 = load i32, i32* @S_IXOTH
%41 = or i32 %39, %40
%42 = call i32 @mkdir(i8* %34, i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [22 x i8] c"/.local/share/secapp/\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define i32 @mkdir_one(i8* %0, i8* nocapture %1) {
%3 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%4 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %3, i8* %6)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%9 = getelementptr i8, i8* %3, i64 %8
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %9, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 22, i1 false)
%10 = tail call i8* @strcat(i8* dereferenceable(1) %3, i8* dereferenceable(1) %4)
%11 = tail call i32 @strcpy(i8* %4, i8* %3)
%12 = load i32, i32* @S_IRWXU
%13 = load i32, i32* @S_IRWXG
%14 = or i32 %13, %12
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IXOTH
%18 = or i32 %16, %17
%19 = tail call i32 @mkdir(i8* %4, i32 %18)
%20 = tail call i8* @strcat(i8* dereferenceable(1) %4, i8* dereferenceable(1) %1)
%21 = load i32, i32* @S_IRWXU
%22 = load i32, i32* @S_IRWXG
%23 = or i32 %22, %21
%24 = load i32, i32* @S_IROTH
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IXOTH
%27 = or i32 %25, %26
%28 = tail call i32 @mkdir(i8* %4, i32 %27)
ret i32 0
}