#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 destroydir(char *);
int /*<<< orphan*/ quota_ctl(unsigned int, int);
int quota_off(unsigned int, int);
int vps_destroy_dir(unsigned int veid, char *dir) {
  int ret;
  if (!quota_ctl(veid, 2)) {
    if ((ret = quota_off(veid, 0)))
      if ((ret = quota_off(veid, 1)))
        return ret;
  }
  quota_ctl(veid, 1);
  if ((ret = destroydir(dir)))
    return ret;
  return 0;
}


x86 assembly (clang, -O0):
<vps_destroy_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <quota_ctl@plt>
cmp    $0x0,%eax
jne    1199 <vps_destroy_dir+0x69>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1030 <quota_off@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1194 <vps_destroy_dir+0x64>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <quota_off@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     118f <vps_destroy_dir+0x5f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <vps_destroy_dir+0x9d>
jmp    1194 <vps_destroy_dir+0x64>
jmp    1199 <vps_destroy_dir+0x69>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <quota_ctl@plt>
mov    -0x10(%rbp),%rdi
call   1040 <destroydir@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11c6 <vps_destroy_dir+0x96>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cd <vps_destroy_dir+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vps_destroy_dir>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x2,%esi
call   1050 <quota_ctl@plt>
test   %eax,%eax
je     1160 <vps_destroy_dir+0x30>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <quota_ctl@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <destroydir@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <quota_off@plt>
test   %eax,%eax
je     1146 <vps_destroy_dir+0x16>
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <quota_off@plt>
test   %eax,%eax
je     1146 <vps_destroy_dir+0x16>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @vps_destroy_dir(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i32, i32* %4
%8 = call i32 @quota_ctl(i32 %7, i32 2)
%9 = icmp ne i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @quota_off(i32 %11, i32 0)
store i32 %12, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* %4
%16 = call i32 @quota_off(i32 %15, i32 1)
store i32 %16, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %31
20: ; preds = %14
br label %21
21: ; preds = %20, %10
br label %22
22: ; preds = %21, %2
%23 = load i32, i32* %4
%24 = call i32 @quota_ctl(i32 %23, i32 1)
%25 = load i8*, i8** %5
%26 = call i32 @destroydir(i8* %25)
store i32 %26, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* %6
store i32 %29, i32* %3
br label %31
30: ; preds = %22
store i32 0, i32* %3
br label %31
31: ; preds = %30, %28, %18
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @vps_destroy_dir(i32 %0, i8* %1) {
%3 = tail call i32 @quota_ctl(i32 %0, i32 2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = tail call i32 @quota_off(i32 %0, i32 0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @quota_off(i32 %0, i32 1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5, %8, %2
%12 = tail call i32 @quota_ctl(i32 %0, i32 1)
%13 = tail call i32 @destroydir(i8* %1)
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ %9, %8 ], [ %13, %11 ]
ret i32 %15
}