#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 */
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
int loader_SSS_check(const char *filename, unsigned char *data, long size) {
  int len;
  const char *name;
  len = data[0] | (data[1] << 8);
  if (len > size)
    return 0;
  if ((len + 129) < size)
    return 0;
  if (data[3] != 4)
    return 0;
  len = strlen(filename);
  if (len >= 4) {
    name = filename + len - 4;
    if (strcmp(name, ".sss") == 0)
      return 1;
    if (strcmp(name, ".SSS") == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<loader_SSS_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    1165 <loader_SSS_check+0x45>
movl   $0x0,-0x4(%rbp)
jmp    1223 <loader_SSS_check+0x103>
mov    -0x24(%rbp),%eax
add    $0x81,%eax
cltq
cmp    -0x20(%rbp),%rax
jge    1185 <loader_SSS_check+0x65>
movl   $0x0,-0x4(%rbp)
jmp    1223 <loader_SSS_check+0x103>
mov    -0x18(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x4,%eax
je     11a2 <loader_SSS_check+0x82>
movl   $0x0,-0x4(%rbp)
jmp    1223 <loader_SSS_check+0x103>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jl     121c <loader_SSS_check+0xfc>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <loader_SSS_check+0xd1>
movl   $0x1,-0x4(%rbp)
jmp    1223 <loader_SSS_check+0x103>
mov    -0x30(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1217 <loader_SSS_check+0xf7>
movl   $0x1,-0x4(%rbp)
jmp    1223 <loader_SSS_check+0x103>
jmp    121c <loader_SSS_check+0xfc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loader_SSS_check>:
push   %r14
push   %rbx
push   %rax
movzwl (%rsi),%eax
xor    %ebx,%ebx
cmp    %rdx,%rax
jg     1183 <loader_SSS_check+0x63>
add    $0x81,%eax
cmp    %rdx,%rax
jl     1183 <loader_SSS_check+0x63>
cmpb   $0x4,0x3(%rsi)
jne    1183 <loader_SSS_check+0x63>
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x4,%eax
jl     1181 <loader_SSS_check+0x61>
mov    %eax,%eax
add    %rax,%r14
add    $0xfffffffffffffffc,%r14
lea    0xea5(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     1183 <loader_SSS_check+0x63>
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1183 <loader_SSS_check+0x63>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c".sss\00"
@.str.1 = [5 x i8] c".SSS\00"
define i32 @loader_SSS_check(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl i32 %17, 8
%19 = or i32 %13, %18
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = load i64, i64* %7
%23 = icmp sgt i64 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %3
store i32 0, i32* %4
br label %61
25: ; preds = %3
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 129
%28 = sext i32 %27 to i64
%29 = load i64, i64* %7
%30 = icmp slt i64 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %4
br label %61
32: ; preds = %25
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 3
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = icmp ne i32 %36, 4
br i1 %37, label %38, label %39
38: ; preds = %32
store i32 0, i32* %4
br label %61
39: ; preds = %32
%40 = load i8*, i8** %5
%41 = call i32 @strlen(i8* %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp sge i32 %42, 4
br i1 %43, label %44, label %60
44: ; preds = %39
%45 = load i8*, i8** %5
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = getelementptr inbounds i8, i8* %48, i64 -4
store i8* %49, i8** %9
%50 = load i8*, i8** %9
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %44
store i32 1, i32* %4
br label %61
54: ; preds = %44
%55 = load i8*, i8** %9
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 1, i32* %4
br label %61
59: ; preds = %54
br label %60
60: ; preds = %59, %39
store i32 0, i32* %4
br label %61
61: ; preds = %60, %58, %53, %38, %31, %24
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
@.str = [5 x i8] c".sss\00"
@.str.1 = [5 x i8] c".SSS\00"
define i32 @loader_SSS_check(i8* %0, i8* nocapture %1, i64 %2) {
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = shl nuw nsw i32 %8, 8
%10 = or i32 %9, %5
%11 = zext i32 %10 to i64
%12 = icmp sgt i64 %11, %2
%13 = add nuw nsw i32 %10, 129
%14 = zext i32 %13 to i64
%15 = icmp slt i64 %14, %2
%16 = select i1 %12, i1 true, i1 %15
br i1 %16, label %34, label %17
17: ; preds = %3
%18 = getelementptr inbounds i8, i8* %1, i64 3
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 4
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = tail call i32 @strlen(i8* %0)
%23 = icmp sgt i32 %22, 3
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = zext i32 %22 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -4
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %24
%31 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %30, %21
br label %34
34: ; preds = %30, %24, %17, %3, %33
%35 = phi i32 [ 0, %33 ], [ 0, %3 ], [ 0, %17 ], [ 1, %24 ], [ 1, %30 ]
ret i32 %35
}