#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 */
unsigned int get32u(char const *, unsigned int const);
int /*<<< orphan*/ software2ext(char const **, char const *,
                                unsigned int const);
void OLE_parse_software_entry(const char *buffer, const unsigned int size,
                              const unsigned int offset, const char **ext) {
  if (offset >= size - 8) {
    return;
  }
  {
    const unsigned int count = get32u(buffer, offset + 4);
    const unsigned int offset_soft = offset + 8;
    if (count == 0 || count > size) {
      return;
    }
    if (offset_soft + count > size) {
      return;
    }
    software2ext(ext, &buffer[offset_soft], count);
  }
}


x86 assembly (clang, -O0):
<OLE_parse_software_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x8,%ecx
cmp    %ecx,%eax
jb     114c <OLE_parse_software_entry+0x2c>
jmp    11ac <OLE_parse_software_entry+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x4,%esi
call   1040 <get32u@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117d <OLE_parse_software_entry+0x5d>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jbe    1182 <OLE_parse_software_entry+0x62>
jmp    11ac <OLE_parse_software_entry+0x8c>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jbe    1196 <OLE_parse_software_entry+0x76>
jmp    11ac <OLE_parse_software_entry+0x8c>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%eax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <software2ext@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OLE_parse_software_entry>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
lea    -0x8(%r12),%eax
cmp    %edx,%eax
jbe    1177 <OLE_parse_software_entry+0x57>
mov    %rcx,%r14
mov    %edx,%ebx
mov    %rdi,%r15
lea    0x4(%rbx),%esi
call   1040 <get32u@plt>
lea    -0x1(%rax),%ecx
cmp    %r12d,%ecx
jae    1177 <OLE_parse_software_entry+0x57>
lea    (%rax,%rbx,1),%ecx
add    $0x8,%ecx
cmp    %r12d,%ecx
ja     1177 <OLE_parse_software_entry+0x57>
add    $0x8,%ebx
mov    %ebx,%ecx
add    %rcx,%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <software2ext@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @OLE_parse_software_entry(i8* %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = sub i32 %12, 8
%14 = icmp uge i32 %11, %13
br i1 %14, label %15, label %16
15: ; preds = %4
br label %45
16: ; preds = %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = add i32 %18, 4
%20 = call i32 @get32u(i8* %17, i32 %19)
store i32 %20, i32* %9
%21 = load i32, i32* %7
%22 = add i32 %21, 8
store i32 %22, i32* %10
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %16
%26 = load i32, i32* %9
%27 = load i32, i32* %6
%28 = icmp ugt i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25, %16
br label %45
30: ; preds = %25
%31 = load i32, i32* %10
%32 = load i32, i32* %9
%33 = add i32 %31, %32
%34 = load i32, i32* %6
%35 = icmp ugt i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %30
br label %45
37: ; preds = %30
%38 = load i8**, i8*** %8
%39 = load i8*, i8** %5
%40 = load i32, i32* %10
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i32, i32* %9
%44 = call i32 @software2ext(i8** %38, i8* %42, i32 %43)
br label %45
45: ; preds = %37, %36, %29, %15
ret void
}

LLVM IR (-O2):
define void @OLE_parse_software_entry(i8* %0, i32 %1, i32 %2, i8** %3) {
%5 = add i32 %1, -8
%6 = icmp ugt i32 %5, %2
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = add i32 %2, 4
%9 = tail call i32 @get32u(i8* %0, i32 %8)
%10 = add i32 %2, 8
%11 = add i32 %9, -1
%12 = icmp uge i32 %11, %1
%13 = add i32 %9, %10
%14 = icmp ugt i32 %13, %1
%15 = or i1 %12, %14
br i1 %15, label %20, label %16
16: ; preds = %7
%17 = zext i32 %10 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = tail call i32 @software2ext(i8** %3, i8* %18, i32 %9)
br label %20
20: ; preds = %16, %7, %4
ret void
}