#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 /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ rmdir(char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int test_delete_self_helper(char *path, void *dummy) {
  if (rmdir(path) < 0) {
    fprintf(stderr, "Cannot rmdir %s: %s\n", path, strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_delete_self_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rmdir@plt>
cmp    $0x0,%rax
jge    1197 <test_delete_self_helper+0x67>
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe7a(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <test_delete_self_helper+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_delete_self_helper>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <rmdir@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1175 <test_delete_self_helper+0x45>
mov    0x2e94(%rip),%rax
mov    (%rax),%ebp
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe9d(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Cannot rmdir %s: %s\0A\00"
@errno = global i32 0
define i32 @test_delete_self_helper(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i64 @rmdir(i8* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %4
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13)
store i32 -1, i32* %3
br label %16
15: ; preds = %2
store i32 0, i32* %3
br label %16
16: ; preds = %15, %9
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Cannot rmdir %s: %s\0A\00"
@errno = global i32 0
define i32 @test_delete_self_helper(i8* %0, i8* nocapture readnone %1) {
%3 = tail call i64 @rmdir(i8* %0)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8)
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ -1, %5 ], [ 0, %2 ]
ret i32 %11
}