#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*/ isupper(char const);
scalar_t__ memcmp(char const *, char const *, int);
int strlen(char const *);
int match_signature(void *userdata, const char *name) {
  (void)userdata;
  const char *prefix = "META-INF/";
  const char *suffix = ".SF";
  int prefix_len = strlen(prefix);
  int suffix_len = strlen(suffix);
  int name_len = strlen(name);
  int body_len = name_len - prefix_len - suffix_len;
  int suffix_offset = prefix_len + body_len;
  if (!(body_len > 0)) {
    return 0;
  }
  if (memcmp(prefix, name, prefix_len)) {
    return 0;
  }
  if (memcmp(suffix, name + suffix_offset, suffix_len)) {
    return 0;
  }
  for (int i = prefix_len; i < suffix_offset; i++) {
    if (!isupper(name[i])) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<match_signature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeb8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x38(%rbp)
jg     11a5 <match_signature+0x75>
movl   $0x0,-0x4(%rbp)
jmp    124a <match_signature+0x11a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11cb <match_signature+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    124a <match_signature+0x11a>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x3c(%rbp),%rax
add    %rax,%rsi
mov    -0x30(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11f8 <match_signature+0xc8>
movl   $0x0,-0x4(%rbp)
jmp    124a <match_signature+0x11a>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1243 <match_signature+0x113>
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isupper@plt>
cmp    $0x0,%eax
jne    1230 <match_signature+0x100>
movl   $0x0,-0x4(%rbp)
jmp    124a <match_signature+0x11a>
jmp    1235 <match_signature+0x105>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11fe <match_signature+0xce>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_signature>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xebb(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xeb6(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
sub    %r12d,%ebp
sub    %r14d,%ebp
xor    %r15d,%r15d
test   %ebp,%ebp
jle    11d3 <match_signature+0xa3>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    11d3 <match_signature+0xa3>
add    %r14d,%ebp
movslq %ebp,%r13
lea    (%rbx,%r13,1),%rsi
lea    0xe6f(%rip),%rdi
mov    %r12d,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    11d3 <match_signature+0xa3>
movslq %r14d,%rbp
add    $0x1,%rbp
nop
movsbl -0x1(%rbx,%rbp,1),%edi
call   1050 <isupper@plt>
test   %eax,%eax
je     11ca <match_signature+0x9a>
lea    0x1(%rbp),%rcx
cmp    %r13,%rbp
mov    %rcx,%rbp
jl     11b0 <match_signature+0x80>
xor    %r15d,%r15d
test   %eax,%eax
setne  %r15b
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"META-INF/\00"
@.str.1 = [4 x i8] c".SF\00"
define i32 @match_signature(i8* nocapture readnone %0, i8* %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, %3
%7 = sub i32 %5, %6
%8 = add nsw i32 %7, %3
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %33
10: ; preds = %2
%11 = tail call i64 @memcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = sext i32 %8 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = tail call i64 @memcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = sext i32 %3 to i64
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ %19, %18 ], [ %26, %20 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = tail call i32 @isupper(i8 signext %23)
%25 = icmp eq i32 %24, 0
%26 = add nsw i64 %21, 1
%27 = xor i1 %25, true
%28 = icmp slt i64 %26, %14
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %20, label %30
30: ; preds = %20
%31 = xor i1 %25, true
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %30, %13, %10, %2
%34 = phi i32 [ 0, %2 ], [ 0, %10 ], [ 0, %13 ], [ %32, %30 ]
ret i32 %34
}