#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*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ check_archive(int);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int delete (int argc, char *argv[]) {
  int archiveFd;
  archiveFd = open(argv[2], O_RDONLY);
  if (archiveFd == -1) {
    perror("archive");
    _exit(EXIT_FAILURE);
  }
  check_archive(archiveFd);
  printf("Feature not yet implemented\n");
  close(archiveFd);
  return 0;
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ac <delete+0x4c>
lea    0xe67(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x14(%rbp),%edi
call   1080 <check_archive@plt>
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %rbx
mov    0x10(%rsi),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     1198 <delete+0x38>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <check_archive@plt>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe61(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [8 x i8] c"archive\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"Feature not yet implemented\0A\00"
define i32 @delete(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i64 2
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @_exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* %5
%19 = call i32 @check_archive(i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %5
%22 = call i32 @close(i32 %21)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [8 x i8] c"archive\00"
@EXIT_FAILURE = global i32 0
@str = [28 x i8] c"Feature not yet implemented\00"
define i32 @delete(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* %4, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @_exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 @check_archive(i32 %6)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @close(i32 %6)
ret i32 0
}