#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 strlen(char *);
int file_is_library(char *filename) {
  if (strlen(filename) < 4)
    return 0;
  if ((filename[strlen(filename) - 3] == '.') &&
      (filename[strlen(filename) - 2] == 's') &&
      (filename[strlen(filename) - 1] == 'o')) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_is_library>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jge    113a <file_is_library+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11cb <file_is_library+0xbb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11c4 <file_is_library+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x73,%eax
jne    11c4 <file_is_library+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6f,%eax
jne    11c4 <file_is_library+0xb4>
movl   $0x1,-0x4(%rbp)
jmp    11cb <file_is_library+0xbb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_is_library>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jl     115d <file_is_library+0x4d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2e,-0x3(%rax,%rbx,1)
jne    115b <file_is_library+0x4b>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x73,-0x2(%rax,%rbx,1)
jne    115b <file_is_library+0x4b>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x1,%eax
cmpb   $0x6f,-0x1(%rcx,%rbx,1)
je     115d <file_is_library+0x4d>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @file_is_library(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strlen(i8* %4)
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %40
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 46
br i1 %17, label %18, label %39
18: ; preds = %8
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 115
br i1 %27, label %28, label %39
28: ; preds = %18
%29 = load i8*, i8** %3
%30 = load i8*, i8** %3
%31 = call i32 @strlen(i8* %30)
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 111
br i1 %37, label %38, label %39
38: ; preds = %28
store i32 1, i32* %2
br label %40
39: ; preds = %28, %18, %8
store i32 0, i32* %2
br label %40
40: ; preds = %39, %38, %7
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @file_is_library(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 4
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, -3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 46
br i1 %10, label %11, label %25
11: ; preds = %4
%12 = tail call i32 @strlen(i8* %0)
%13 = add nsw i32 %12, -2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 115
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = tail call i32 @strlen(i8* %0)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 111
br i1 %24, label %26, label %25
25: ; preds = %18, %11, %4
br label %26
26: ; preds = %18, %1, %25
%27 = phi i32 [ 0, %25 ], [ 0, %1 ], [ 1, %18 ]
ret i32 %27
}