#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 int /*<<< orphan*/ mm_pad_version_info;
typedef int /*<<< orphan*/ mm_header;

/* Variables and functions */
scalar_t__ memcmp(unsigned char const *, ...);
int strlen(char const *);
unsigned int search_MMT(const unsigned char *buffer, const unsigned int i,
                        const unsigned int buffer_size) {
  const unsigned char mm_header[10] = {'1', '8', '2', '7',  '3',
                                       '6', '4', '5', 0x00, 0x00};
  const unsigned char mm_pad_version_info[14] = {0x00, 0x00, 0x00, 0x00, '1',
                                                 '8',  '2',  '7',  '3',  '6',
                                                 '4',  '5',  0x00, 0x00};
  const char *mm_footer = "Brava Software Inc.";
  const char *mm_footer_tag = "TAG";
  unsigned int size = 0;
  unsigned int image_size;
  if (i + sizeof(mm_header) > buffer_size)
    return 0;
  if (memcmp(&buffer[i], mm_header, sizeof(mm_header)) == 0) {
    size = 256;
  } else {
    if (memcmp(&buffer[i + size], "    ", 4) != 0 &&
        memcmp(&buffer[i + size], "bmp ", 4) != 0 &&
        memcmp(&buffer[i + size], "jpg ", 4) != 0)
      return 0;
  }
  image_size = buffer[i + size + 4] + (buffer[i + size + 5] << 8) +
               (buffer[i + size + 6] << 16) + (buffer[i + size + 7] << 24);
  size += 8 + image_size;
  if (i + size + sizeof(mm_pad_version_info) > buffer_size) {
    return 0;
  }
  if (memcmp(&buffer[i + size], mm_pad_version_info,
             sizeof(mm_pad_version_info)) != 0) {
    return 0;
  }
  size += 4 + 256;
  size += 20;
  if (i + size + 8132 + sizeof(*mm_footer) > buffer_size) {
    return 0;
  }
  if (memcmp(&buffer[i + size + 7868], mm_footer, strlen(mm_footer)) == 0 ||
      memcmp(&buffer[i + size + 7868], mm_footer_tag, strlen(mm_footer_tag)) ==
          0)
    size += 7868;
  else if (memcmp(&buffer[i + size + 7936], mm_footer, strlen(mm_footer)) ==
               0 ||
           memcmp(&buffer[i + size + 7936], mm_footer_tag,
                  strlen(mm_footer_tag)) == 0)
    size += 7936;
  else if (memcmp(&buffer[i + size + 8004], mm_footer, strlen(mm_footer)) ==
               0 ||
           memcmp(&buffer[i + size + 8004], mm_footer_tag,
                  strlen(mm_footer_tag)) == 0)
    size += 8004;
  else if (memcmp(&buffer[i + size + 8132], mm_footer, strlen(mm_footer)) ==
               0 ||
           memcmp(&buffer[i + size + 8132], mm_footer_tag,
                  strlen(mm_footer_tag)) == 0)
    size += 8132;
  else {
    return 0;
  }
  if (memcmp(&buffer[i + size], mm_footer, strlen(mm_footer)) == 0)
    size += 48;
  else
    size += 0x80;
  return (size);
}


x86 assembly (clang, -O0):
<search_MMT>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xec1(%rip),%ax
mov    %ax,-0x1a(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xeb0(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x14(%rbp),%eax
add    $0xa,%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jbe    11a6 <search_MMT+0x86>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
lea    -0x22(%rbp),%rsi
xor    %eax,%eax
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11d6 <search_MMT+0xb6>
movl   $0x100,-0x44(%rbp)
jmp    126b <search_MMT+0x14b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
lea    0xe44(%rip),%rsi
xor    %eax,%eax
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1266 <search_MMT+0x146>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1266 <search_MMT+0x146>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
lea    0xdf6(%rip),%rsi
xor    %eax,%eax
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1266 <search_MMT+0x146>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
jmp    126b <search_MMT+0x14b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
add    -0x44(%rbp),%edx
add    $0x5,%edx
mov    %edx,%edx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
add    -0x44(%rbp),%edx
add    $0x6,%edx
mov    %edx,%edx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
add    -0x44(%rbp),%edx
add    $0x7,%edx
mov    %edx,%edx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
add    $0x8,%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,%eax
add    $0xe,%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jbe    12f9 <search_MMT+0x1d9>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,%eax
add    %rax,%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    $0xe,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     132e <search_MMT+0x20e>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
mov    -0x44(%rbp),%eax
add    $0x104,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x44(%rbp)
mov    -0x14(%rbp),%eax
add    -0x44(%rbp),%eax
add    $0x1fc4,%eax
mov    %eax,%eax
add    $0x1,%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jbe    136b <search_MMT+0x24b>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1ebc,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     13f5 <search_MMT+0x2d5>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1ebc,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1405 <search_MMT+0x2e5>
mov    -0x44(%rbp),%eax
add    $0x1ebc,%eax
mov    %eax,-0x44(%rbp)
jmp    1624 <search_MMT+0x504>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1f00,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1495 <search_MMT+0x375>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1f00,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    14a5 <search_MMT+0x385>
mov    -0x44(%rbp),%eax
add    $0x1f00,%eax
mov    %eax,-0x44(%rbp)
jmp    161f <search_MMT+0x4ff>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1f44,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x98(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1547 <search_MMT+0x427>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1f44,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0xa8(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1557 <search_MMT+0x437>
mov    -0x44(%rbp),%eax
add    $0x1f44,%eax
mov    %eax,-0x44(%rbp)
jmp    161a <search_MMT+0x4fa>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1fc4,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0xb8(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     15f9 <search_MMT+0x4d9>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    $0x1fc4,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0xc8(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1609 <search_MMT+0x4e9>
mov    -0x44(%rbp),%eax
add    $0x1fc4,%eax
mov    %eax,-0x44(%rbp)
jmp    1615 <search_MMT+0x4f5>
movl   $0x0,-0x4(%rbp)
jmp    168e <search_MMT+0x56e>
jmp    161a <search_MMT+0x4fa>
jmp    161f <search_MMT+0x4ff>
jmp    1624 <search_MMT+0x504>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0xd8(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    167d <search_MMT+0x55d>
mov    -0x44(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x44(%rbp)
jmp    1688 <search_MMT+0x568>
mov    -0x44(%rbp),%eax
add    $0x80,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_MMT>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movabs $0x3534363337323831,%rax
36 34 35
mov    %rax,0x10(%rsp)
movw   $0x0,0x18(%rsp)
movabs $0x353436333732,%rax
mov    %rax,0x2e(%rsp)
movabs $0x3732383100000000,%rax
38 32 37
mov    %rax,0x28(%rsp)
mov    %esi,%ebp
lea    0xa(%rbp),%rax
mov    %edx,%r14d
xor    %ebx,%ebx
cmp    %r14,%rax
ja     1476 <search_MMT+0x356>
mov    %edx,%r15d
mov    %esi,%r13d
mov    %rdi,(%rsp)
add    %rdi,%rbp
xor    %r12d,%r12d
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
je     120d <search_MMT+0xed>
lea    0xe8a(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
mov    (%rsp),%rdx
je     1217 <search_MMT+0xf7>
lea    0xe70(%rip),%rsi
xor    %r12d,%r12d
mov    %rbp,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    (%rsp),%rdx
test   %rax,%rax
je     1217 <search_MMT+0xf7>
lea    0xe53(%rip),%rsi
xor    %r12d,%r12d
mov    %rbp,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    (%rsp),%rdx
mov    $0x0,%ebx
test   %rax,%rax
jne    1476 <search_MMT+0x356>
jmp    1217 <search_MMT+0xf7>
mov    $0x100,%r12d
mov    (%rsp),%rdx
lea    (%r12,%r13,1),%eax
add    $0x4,%eax
movzbl (%rdx,%rax,1),%eax
lea    (%r12,%r13,1),%ecx
add    $0x5,%ecx
movzbl (%rdx,%rcx,1),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
lea    (%r12,%r13,1),%eax
add    $0x6,%eax
movzbl (%rdx,%rax,1),%eax
shl    $0x10,%eax
or     %ecx,%eax
lea    (%r12,%r13,1),%ecx
add    $0x7,%ecx
movzbl (%rdx,%rcx,1),%ecx
shl    $0x18,%ecx
or     %eax,%ecx
or     $0x8,%r12d
add    %ecx,%r12d
lea    (%r12,%r13,1),%ecx
lea    0xe(%rcx),%rax
mov    $0x0,%ebx
cmp    %r14,%rax
ja     1476 <search_MMT+0x356>
mov    %rdx,%rbp
mov    %rcx,%r14
lea    (%rdx,%rcx,1),%rdi
xor    %ebx,%ebx
lea    0x28(%rsp),%rsi
mov    $0xe,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1476 <search_MMT+0x356>
lea    0x20dc(%r14),%eax
mov    %rax,0x20(%rsp)
cmp    %r15d,%eax
jae    1476 <search_MMT+0x356>
mov    %r14,0x8(%rsp)
lea    0x1fd4(%r14),%ebx
add    %rbp,%rbx
lea    0xd58(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    $0x1fd4,%r15d
test   %rax,%rax
je     1435 <search_MMT+0x315>
lea    0xd3f(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
mov    (%rsp),%rcx
mov    0x8(%rsp),%rax
je     1439 <search_MMT+0x319>
lea    0x2018(%rax),%ebx
add    %rcx,%rbx
lea    0xcf2(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    $0x2018,%r15d
test   %rax,%rax
je     1435 <search_MMT+0x315>
lea    0xcd9(%rip),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
mov    (%rsp),%rcx
mov    0x8(%rsp),%rbp
je     1439 <search_MMT+0x319>
add    $0x205c,%ebp
add    %rcx,%rbp
lea    0xc8c(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    $0x205c,%r15d
test   %rax,%rax
je     1435 <search_MMT+0x315>
lea    0xc73(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
mov    (%rsp),%rcx
je     1439 <search_MMT+0x319>
mov    0x20(%rsp),%rbp
add    %rcx,%rbp
lea    0xc30(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
mov    $0x20dc,%r15d
test   %rax,%rax
je     1435 <search_MMT+0x315>
lea    0xc19(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
mov    (%rsp),%rcx
jne    1476 <search_MMT+0x356>
jmp    1439 <search_MMT+0x319>
mov    (%rsp),%rcx
add    %r12d,%r13d
add    %r15d,%r13d
add    %r13,%rcx
lea    0xbcf(%rip),%rbx
mov    %rcx,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <memcmp@plt>
test   %rax,%rax
lea    0x30(%r12,%r15,1),%eax
lea    0x80(%r12,%r15,1),%ebx
cmove  %eax,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.search_MMT.mm_header = [10 x i8] c"18273645\00\00"
@__const.search_MMT.mm_pad_version_info = [14 x i8] c"\00\00\00\0018273645\00\00"
@.str = [20 x i8] c"Brava Software Inc.\00"
@.str.1 = [4 x i8] c"TAG\00"
@.str.2 = [5 x i8] c" \00"
@.str.3 = [5 x i8] c"bmp \00"
@.str.4 = [5 x i8] c"jpg \00"
define i32 @search_MMT(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca [14 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%14 = bitcast [10 x i8]* %8 to i8*
%15 = bitcast [14 x i8]* %9 to i8*
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11
store i32 0, i32* %12
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = add i64 %17, 10
%19 = load i32, i32* %7
%20 = zext i32 %19 to i64
%21 = icmp ugt i64 %18, %20
br i1 %21, label %22, label %23
22: ; preds = %3
store i32 0, i32* %4
br label %283
23: ; preds = %3
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%29 = call i64 (i8*, ...) @memcmp(i8* %27, i8* %28, i64 10)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 256, i32* %12
br label %61
32: ; preds = %23
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = load i32, i32* %12
%36 = add i32 %34, %35
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = call i64 (i8*, ...) @memcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %60
41: ; preds = %32
%42 = load i8*, i8** %5
%43 = load i32, i32* %6
%44 = load i32, i32* %12
%45 = add i32 %43, %44
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %42, i64 %46
%48 = call i64 (i8*, ...) @memcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %41
%51 = load i8*, i8** %5
%52 = load i32, i32* %6
%53 = load i32, i32* %12
%54 = add i32 %52, %53
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
%57 = call i64 (i8*, ...) @memcmp(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %50
store i32 0, i32* %4
br label %283
60: ; preds = %50, %41, %32
br label %61
61: ; preds = %60, %31
%62 = load i8*, i8** %5
%63 = load i32, i32* %6
%64 = load i32, i32* %12
%65 = add i32 %63, %64
%66 = add i32 %65, 4
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %62, i64 %67
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = load i8*, i8** %5
%72 = load i32, i32* %6
%73 = load i32, i32* %12
%74 = add i32 %72, %73
%75 = add i32 %74, 5
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %71, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = shl i32 %79, 8
%81 = add nsw i32 %70, %80
%82 = load i8*, i8** %5
%83 = load i32, i32* %6
%84 = load i32, i32* %12
%85 = add i32 %83, %84
%86 = add i32 %85, 6
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %82, i64 %87
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = shl i32 %90, 16
%92 = add nsw i32 %81, %91
%93 = load i8*, i8** %5
%94 = load i32, i32* %6
%95 = load i32, i32* %12
%96 = add i32 %94, %95
%97 = add i32 %96, 7
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %93, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = shl i32 %101, 24
%103 = add nsw i32 %92, %102
store i32 %103, i32* %13
%104 = load i32, i32* %13
%105 = add i32 8, %104
%106 = load i32, i32* %12
%107 = add i32 %106, %105
store i32 %107, i32* %12
%108 = load i32, i32* %6
%109 = load i32, i32* %12
%110 = add i32 %108, %109
%111 = zext i32 %110 to i64
%112 = add i64 %111, 14
%113 = load i32, i32* %7
%114 = zext i32 %113 to i64
%115 = icmp ugt i64 %112, %114
br i1 %115, label %116, label %117
116: ; preds = %61
store i32 0, i32* %4
br label %283
117: ; preds = %61
%118 = load i8*, i8** %5
%119 = load i32, i32* %6
%120 = load i32, i32* %12
%121 = add i32 %119, %120
%122 = zext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %118, i64 %122
%124 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%125 = call i64 (i8*, ...) @memcmp(i8* %123, i8* %124, i64 14)
%126 = icmp ne i64 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %117
store i32 0, i32* %4
br label %283
128: ; preds = %117
%129 = load i32, i32* %12
%130 = add i32 %129, 260
store i32 %130, i32* %12
%131 = load i32, i32* %12
%132 = add i32 %131, 20
store i32 %132, i32* %12
%133 = load i32, i32* %6
%134 = load i32, i32* %12
%135 = add i32 %133, %134
%136 = add i32 %135, 8132
%137 = zext i32 %136 to i64
%138 = add i64 %137, 1
%139 = load i32, i32* %7
%140 = zext i32 %139 to i64
%141 = icmp ugt i64 %138, %140
br i1 %141, label %142, label %143
142: ; preds = %128
store i32 0, i32* %4
br label %283
143: ; preds = %128
%144 = load i8*, i8** %5
%145 = load i32, i32* %6
%146 = load i32, i32* %12
%147 = add i32 %145, %146
%148 = add i32 %147, 7868
%149 = zext i32 %148 to i64
%150 = getelementptr inbounds i8, i8* %144, i64 %149
%151 = load i8*, i8** %10
%152 = load i8*, i8** %10
%153 = call i32 @strlen(i8* %152)
%154 = call i64 (i8*, ...) @memcmp(i8* %150, i8* %151, i32 %153)
%155 = icmp eq i64 %154, 0
br i1 %155, label %169, label %156
156: ; preds = %143
%157 = load i8*, i8** %5
%158 = load i32, i32* %6
%159 = load i32, i32* %12
%160 = add i32 %158, %159
%161 = add i32 %160, 7868
%162 = zext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %157, i64 %162
%164 = load i8*, i8** %11
%165 = load i8*, i8** %11
%166 = call i32 @strlen(i8* %165)
%167 = call i64 (i8*, ...) @memcmp(i8* %163, i8* %164, i32 %166)
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %172
169: ; preds = %156, %143
%170 = load i32, i32* %12
%171 = add i32 %170, 7868
store i32 %171, i32* %12
br label %263
172: ; preds = %156
%173 = load i8*, i8** %5
%174 = load i32, i32* %6
%175 = load i32, i32* %12
%176 = add i32 %174, %175
%177 = add i32 %176, 7936
%178 = zext i32 %177 to i64
%179 = getelementptr inbounds i8, i8* %173, i64 %178
%180 = load i8*, i8** %10
%181 = load i8*, i8** %10
%182 = call i32 @strlen(i8* %181)
%183 = call i64 (i8*, ...) @memcmp(i8* %179, i8* %180, i32 %182)
%184 = icmp eq i64 %183, 0
br i1 %184, label %198, label %185
185: ; preds = %172
%186 = load i8*, i8** %5
%187 = load i32, i32* %6
%188 = load i32, i32* %12
%189 = add i32 %187, %188
%190 = add i32 %189, 7936
%191 = zext i32 %190 to i64
%192 = getelementptr inbounds i8, i8* %186, i64 %191
%193 = load i8*, i8** %11
%194 = load i8*, i8** %11
%195 = call i32 @strlen(i8* %194)
%196 = call i64 (i8*, ...) @memcmp(i8* %192, i8* %193, i32 %195)
%197 = icmp eq i64 %196, 0
br i1 %197, label %198, label %201
198: ; preds = %185, %172
%199 = load i32, i32* %12
%200 = add i32 %199, 7936
store i32 %200, i32* %12
br label %262
201: ; preds = %185
%202 = load i8*, i8** %5
%203 = load i32, i32* %6
%204 = load i32, i32* %12
%205 = add i32 %203, %204
%206 = add i32 %205, 8004
%207 = zext i32 %206 to i64
%208 = getelementptr inbounds i8, i8* %202, i64 %207
%209 = load i8*, i8** %10
%210 = load i8*, i8** %10
%211 = call i32 @strlen(i8* %210)
%212 = call i64 (i8*, ...) @memcmp(i8* %208, i8* %209, i32 %211)
%213 = icmp eq i64 %212, 0
br i1 %213, label %227, label %214
214: ; preds = %201
%215 = load i8*, i8** %5
%216 = load i32, i32* %6
%217 = load i32, i32* %12
%218 = add i32 %216, %217
%219 = add i32 %218, 8004
%220 = zext i32 %219 to i64
%221 = getelementptr inbounds i8, i8* %215, i64 %220
%222 = load i8*, i8** %11
%223 = load i8*, i8** %11
%224 = call i32 @strlen(i8* %223)
%225 = call i64 (i8*, ...) @memcmp(i8* %221, i8* %222, i32 %224)
%226 = icmp eq i64 %225, 0
br i1 %226, label %227, label %230
227: ; preds = %214, %201
%228 = load i32, i32* %12
%229 = add i32 %228, 8004
store i32 %229, i32* %12
br label %261
230: ; preds = %214
%231 = load i8*, i8** %5
%232 = load i32, i32* %6
%233 = load i32, i32* %12
%234 = add i32 %232, %233
%235 = add i32 %234, 8132
%236 = zext i32 %235 to i64
%237 = getelementptr inbounds i8, i8* %231, i64 %236
%238 = load i8*, i8** %10
%239 = load i8*, i8** %10
%240 = call i32 @strlen(i8* %239)
%241 = call i64 (i8*, ...) @memcmp(i8* %237, i8* %238, i32 %240)
%242 = icmp eq i64 %241, 0
br i1 %242, label %256, label %243
243: ; preds = %230
%244 = load i8*, i8** %5
%245 = load i32, i32* %6
%246 = load i32, i32* %12
%247 = add i32 %245, %246
%248 = add i32 %247, 8132
%249 = zext i32 %248 to i64
%250 = getelementptr inbounds i8, i8* %244, i64 %249
%251 = load i8*, i8** %11
%252 = load i8*, i8** %11
%253 = call i32 @strlen(i8* %252)
%254 = call i64 (i8*, ...) @memcmp(i8* %250, i8* %251, i32 %253)
%255 = icmp eq i64 %254, 0
br i1 %255, label %256, label %259
256: ; preds = %243, %230
%257 = load i32, i32* %12
%258 = add i32 %257, 8132
store i32 %258, i32* %12
br label %260
259: ; preds = %243
store i32 0, i32* %4
br label %283
260: ; preds = %256
br label %261
261: ; preds = %260, %227
br label %262
262: ; preds = %261, %198
br label %263
263: ; preds = %262, %169
%264 = load i8*, i8** %5
%265 = load i32, i32* %6
%266 = load i32, i32* %12
%267 = add i32 %265, %266
%268 = zext i32 %267 to i64
%269 = getelementptr inbounds i8, i8* %264, i64 %268
%270 = load i8*, i8** %10
%271 = load i8*, i8** %10
%272 = call i32 @strlen(i8* %271)
%273 = call i64 (i8*, ...) @memcmp(i8* %269, i8* %270, i32 %272)
%274 = icmp eq i64 %273, 0
br i1 %274, label %275, label %278
275: ; preds = %263
%276 = load i32, i32* %12
%277 = add i32 %276, 48
store i32 %277, i32* %12
br label %281
278: ; preds = %263
%279 = load i32, i32* %12
%280 = add i32 %279, 128
store i32 %280, i32* %12
br label %281
281: ; preds = %278, %275
%282 = load i32, i32* %12
store i32 %282, i32* %4
br label %283
283: ; preds = %281, %259, %142, %127, %116, %59, %22
%284 = load i32, i32* %4
ret i32 %284
}

LLVM IR (-O2):
@__const.search_MMT.mm_header = [10 x i8] c"18273645\00\00"
@__const.search_MMT.mm_pad_version_info = [14 x i8] c"\00\00\00\0018273645\00\00"
@.str = [20 x i8] c"Brava Software Inc.\00"
@.str.1 = [4 x i8] c"TAG\00"
@.str.2 = [5 x i8] c" \00"
@.str.3 = [5 x i8] c"bmp \00"
@.str.4 = [5 x i8] c"jpg \00"
define i32 @search_MMT(i8* %0, i32 %1, i32 %2) {
%4 = alloca [10 x i8]
%5 = alloca [14 x i8]
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%8 = zext i32 %1 to i64
%9 = add nuw nsw i64 %8, 10
%10 = zext i32 %2 to i64
%11 = icmp ugt i64 %9, %10
br i1 %11, label %121, label %12
12: ; preds = %3
%13 = getelementptr inbounds i8, i8* %0, i64 %8
%14 = call i64 (i8*, ...) @memcmp(i8* %13, i8* %6, i64 10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %12
%17 = call i64 (i8*, ...) @memcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = call i64 (i8*, ...) @memcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i64 (i8*, ...) @memcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %121
25: ; preds = %12, %16, %19, %22
%26 = phi i32 [ 0, %22 ], [ 0, %19 ], [ 0, %16 ], [ 256, %12 ]
%27 = add i32 %26, %1
%28 = add i32 %27, 4
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = add i32 %27, 5
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = shl nuw nsw i32 %37, 8
%39 = or i32 %38, %32
%40 = add i32 %27, 6
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %0, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = shl nuw nsw i32 %44, 16
%46 = or i32 %39, %45
%47 = add i32 %27, 7
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %0, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = shl nuw i32 %51, 24
%53 = or i32 %46, %52
%54 = or i32 %26, 8
%55 = add i32 %54, %53
%56 = add i32 %55, %1
%57 = zext i32 %56 to i64
%58 = add nuw nsw i64 %57, 14
%59 = icmp ugt i64 %58, %10
br i1 %59, label %121, label %60
60: ; preds = %25
%61 = getelementptr inbounds i8, i8* %0, i64 %57
%62 = call i64 (i8*, ...) @memcmp(i8* %61, i8* %7, i64 14)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %121
64: ; preds = %60
%65 = add i32 %56, 8412
%66 = zext i32 %65 to i64
%67 = icmp ult i32 %65, %2
br i1 %67, label %68, label %121
68: ; preds = %64
%69 = add i32 %56, 8148
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %0, i64 %70
%72 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%73 = call i64 (i8*, ...) @memcmp(i8* %71, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %110, label %75
75: ; preds = %68
%76 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%77 = call i64 (i8*, ...) @memcmp(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %110, label %79
79: ; preds = %75
%80 = add i32 %56, 8216
%81 = zext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %0, i64 %81
%83 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%84 = call i64 (i8*, ...) @memcmp(i8* %82, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %83)
%85 = icmp eq i64 %84, 0
br i1 %85, label %110, label %86
86: ; preds = %79
%87 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%88 = call i64 (i8*, ...) @memcmp(i8* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %110, label %90
90: ; preds = %86
%91 = add i32 %56, 8284
%92 = zext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %0, i64 %92
%94 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%95 = call i64 (i8*, ...) @memcmp(i8* %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %110, label %97
97: ; preds = %90
%98 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%99 = call i64 (i8*, ...) @memcmp(i8* %93, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %98)
%100 = icmp eq i64 %99, 0
br i1 %100, label %110, label %101
101: ; preds = %97
%102 = getelementptr inbounds i8, i8* %0, i64 %66
%103 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%104 = call i64 (i8*, ...) @memcmp(i8* %102, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %103)
%105 = icmp eq i64 %104, 0
br i1 %105, label %110, label %106
106: ; preds = %101
%107 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%108 = call i64 (i8*, ...) @memcmp(i8* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %107)
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %121
110: ; preds = %101, %106, %90, %97, %79, %86, %68, %75
%111 = phi i32 [ 8148, %75 ], [ 8148, %68 ], [ 8216, %86 ], [ 8216, %79 ], [ 8284, %97 ], [ 8284, %90 ], [ 8412, %106 ], [ 8412, %101 ]
%112 = add i32 %55, %111
%113 = add i32 %112, %1
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %0, i64 %114
%116 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%117 = call i64 (i8*, ...) @memcmp(i8* %115, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %116)
%118 = icmp eq i64 %117, 0
%119 = select i1 %118, i32 48, i32 128
%120 = add i32 %119, %112
br label %121
121: ; preds = %106, %64, %60, %25, %22, %3, %110
%122 = phi i32 [ %120, %110 ], [ 0, %3 ], [ 0, %22 ], [ 0, %25 ], [ 0, %60 ], [ 0, %64 ], [ 0, %106 ]
ret i32 %122
}