#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;
scalar_t__ errno;
char *format(char *, char const *);
int unlink(char const *);
int /*<<< orphan*/ warning(char *, char const *);
bool unlink_by_tag(const char *tag) {
  const char *path;
  if (tag == NULL)
    return false;
  path = format("/var/crash_reports"
                "/"
                "crash_report"
                "__"
                "%s",
                tag);
  if (unlink(path) == -1 && errno != ENOENT) {
    warning("%s: unlink", path);
    return false;
  }
  path = format("/var/crash_reports"
                "/"
                "core"
                "__"
                "%s",
                tag);
  if (unlink(path) == -1 && errno != ENOENT) {
    warning("%s: unlink", path);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<unlink_by_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <unlink_by_tag+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1212 <unlink_by_tag+0xe2>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1050 <format@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
jne    11af <unlink_by_tag+0x7f>
mov    0x2e60(%rip),%rax
mov    (%rax),%rax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%rax
je     11af <unlink_by_tag+0x7f>
mov    -0x18(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1040 <warning@plt>
movl   $0x0,-0x4(%rbp)
jmp    1212 <unlink_by_tag+0xe2>
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1050 <format@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
jne    120b <unlink_by_tag+0xdb>
mov    0x2e04(%rip),%rax
mov    (%rax),%rax
mov    0x2dea(%rip),%rcx
cmp    (%rcx),%rax
je     120b <unlink_by_tag+0xdb>
mov    -0x18(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1040 <warning@plt>
movl   $0x0,-0x4(%rbp)
jmp    1212 <unlink_by_tag+0xe2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlink_by_tag>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     11c4 <unlink_by_tag+0x94>
mov    %rdi,%rbx
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <format@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
jne    1177 <unlink_by_tag+0x47>
mov    0x2e78(%rip),%rax
mov    (%rax),%rax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%rax
jne    11b3 <unlink_by_tag+0x83>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1050 <format@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <unlink@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0xffffffff,%ecx
jne    11c4 <unlink_by_tag+0x94>
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e22(%rip),%rdx
cmp    (%rdx),%rcx
je     11c4 <unlink_by_tag+0x94>
lea    0xe6a(%rip),%rdi
mov    %r14,%rsi
call   1040 <warning@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"/var/crash_reports/crash_report__%s\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [11 x i8] c"%s: unlink\00"
@.str.2 = [28 x i8] c"/var/crash_reports/core__%s\00"
define i32 @unlink_by_tag(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %35
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @format(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @unlink(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %21
14: ; preds = %8
%15 = load i64, i64* @errno
%16 = load i64, i64* @ENOENT
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = call i32 @warning(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 0, i32* %2
br label %35
21: ; preds = %14, %8
%22 = load i8*, i8** %3
%23 = call i8* @format(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %22)
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = call i32 @unlink(i8* %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %34
27: ; preds = %21
%28 = load i64, i64* @errno
%29 = load i64, i64* @ENOENT
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = call i32 @warning(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 0, i32* %2
br label %35
34: ; preds = %27, %21
store i32 1, i32* %2
br label %35
35: ; preds = %34, %31, %18, %7
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [36 x i8] c"/var/crash_reports/crash_report__%s\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [11 x i8] c"%s: unlink\00"
@.str.2 = [28 x i8] c"/var/crash_reports/core__%s\00"
define i32 @unlink_by_tag(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call i8* @format(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 @unlink(i8* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOENT
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7, %3
%12 = tail call i8* @format(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = tail call i32 @unlink(i8* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i64, i64* @errno
%17 = load i64, i64* @ENOENT
%18 = icmp eq i64 %16, %17
br i1 %18, label %22, label %19
19: ; preds = %15, %7
%20 = phi i8* [ %4, %7 ], [ %12, %15 ]
%21 = tail call i32 @warning(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %11, %15, %1
%23 = phi i32 [ 0, %1 ], [ 1, %15 ], [ 1, %11 ], [ 0, %19 ]
ret i32 %23
}