#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*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ read_defect_data_10_hdr_is_valid(int /*<<< orphan*/ *,
                                                    unsigned int);
scalar_t__ read_defect_data_10_len(int /*<<< orphan*/ *);
bool read_defect_data_10_is_valid(uint8_t *data, unsigned data_len) {
  if (!read_defect_data_10_hdr_is_valid(data, data_len))
    return false;
  if ((unsigned)read_defect_data_10_len(data) + 4 < data_len)
    return false;
  return true;
}


x86 assembly (clang, -O0):
<read_defect_data_10_is_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <read_defect_data_10_hdr_is_valid@plt>
cmp    $0x0,%eax
jne    1150 <read_defect_data_10_is_valid+0x30>
movl   $0x0,-0x4(%rbp)
jmp    1178 <read_defect_data_10_is_valid+0x58>
mov    -0x10(%rbp),%rdi
call   1040 <read_defect_data_10_len@plt>
add    $0x4,%eax
cmp    -0x14(%rbp),%eax
jae    1171 <read_defect_data_10_is_valid+0x51>
movl   $0x0,-0x4(%rbp)
jmp    1178 <read_defect_data_10_is_valid+0x58>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_defect_data_10_is_valid>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <read_defect_data_10_hdr_is_valid@plt>
test   %eax,%eax
je     1148 <read_defect_data_10_is_valid+0x28>
mov    %rbx,%rdi
call   1040 <read_defect_data_10_len@plt>
mov    %rax,%rcx
add    $0x4,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
setae  %al
jmp    114a <read_defect_data_10_is_valid+0x2a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_defect_data_10_is_valid(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32*, i32** %4
%7 = load i32, i32* %5
%8 = call i32 @read_defect_data_10_hdr_is_valid(i32* %6, i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %2
store i32 0, i32* %3
br label %20
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = call i64 @read_defect_data_10_len(i32* %12)
%14 = trunc i64 %13 to i32
%15 = add i32 %14, 4
%16 = load i32, i32* %5
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 0, i32* %3
br label %20
19: ; preds = %11
store i32 1, i32* %3
br label %20
20: ; preds = %19, %18, %10
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
define i32 @read_defect_data_10_is_valid(i32* %0, i32 %1) {
%3 = tail call i32 @read_defect_data_10_hdr_is_valid(i32* %0, i32 %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i64 @read_defect_data_10_len(i32* %0)
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 4
%9 = icmp uge i32 %8, %1
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %5, %2
%12 = phi i32 [ 0, %2 ], [ %10, %5 ]
ret i32 %12
}