#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 */
scalar_t__ ENOENT;
char *append(char *, char const *);
int /*<<< orphan*/ err(int, char *, char *);
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *, char const *);
int /*<<< orphan*/ free(char *);
char *plandir();
scalar_t__ unlink(char *);
void delete (const char *plan) {
  char *path = append(append(plandir(), "/"), plan);
  if (unlink(path) < 0) {
    if (errno == ENOENT)
      errx(1, "plan '%s' does not exist", plan);
    else
      err(1, "could not remove plan file '%s'", path);
  }
  path = append(path, ".status");
  if (unlink(path) < 0)
    err(1, "could not remove plan status file '%s'", path);
  free(path);
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <plandir@plt>
mov    %rax,%rdi
lea    0xe83(%rip),%rsi
call   1040 <append@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%rsi
call   1040 <append@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <unlink@plt>
cmp    $0x0,%rax
jge    11f3 <delete+0x93>
mov    0x2e34(%rip),%rax
mov    (%rax),%rax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%rax
jne    11d9 <delete+0x79>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe33(%rip),%rsi
call   1070 <errx@plt>
jmp    11ee <delete+0x8e>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe32(%rip),%rsi
call   1080 <err@plt>
jmp    11f3 <delete+0x93>
mov    -0x10(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <append@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <unlink@plt>
cmp    $0x0,%rax
jge    122f <delete+0xcf>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe19(%rip),%rsi
call   1080 <err@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <plandir@plt>
lea    0xe8b(%rip),%rsi
mov    %rax,%rdi
call   1040 <append@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <append@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <unlink@plt>
test   %rax,%rax
jns    11d8 <delete+0x78>
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%rax
jne    11c4 <delete+0x64>
lea    0xe4d(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rdx
call   1070 <errx@plt>
jmp    11d8 <delete+0x78>
lea    0xe50(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1080 <err@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <append@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <unlink@plt>
test   %rax,%rax
jns    120b <delete+0xab>
lea    0xe45(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1080 <err@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [25 x i8] c"plan '%s' does not exist\00"
@.str.2 = [32 x i8] c"could not remove plan file '%s'\00"
@.str.3 = [8 x i8] c".status\00"
@.str.4 = [39 x i8] c"could not remove plan status file '%s'\00"
define void @delete(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i8* (...) @plandir()
%5 = call i8* @append(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i8* @append(i8* %5, i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i64 @unlink(i8* %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %1
%12 = load i64, i64* @errno
%13 = load i64, i64* @ENOENT
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = call i32 @errx(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %21
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = call i32 @err(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %15
br label %22
22: ; preds = %21, %1
%23 = load i8*, i8** %3
%24 = call i8* @append(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = call i64 @unlink(i8* %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = call i32 @err(i32 1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %22
%32 = load i8*, i8** %3
%33 = call i32 @free(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [25 x i8] c"plan '%s' does not exist\00"
@.str.2 = [32 x i8] c"could not remove plan file '%s'\00"
@.str.3 = [8 x i8] c".status\00"
@.str.4 = [39 x i8] c"could not remove plan status file '%s'\00"
define void @delete(i8* %0) {
%2 = tail call i8* (...) @plandir()
%3 = tail call i8* @append(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @append(i8* %3, i8* %0)
%5 = tail call i64 @unlink(i8* %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOENT
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
13: ; preds = %7
%14 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %15
15: ; preds = %11, %13, %1
%16 = tail call i8* @append(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i64 @unlink(i8* %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %21
21: ; preds = %19, %15
%22 = tail call i32 @free(i8* %16)
ret void
}