#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 */
struct node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ check_archive(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ extract_aux(char *, struct node *);
char *getprogname();
struct node *list_lookup(char *);
struct node *list_next(struct node *);
int /*<<< orphan*/ parse_archive(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int extract(char *ar_name, char *file_name) {
  struct node *ptr = NULL;
  check_archive(ar_name);
  parse_archive(ar_name);
  if (!file_name)
    while ((ptr = list_next(ptr)) != NULL)
      extract_aux(ar_name, ptr);
  else {
    if (!(ptr = list_lookup(file_name))) {
      printf("%s: no entry %s found\n", getprogname(), file_name);
      exit(0);
    }
    extract_aux(ar_name, ptr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<extract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <check_archive@plt>
mov    -0x8(%rbp),%rdi
call   1070 <parse_archive@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11e8 <extract+0x68>
jmp    11ba <extract+0x3a>
mov    -0x18(%rbp),%rdi
call   1050 <list_next@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11e3 <extract+0x63>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <extract_aux@plt>
jmp    11ba <extract+0x3a>
jmp    122d <extract+0xad>
mov    -0x10(%rbp),%rdi
call   1080 <list_lookup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1220 <extract+0xa0>
mov    $0x0,%al
call   1030 <getprogname@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rdx
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <extract_aux@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   10a0 <check_archive@plt>
mov    %r15,%rdi
call   1070 <parse_archive@plt>
test   %r14,%r14
je     11b7 <extract+0x37>
mov    %r14,%rdi
call   1080 <list_lookup@plt>
test   %rax,%rax
je     11f3 <extract+0x73>
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <extract_aux@plt>
jmp    11eb <extract+0x6b>
xor    %edi,%edi
call   1050 <list_next@plt>
test   %rax,%rax
je     11eb <extract+0x6b>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <extract_aux@plt>
mov    %rbx,%rdi
call   1050 <list_next@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <extract+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <getprogname@plt>
lea    0xdff(%rip),%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [23 x i8] c"%s: no entry %s found\0A\00"
define i32 @extract(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.node*
store i8* %0, i8** %3
store i8* %1, i8** %4
store %struct.node* null, %struct.node** %5
%6 = load i8*, i8** %3
%7 = call i32 @check_archive(i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @parse_archive(i8* %8)
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %22, label %12
12: ; preds = %2
br label %13
13: ; preds = %17, %12
%14 = load %struct.node*, %struct.node** %5
%15 = call %struct.node* @list_next(%struct.node* %14)
store %struct.node* %15, %struct.node** %5
%16 = icmp ne %struct.node* %15, null
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load %struct.node*, %struct.node** %5
%20 = call i32 @extract_aux(i8* %18, %struct.node* %19)
br label %13
21: ; preds = %13
br label %35
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = call %struct.node* @list_lookup(i8* %23)
store %struct.node* %24, %struct.node** %5
%25 = icmp ne %struct.node* %24, null
br i1 %25, label %31, label %26
26: ; preds = %22
%27 = call i8* (...) @getprogname()
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %28)
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %22
%32 = load i8*, i8** %3
%33 = load %struct.node*, %struct.node** %5
%34 = call i32 @extract_aux(i8* %32, %struct.node* %33)
br label %35
35: ; preds = %31, %21
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [23 x i8] c"%s: no entry %s found\0A\00"
define i32 @extract(i8* %0, i8* %1) {
%3 = tail call i32 @check_archive(i8* %0)
%4 = tail call i32 @parse_archive(i8* %0)
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = tail call %struct.node* @list_next(%struct.node* null)
%8 = icmp eq %struct.node* %7, null
br i1 %8, label %23, label %9
9: ; preds = %6, %9
%10 = phi %struct.node* [ %12, %9 ], [ %7, %6 ]
%11 = tail call i32 @extract_aux(i8* %0, %struct.node* %10)
%12 = tail call %struct.node* @list_next(%struct.node* %10)
%13 = icmp eq %struct.node* %12, null
br i1 %13, label %23, label %9
14: ; preds = %2
%15 = tail call %struct.node* @list_lookup(i8* %1)
%16 = icmp eq %struct.node* %15, null
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i8* (...) @getprogname()
%19 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %1)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %14
%22 = tail call i32 @extract_aux(i8* %0, %struct.node* %15)
br label %23
23: ; preds = %9, %6, %21
ret i32 0
}