#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*/ free(char *);
int /*<<< orphan*/ rmdir(char *);
scalar_t__ strcasecmp(char *, char *);
char *strdup(char *);
int strlen(char *);
char *strrchr(char *, char);
void create_subdir_cleanup(char *root_dir, char *path) {
  char *root_dir_int, *slash;
  root_dir_int = strdup(root_dir);
  if (root_dir_int[strlen(root_dir_int) - 1] == '/')
    root_dir_int[strlen(root_dir_int) - 1] = '\0';
  if (!strcasecmp(root_dir_int, path))
    return;
  do {
    rmdir(path);
    slash = strrchr(path, '/');
    if (slash)
      *slash = '\0';
  } while (strcasecmp(root_dir_int, path));
  free(root_dir_int);
}


x86 assembly (clang, -O0):
<create_subdir_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11c8 <create_subdir_cleanup+0x68>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11e4 <create_subdir_cleanup+0x84>
jmp    123b <create_subdir_cleanup+0xdb>
jmp    11e9 <create_subdir_cleanup+0x89>
mov    -0x10(%rbp),%rdi
call   1050 <rmdir@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1216 <create_subdir_cleanup+0xb6>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    121b <create_subdir_cleanup+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11e9 <create_subdir_cleanup+0x89>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_subdir_cleanup>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1080 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r14,1)
jne    1191 <create_subdir_cleanup+0x31>
mov    %r14,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    11c0 <create_subdir_cleanup+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     11df <create_subdir_cleanup+0x7f>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     11b0 <create_subdir_cleanup+0x50>
movb   $0x0,(%rax)
jmp    11b0 <create_subdir_cleanup+0x50>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @create_subdir_cleanup(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 = load i8*, i8** %3
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %25
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %18, %2
%26 = load i8*, i8** %5
%27 = load i8*, i8** %4
%28 = call i64 @strcasecmp(i8* %26, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %25
br label %50
31: ; preds = %25
br label %32
32: ; preds = %42, %31
%33 = load i8*, i8** %4
%34 = call i32 @rmdir(i8* %33)
%35 = load i8*, i8** %4
%36 = call i8* @strrchr(i8* %35, i8 signext 47)
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = load i8*, i8** %6
store i8 0, i8* %40
br label %41
41: ; preds = %39, %32
br label %42
42: ; preds = %41
%43 = load i8*, i8** %5
%44 = load i8*, i8** %4
%45 = call i64 @strcasecmp(i8* %43, i8* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %32, label %47
47: ; preds = %42
%48 = load i8*, i8** %5
%49 = call i32 @free(i8* %48)
br label %50
50: ; preds = %47, %30
ret void
}

LLVM IR (-O2):
define void @create_subdir_cleanup(i8* nocapture %0, i8* %1) {
%3 = tail call i8* @strdup(i8* %0)
%4 = tail call i32 @strlen(i8* %3)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %3, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 47
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = tail call i32 @strlen(i8* %3)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %3, i64 %13
store i8 0, i8* %14
br label %15
15: ; preds = %10, %2
%16 = tail call i64 @strcasecmp(i8* %3, i8* %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %15, %23
%19 = tail call i32 @rmdir(i8* %1)
%20 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 47)
%21 = icmp eq i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %18
store i8 0, i8* %20
br label %23
23: ; preds = %18, %22
%24 = tail call i64 @strcasecmp(i8* %3, i8* %1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %18
26: ; preds = %23
%27 = tail call i32 @free(i8* %3)
br label %28
28: ; preds = %15, %26
ret void
}