#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__ strlen(char const *);
int RECOIL_GetPackedExt(const char *filename) {
  int ext = 0;
  for (int i = (int)strlen(filename); --i >= 0;) {
    int c = filename[i];
    if (c == 46)
      return ext | 538976288;
    if (c <= 32 || c > 122 || ext >= 16777216)
      return 0;
    ext = (ext << 8) + c;
  }
  return 0;
}


x86 assembly (clang, -O0):
<RECOIL_GetPackedExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jl     11a8 <RECOIL_GetPackedExt+0x98>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2e,-0x1c(%rbp)
jne    116a <RECOIL_GetPackedExt+0x5a>
mov    -0x14(%rbp),%eax
or     $0x20202020,%eax
mov    %eax,-0x4(%rbp)
jmp    11af <RECOIL_GetPackedExt+0x9f>
cmpl   $0x20,-0x1c(%rbp)
jle    118b <RECOIL_GetPackedExt+0x7b>
cmpl   $0x7a,-0x1c(%rbp)
jg     118b <RECOIL_GetPackedExt+0x7b>
cmpl   $0x1000000,-0x14(%rbp)
jl     1197 <RECOIL_GetPackedExt+0x87>
movl   $0x0,-0x4(%rbp)
jmp    11af <RECOIL_GetPackedExt+0x9f>
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    112f <RECOIL_GetPackedExt+0x1f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RECOIL_GetPackedExt>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1160 <RECOIL_GetPackedExt+0x50>
mov    %eax,%ecx
add    $0x1,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x2(%rcx),%eax
movsbl (%rbx,%rax,1),%esi
cmp    $0x2e,%esi
je     1164 <RECOIL_GetPackedExt+0x54>
lea    -0x7b(%rsi),%edi
xor    %eax,%eax
cmp    $0xa6,%dil
jb     115e <RECOIL_GetPackedExt+0x4e>
cmp    $0xffffff,%edx
jg     115e <RECOIL_GetPackedExt+0x4e>
shl    $0x8,%edx
add    %esi,%edx
add    $0xffffffffffffffff,%rcx
cmp    $0x1,%rcx
ja     1130 <RECOIL_GetPackedExt+0x20>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
or     $0x20202020,%edx
mov    %edx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @RECOIL_GetPackedExt(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %27
5: ; preds = %1
%6 = and i64 %2, 4294967295
br label %7
7: ; preds = %5, %23
%8 = phi i64 [ %6, %5 ], [ %10, %23 ]
%9 = phi i32 [ 0, %5 ], [ %25, %23 ]
%10 = add nsw i64 %8, -1
%11 = and i64 %10, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i8 %13, 46
br i1 %15, label %16, label %18
16: ; preds = %7
%17 = or i32 %9, 538976288
br label %27
18: ; preds = %7
%19 = add i8 %13, -123
%20 = icmp ult i8 %19, -90
%21 = icmp sgt i32 %9, 16777215
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = shl i32 %9, 8
%25 = add nsw i32 %24, %14
%26 = icmp ugt i64 %8, 1
br i1 %26, label %7, label %27
27: ; preds = %23, %18, %1, %16
%28 = phi i32 [ %17, %16 ], [ 0, %1 ], [ 0, %18 ], [ 0, %23 ]
ret i32 %28
}