#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int enum_opt_dir(int /*<<< orphan*/, char *, int, int /*<<< orphan*/,
                 int /*<<< orphan*/, int /*<<< orphan*/);
int remove(char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int optDelete(char *obj) {
  int ret = 0;
  struct stat info;
  stat(obj, &info);
  if (S_ISDIR(info.st_mode)) {
    ;
    ret = enum_opt_dir(0, obj, 1, 0, 0, 0);
  }
  if (0 == ret) {
    ;
    ret = remove(obj);
  }
  return ret;
}


x86 assembly (clang, -O0):
<optDelete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <stat@plt>
mov    -0x10(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     118f <optDelete+0x4f>
mov    -0x8(%rbp),%rsi
xor    %r9d,%r9d
mov    $0x1,%edx
mov    %r9d,%edi
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1060 <enum_opt_dir@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jne    11a6 <optDelete+0x66>
mov    -0x8(%rbp),%rdi
call   1030 <remove@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optDelete>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
mov    0x8(%rsp),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     1181 <optDelete+0x41>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1060 <enum_opt_dir@plt>
test   %eax,%eax
je     1181 <optDelete+0x41>
add    $0x10,%rsp
pop    %rbx
ret
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <remove@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @optDelete(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.stat
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i32 @stat(i8* %5, %struct.stat* %4)
%7 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%8 = load i32, i32* %7
%9 = call i64 @S_ISDIR(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @enum_opt_dir(i32 0, i8* %12, i32 1, i32 0, i32 0, i32 0)
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %1
%15 = load i32, i32* %3
%16 = icmp eq i32 0, %15
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %2
%19 = call i32 @remove(i8* %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @optDelete(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i32 @stat(i8* %0, %struct.stat* %2)
%5 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i64 @S_ISDIR(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = tail call i32 @enum_opt_dir(i32 0, i8* %0, i32 1, i32 0, i32 0, i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1, %9
%13 = tail call i32 @remove(i8* %0)
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ %13, %12 ], [ %10, %9 ]
ret i32 %15
}