#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__ XCheckNVStructEx(unsigned char *, unsigned long, int /*<<< orphan*/,
                            unsigned long);
scalar_t__ XFindNVOffset(unsigned short, unsigned char *, unsigned long,
                         unsigned long *, unsigned long *, unsigned long);
unsigned long XFindNVOffsetEx(unsigned short wId, unsigned char *lpCode,
                              unsigned long dwCodeSize, unsigned long *dwOffset,
                              unsigned long *dwLength, unsigned long bBigEndian,
                              unsigned long bModule) {
  unsigned long bOK = 0;
  if (XCheckNVStructEx(lpCode, dwCodeSize, 0, bModule)) {
    if (XFindNVOffset(wId, lpCode, dwCodeSize, dwOffset, dwLength, bBigEndian))
      bOK = 1;
  }
  return bOK;
}


x86 assembly (clang, -O0):
<XFindNVOffsetEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %di,%ax
mov    0x10(%rbp),%rdi
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x10(%rbp),%rcx
xor    %edx,%edx
call   1030 <XCheckNVStructEx@plt>
cmp    $0x0,%rax
je     11a3 <XFindNVOffsetEx+0x83>
mov    -0x2(%rbp),%ax
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
movzwl %ax,%edi
call   1040 <XFindNVOffset@plt>
cmp    $0x0,%rax
je     119e <XFindNVOffsetEx+0x7e>
movq   $0x1,-0x38(%rbp)
jmp    11a3 <XFindNVOffsetEx+0x83>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XFindNVOffsetEx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %edi,%r14d
mov    0x40(%rsp),%rcx
xor    %ebx,%ebx
mov    %rsi,%rdi
mov    %rdx,%rsi
xor    %edx,%edx
call   1030 <XCheckNVStructEx@plt>
test   %rax,%rax
je     1178 <XFindNVOffsetEx+0x58>
movzwl %r14w,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    (%rsp),%r9
call   1040 <XFindNVOffset@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @XFindNVOffsetEx(i16 zeroext %0, i8* %1, i64 %2, i64* %3, i64* %4, i64 %5, i64 %6) {
%8 = alloca i16
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i64*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
store i16 %0, i16* %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i64* %3, i64** %11
store i64* %4, i64** %12
store i64 %5, i64* %13
store i64 %6, i64* %14
store i64 0, i64* %15
%16 = load i8*, i8** %9
%17 = load i64, i64* %10
%18 = load i64, i64* %14
%19 = call i64 @XCheckNVStructEx(i8* %16, i64 %17, i32 0, i64 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %7
%22 = load i16, i16* %8
%23 = load i8*, i8** %9
%24 = load i64, i64* %10
%25 = load i64*, i64** %11
%26 = load i64*, i64** %12
%27 = load i64, i64* %13
%28 = call i64 @XFindNVOffset(i16 zeroext %22, i8* %23, i64 %24, i64* %25, i64* %26, i64 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %21
store i64 1, i64* %15
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %7
%33 = load i64, i64* %15
ret i64 %33
}

LLVM IR (-O2):
define i64 @XFindNVOffsetEx(i16 zeroext %0, i8* %1, i64 %2, i64* %3, i64* %4, i64 %5, i64 %6) {
%8 = tail call i64 @XCheckNVStructEx(i8* %1, i64 %2, i32 0, i64 %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @XFindNVOffset(i16 zeroext %0, i8* %1, i64 %2, i64* %3, i64* %4, i64 %5)
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i64
br label %14
14: ; preds = %10, %7
%15 = phi i64 [ 0, %7 ], [ %13, %10 ]
ret i64 %15
}