#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;
typedef scalar_t__ uint64_t;
typedef scalar_t__ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct file_entry {
  int dummy;
};

/* Variables and functions */
struct file_entry *_decode_file_entry(int /*<<< orphan*/ const *, size_t,
                                      int /*<<< orphan*/, scalar_t__,
                                      scalar_t__);
scalar_t__ _get_u32(int /*<<< orphan*/ const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
struct file_entry *decode_file_entry(const uint8_t *p, size_t size,
                                     uint16_t partition) {
  uint32_t l_ea, l_ad;
  l_ea = _get_u32(p + 168);
  l_ad = _get_u32(p + 172);
  if ((uint64_t)l_ea + (uint64_t)l_ad + (uint64_t)176 >= (uint64_t)1 << 32) {
    fprintf(stderr, "ecma: "
                    "invalid file entry\n");
    return NULL;
  }
  return _decode_file_entry(p, size, partition, l_ad, 176 + l_ea);
}


x86 assembly (clang, -O0):
<decode_file_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2a0,%rdi
call   1040 <_get_u32@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2b0,%rdi
call   1040 <_get_u32@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
add    $0xb0,%rax
movabs $0x100000000,%rcx
cmp    %rcx,%rax
jl     11ae <decode_file_entry+0x7e>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d1 <decode_file_entry+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
add    $0xb0,%r8
call   1050 <_decode_file_entry@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_file_entry>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
add    $0x2a0,%rdi
call   1040 <_get_u32@plt>
mov    %rax,%rbx
lea    0x2b0(%rbp),%rdi
call   1040 <_get_u32@plt>
lea    (%rax,%rbx,1),%rcx
mov    $0xffffff50,%edx
cmp    %rdx,%rcx
jl     118b <decode_file_entry+0x5b>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xb0,%rbx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %rax,%rcx
mov    %rbx,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <_decode_file_entry@plt>

LLVM IR (-O0):
%struct.file_entry = type { i32 }
@stderr = global i32 0
@.str = [26 x i8] c"ecma: invalid file entry\0A\00"
define %struct.file_entry* @decode_file_entry(i32* %0, i64 %1, i32 %2) {
%4 = alloca %struct.file_entry*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 168
%12 = call i64 @_get_u32(i32* %11)
store i64 %12, i64* %8
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 172
%15 = call i64 @_get_u32(i32* %14)
store i64 %15, i64* %9
%16 = load i64, i64* %8
%17 = load i64, i64* %9
%18 = add nsw i64 %16, %17
%19 = add nsw i64 %18, 176
%20 = icmp sge i64 %19, 4294967296
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store %struct.file_entry* null, %struct.file_entry** %4
br label %32
24: ; preds = %3
%25 = load i32*, i32** %5
%26 = load i64, i64* %6
%27 = load i32, i32* %7
%28 = load i64, i64* %9
%29 = load i64, i64* %8
%30 = add nsw i64 176, %29
%31 = call %struct.file_entry* @_decode_file_entry(i32* %25, i64 %26, i32 %27, i64 %28, i64 %30)
store %struct.file_entry* %31, %struct.file_entry** %4
br label %32
32: ; preds = %24, %21
%33 = load %struct.file_entry*, %struct.file_entry** %4
ret %struct.file_entry* %33
}

LLVM IR (-O2):
%struct.file_entry = type { i32 }
@stderr = global i32 0
@.str = [26 x i8] c"ecma: invalid file entry\0A\00"
define %struct.file_entry* @decode_file_entry(i32* %0, i64 %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 168
%5 = tail call i64 @_get_u32(i32* %4)
%6 = getelementptr inbounds i32, i32* %0, i64 172
%7 = tail call i64 @_get_u32(i32* %6)
%8 = add nsw i64 %7, %5
%9 = icmp sgt i64 %8, 4294967119
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %3
%14 = add nsw i64 %5, 176
%15 = tail call %struct.file_entry* @_decode_file_entry(i32* %0, i64 %1, i32 %2, i64 %7, i64 %14)
br label %16
16: ; preds = %13, %10
%17 = phi %struct.file_entry* [ null, %10 ], [ %15, %13 ]
ret %struct.file_entry* %17
}