#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*/);
scalar_t__ mfm_dots_dir(char *);
int /*<<< orphan*/
mfm_traverse_directory(char *, int (*)(char *, struct stat *, void *), void *);
int /*<<< orphan*/ remove(char *);
int mfm_delete_item(char *path, struct stat *st, void *udata) {
  if (mfm_dots_dir(path)) {
    return 0;
  }
  if (S_ISDIR(st->st_mode)) {
    mfm_traverse_directory(path, mfm_delete_item, udata);
  }
  remove(path);
  return 0;
}


x86 assembly (clang, -O0):
<mfm_delete_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mfm_dots_dir@plt>
cmp    $0x0,%rax
je     1173 <mfm_delete_item+0x33>
movl   $0x0,-0x4(%rbp)
jmp    11ac <mfm_delete_item+0x6c>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     119c <mfm_delete_item+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    0x2e51(%rip),%rsi
call   1060 <mfm_traverse_directory@plt>
mov    -0x10(%rbp),%rdi
call   1030 <remove@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfm_delete_item>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <mfm_dots_dir@plt>
test   %rax,%rax
jne    117f <mfm_delete_item+0x3f>
mov    (%r15),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     1177 <mfm_delete_item+0x37>
mov    0x2e7c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <mfm_traverse_directory@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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