#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 dummy;
};
struct FTW {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fatal_e_(int, char *, int, char *, char const *);
scalar_t__ rmdir(char const *);
scalar_t__ unlink(char const *);
int _rmdir_recursive_fn(const char *fpath, const struct stat *sb, int typeflag,
                        struct FTW *ftwbuf) {
  if (unlink(fpath) == 0)
    return 0;
  else if (rmdir(fpath) == 0)
    return 0;
  else
    do {
      fatal_e_(3,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/drkitty/netroper/refs/heads/"
               "master/netroper.c",
               107, "Can't remove \"%s\"", fpath);
    } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<_rmdir_recursive_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jne    1166 <_rmdir_recursive_fn+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11bc <_rmdir_recursive_fn+0x8c>
mov    -0x10(%rbp),%rdi
call   1050 <rmdir@plt>
cmp    $0x0,%rax
jne    1185 <_rmdir_recursive_fn+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11bc <_rmdir_recursive_fn+0x8c>
jmp    118a <_rmdir_recursive_fn+0x5a>
mov    -0x10(%rbp),%r8
mov    $0x3,%edi
lea    0xe66(%rip),%rsi
mov    $0x6b,%edx
lea    0xee2(%rip),%rcx
call   1040 <fatal_e_@plt>
jmp    11b0 <_rmdir_recursive_fn+0x80>
jmp    11b5 <_rmdir_recursive_fn+0x85>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_rmdir_recursive_fn>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <unlink@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1174 <_rmdir_recursive_fn+0x44>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
test   %rax,%rax
je     1174 <_rmdir_recursive_fn+0x44>
lea    0xeaa(%rip),%rsi
lea    0xf2b(%rip),%rcx
mov    $0x3,%edi
mov    $0x6b,%edx
mov    %rbx,%r8
call   1040 <fatal_e_@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.FTW = type { i32 }
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/netroper/refs/heads/master/netroper.c\00"
@.str.1 = [18 x i8] c"Can't remove \22%s\22\00"
define i32 @_rmdir_recursive_fn(i8* %0, %struct.stat* %1, i32 %2, %struct.FTW* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.stat*
%8 = alloca i32
%9 = alloca %struct.FTW*
store i8* %0, i8** %6
store %struct.stat* %1, %struct.stat** %7
store i32 %2, i32* %8
store %struct.FTW* %3, %struct.FTW** %9
%10 = load i8*, i8** %6
%11 = call i64 @unlink(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 0, i32* %5
br label %26
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = call i64 @rmdir(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %5
br label %26
19: ; preds = %14
br label %20
20: ; preds = %19
%21 = load i8*, i8** %6
%22 = call i32 @fatal_e_(i32 3, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str, i64 0, i64 0), i32 107, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
store i32 1, i32* %5
br label %26
26: ; preds = %25, %18, %13
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.FTW = type { i32 }
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/netroper/refs/heads/master/netroper.c\00"
@.str.1 = [18 x i8] c"Can't remove \22%s\22\00"
define i32 @_rmdir_recursive_fn(i8* %0, %struct.stat* nocapture readnone %1, i32 %2, %struct.FTW* nocapture readnone %3) {
%5 = tail call i64 @unlink(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @rmdir(i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @fatal_e_(i32 3, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str, i64 0, i64 0), i32 107, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %7, %4, %10
%13 = phi i32 [ 1, %10 ], [ 0, %4 ], [ 0, %7 ]
ret i32 %13
}