#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 */
typedef int /*<<< orphan*/ path;

/* Variables and functions */
int /*<<< orphan*/ FILENAME_MAX;
scalar_t__ rmdir(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *,
                            char const *);
int cgroupDestroyType(const char *cgid, const char *prefix, const char *type) {
  char path[FILENAME_MAX + 1];
  int retries = 5;
  snprintf(path, sizeof(path), "%s/%s/%s", prefix, type, cgid);
  while (rmdir(path) && retries) {
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<cgroupDestroyType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
add    $0x1,%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,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x5,-0x2c(%rbp)
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x8(%rbp),%r9
lea    0xe71(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <rmdir@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
je     11b9 <cgroupDestroyType+0x89>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11c9 <cgroupDestroyType+0x99>
jmp    11d8 <cgroupDestroyType+0xa8>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    1194 <cgroupDestroyType+0x64>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgroupDestroyType>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rdi,%r9
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9d(%rip),%rdx
mov    %rbx,%rdi
call   1040 <snprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <rmdir@plt>
test   %rax,%rax
je     1189 <cgroupDestroyType+0x59>
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    1170 <cgroupDestroyType+0x40>
xor    %eax,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@.str = [9 x i8] c"%s/%s/%s\00"
define i32 @cgroupDestroyType(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i32, i32* @FILENAME_MAX
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
store i32 5, i32* %9
%15 = trunc i64 %12 to i32
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i8*, i8** %4
%19 = call i32 @snprintf(i8* %14, i32 %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18)
br label %20
20: ; preds = %28, %3
%21 = call i64 @rmdir(i8* %14)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br label %26
26: ; preds = %23, %20
%27 = phi i1 [ false, %20 ], [ %25, %23 ]
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 @sleep(i32 1)
br label %20
30: ; preds = %26
%31 = load i8*, i8** %7
ret i32 0
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@.str = [9 x i8] c"%s/%s/%s\00"
define i32 @cgroupDestroyType(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @FILENAME_MAX
%5 = add nsw i32 %4, 1
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32 @snprintf(i8* %7, i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %0)
%9 = call i64 @rmdir(i8* %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %3, %11
%12 = call i32 @sleep(i32 1)
%13 = call i64 @rmdir(i8* %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11, %3
ret i32 0
}