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


x86 assembly (clang, -O0):
<extract>:
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    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    $0x1b6,%edx
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c1 <extract+0x51>
lea    0xe52(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x14(%rbp),%edi
call   1090 <check_archive@plt>
mov    -0x14(%rbp),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
lea    0xe1e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract>:
push   %rbx
mov    0x10(%rsi),%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
mov    $0x1b6,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11c6 <extract+0x56>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <check_archive@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
call   1050 <lseek@plt>
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe33(%rip),%rdi
call   1080 <perror@plt>
mov    0x2def(%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
@SARMAG = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [29 x i8] c"Feature not yet implemented\0A\00"
define i32 @extract(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, i32 438)
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 = load i32, i32* %5
%21 = load i32, i32* @SARMAG
%22 = load i32, i32* @SEEK_SET
%23 = call i32 @lseek(i32 %20, i32 %21, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %5
%26 = call i32 @close(i32 %25)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [8 x i8] c"archive\00"
@EXIT_FAILURE = global i32 0
@SARMAG = global i32 0
@SEEK_SET = global i32 0
@str = [28 x i8] c"Feature not yet implemented\00"
define i32 @extract(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, i32 438)
%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 = load i32, i32* @SARMAG
%15 = load i32, i32* @SEEK_SET
%16 = tail call i32 @lseek(i32 %6, i32 %14, i32 %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @close(i32 %6)
ret i32 0
}