#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 btree_deletekey(int, int /*<<< orphan*/, char *, int);
int btree_locate(int, int /*<<< orphan*/, char *);
int dfile_delete_record(int, int);
int /*<<< orphan*/ dfile_write_header(int);
int g_erase_fileobject(int file_id, char *label) {
  int pt;
  if ((pt = btree_locate(file_id, 0, label)) == 0)
    return -1;
  if (btree_deletekey(file_id, 0, label, pt) == -1)
    return -1;
  if (dfile_delete_record(file_id, pt) == -1)
    return -1;
  dfile_write_header(file_id);
  return 0;
}


x86 assembly (clang, -O0):
<g_erase_fileobject>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
xor    %esi,%esi
call   1040 <btree_locate@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1175 <g_erase_fileobject+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <g_erase_fileobject+0x8a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
call   1030 <btree_deletekey@plt>
cmp    $0xffffffff,%eax
jne    119b <g_erase_fileobject+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <g_erase_fileobject+0x8a>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <dfile_delete_record@plt>
cmp    $0xffffffff,%eax
jne    11bb <g_erase_fileobject+0x7b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <g_erase_fileobject+0x8a>
mov    -0x8(%rbp),%edi
call   1050 <dfile_write_header@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g_erase_fileobject>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %esi,%esi
mov    %rbx,%rdx
call   1040 <btree_locate@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
je     1191 <g_erase_fileobject+0x51>
mov    %eax,%ebp
mov    %r15d,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1030 <btree_deletekey@plt>
cmp    $0xffffffff,%eax
je     1191 <g_erase_fileobject+0x51>
mov    %r15d,%edi
mov    %ebp,%esi
call   1060 <dfile_delete_record@plt>
cmp    $0xffffffff,%eax
je     1191 <g_erase_fileobject+0x51>
mov    %r15d,%edi
call   1050 <dfile_write_header@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @g_erase_fileobject(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i32, i32* %4
%8 = load i8*, i8** %5
%9 = call i32 @btree_locate(i32 %7, i32 0, i8* %8)
store i32 %9, i32* %6
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %28
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i32 @btree_deletekey(i32 %13, i32 0, i8* %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 -1, i32* %3
br label %28
19: ; preds = %12
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = call i32 @dfile_delete_record(i32 %20, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %3
br label %28
25: ; preds = %19
%26 = load i32, i32* %4
%27 = call i32 @dfile_write_header(i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %25, %24, %18, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @g_erase_fileobject(i32 %0, i8* %1) {
%3 = tail call i32 @btree_locate(i32 %0, i32 0, i8* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 @btree_deletekey(i32 %0, i32 0, i8* %1, i32 %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @dfile_delete_record(i32 %0, i32 %3)
%10 = icmp eq i32 %9, -1
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @dfile_write_header(i32 %0)
br label %13
13: ; preds = %8, %5, %2, %11
%14 = phi i32 [ 0, %11 ], [ -1, %2 ], [ -1, %5 ], [ -1, %8 ]
ret i32 %14
}