#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_SUCCESS;
int /*<<< orphan*/ Error(char *);
int /*<<< orphan*/ LibClose();
int /*<<< orphan*/ LibOpen(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ ObjExtract(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void ExtractObjFiles(int argc, char *argv[]) {
  int I;
  if (argc <= 0) {
    Error("No library name given");
  }
  if (argc <= 1) {
    Error("No object files to extract");
  }
  LibOpen(argv[0], 1, 0);
  I = 1;
  while (I < argc) {
    ObjExtract(argv[I]);
    ++I;
  }
  LibClose();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<ExtractObjFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1175 <ExtractObjFiles+0x25>
lea    0xe90(%rip),%rdi
call   1030 <Error@plt>
cmpl   $0x1,-0x4(%rbp)
jg     118b <ExtractObjFiles+0x3b>
lea    0xe90(%rip),%rdi
call   1030 <Error@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <LibOpen@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d0 <ExtractObjFiles+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <ObjExtract@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a5 <ExtractObjFiles+0x55>
mov    $0x0,%al
call   1040 <LibClose@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<ExtractObjFiles>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
test   %edi,%edi
jg     1169 <ExtractObjFiles+0x19>
lea    0xe9e(%rip),%rdi
call   1030 <Error@plt>
jmp    1170 <ExtractObjFiles+0x20>
mov    %edi,%ebp
cmp    $0x1,%edi
jne    118d <ExtractObjFiles+0x3d>
lea    0xe9f(%rip),%rdi
call   1030 <Error@plt>
mov    (%r14),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <LibOpen@plt>
jmp    11c2 <ExtractObjFiles+0x72>
mov    (%r14),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <LibOpen@plt>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
call   1050 <ObjExtract@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <ExtractObjFiles+0x60>
xor    %eax,%eax
call   1040 <LibClose@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"No library name given\00"
@.str.1 = [27 x i8] c"No object files to extract\00"
@EXIT_SUCCESS = global i32 0
define void @ExtractObjFiles(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 i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @Error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @Error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @LibOpen(i8* %18, i32 1, i32 0)
store i32 1, i32* %5
br label %20
20: ; preds = %24, %15
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i8**, i8*** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @ObjExtract(i8* %29)
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %20
33: ; preds = %20
%34 = call i32 (...) @LibClose()
%35 = load i32, i32* @EXIT_SUCCESS
%36 = call i32 @exit(i32 %35)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"No library name given\00"
@.str.1 = [27 x i8] c"No object files to extract\00"
@EXIT_SUCCESS = global i32 0
define void @ExtractObjFiles(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @Error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %8
6: ; preds = %2
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %12
8: ; preds = %6, %4
%9 = tail call i32 @Error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %1
%11 = tail call i32 @LibOpen(i8* %10, i32 1, i32 0)
br label %23
12: ; preds = %6
%13 = load i8*, i8** %1
%14 = tail call i32 @LibOpen(i8* %13, i32 1, i32 0)
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ 1, %12 ], [ %21, %16 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32 @ObjExtract(i8* %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %15
br i1 %22, label %23, label %16
23: ; preds = %16, %8
%24 = tail call i32 (...) @LibClose()
%25 = load i32, i32* @EXIT_SUCCESS
%26 = tail call i32 @exit(i32 %25)
unreachable
}