#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 */
typedef char const uint8_t;
typedef int /*<<< orphan*/ header;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int imports_ar_read_signature(uint8_t *buffer, int file_size) {
  const char *header = "!<arch>\n";
  int i;
  if (file_size < sizeof(header)) {
    printf("Not a library archive file.\n");
    return -1;
  }
  for (i = 0; i < sizeof(header); i++) {
    if (buffer[i] != header[i]) {
      printf("Not a library archive file.\n");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<imports_ar_read_signature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jae    1150 <imports_ar_read_signature+0x40>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <imports_ar_read_signature+0xa7>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x8,%rax
jae    11b0 <imports_ar_read_signature+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     119d <imports_ar_read_signature+0x8d>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <imports_ar_read_signature+0xa7>
jmp    11a2 <imports_ar_read_signature+0x92>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1157 <imports_ar_read_signature+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imports_ar_read_signature>:
push   %rax
cmp    $0x8,%esi
jb     1147 <imports_ar_read_signature+0x37>
cmpb   $0x21,(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x3c,0x1(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x61,0x2(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x72,0x3(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x63,0x4(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x68,0x5(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
cmpb   $0x3e,0x6(%rdi)
jne    1147 <imports_ar_read_signature+0x37>
xor    %eax,%eax
cmpb   $0xa,0x7(%rdi)
je     1158 <imports_ar_read_signature+0x48>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"!<arch>\0A\00"
@.str.1 = [29 x i8] c"Not a library archive file.\0A\00"
define i32 @imports_ar_read_signature(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 8
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %39
13: ; preds = %2
store i32 0, i32* %7
br label %14
14: ; preds = %35, %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = icmp ult i64 %16, 8
br i1 %17, label %18, label %38
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %24, %30
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %39
34: ; preds = %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %14
38: ; preds = %14
store i32 0, i32* %3
br label %39
39: ; preds = %38, %32, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@str.2 = [28 x i8] c"Not a library archive file.\00"
define i32 @imports_ar_read_signature(i8* nocapture %0, i32 %1) {
%3 = icmp ult i32 %1, 8
br i1 %3, label %35, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 33
br i1 %6, label %7, label %35
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 60
br i1 %10, label %11, label %35
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 97
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %0, i64 3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 114
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %0, i64 4
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 99
br i1 %22, label %23, label %35
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %0, i64 5
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 104
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = getelementptr inbounds i8, i8* %0, i64 6
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 62
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %0, i64 7
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 10
br i1 %34, label %38, label %35
35: ; preds = %4, %7, %11, %15, %19, %23, %27, %31, %2
%36 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %31 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %27 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %23 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %19 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.2, i64 0, i64 0), %4 ]
%37 = tail call i32 @puts(i8* dereferenceable(1) %36)
br label %38
38: ; preds = %35, %31
%39 = phi i32 [ 0, %31 ], [ -1, %35 ]
ret i32 %39
}