#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 */
struct nlattr {
  int nla_len;
};

/* Variables and functions */
int nla_attr_size(int /*<<< orphan*/);
scalar_t__ nla_data(struct nlattr const *);
int nla_parse(struct nlattr **, int, struct nlattr *, int);
int nla_parse_nested(struct nlattr *arr[], int max, const struct nlattr *nla) {
  struct nlattr *_nla = (struct nlattr *)nla_data(nla);
  int len = nla->nla_len - nla_attr_size(0);
  return nla_parse(arr, max, _nla, len);
}


x86 assembly (clang, -O0):
<nla_parse_nested>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <nla_data@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
xor    %edi,%edi
call   1050 <nla_attr_size@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <nla_parse@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nla_parse_nested>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <nla_data@plt>
mov    %rax,%rbp
mov    (%rbx),%ebx
xor    %edi,%edi
call   1050 <nla_attr_size@plt>
sub    %eax,%ebx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <nla_parse@plt>

LLVM IR (-O0):
%struct.nlattr = type { i32 }
define i32 @nla_parse_nested(%struct.nlattr** %0, i32 %1, %struct.nlattr* %2) {
%4 = alloca %struct.nlattr**
%5 = alloca i32
%6 = alloca %struct.nlattr*
%7 = alloca %struct.nlattr*
%8 = alloca i32
store %struct.nlattr** %0, %struct.nlattr*** %4
store i32 %1, i32* %5
store %struct.nlattr* %2, %struct.nlattr** %6
%9 = load %struct.nlattr*, %struct.nlattr** %6
%10 = call i64 @nla_data(%struct.nlattr* %9)
%11 = inttoptr i64 %10 to %struct.nlattr*
store %struct.nlattr* %11, %struct.nlattr** %7
%12 = load %struct.nlattr*, %struct.nlattr** %6
%13 = getelementptr inbounds %struct.nlattr, %struct.nlattr* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @nla_attr_size(i32 0)
%16 = sub nsw i32 %14, %15
store i32 %16, i32* %8
%17 = load %struct.nlattr**, %struct.nlattr*** %4
%18 = load i32, i32* %5
%19 = load %struct.nlattr*, %struct.nlattr** %7
%20 = load i32, i32* %8
%21 = call i32 @nla_parse(%struct.nlattr** %17, i32 %18, %struct.nlattr* %19, i32 %20)
ret i32 %21
}

LLVM IR (-O2):
%struct.nlattr = type { i32 }
define i32 @nla_parse_nested(%struct.nlattr** %0, i32 %1, %struct.nlattr* %2) {
%4 = tail call i64 @nla_data(%struct.nlattr* %2)
%5 = inttoptr i64 %4 to %struct.nlattr*
%6 = getelementptr inbounds %struct.nlattr, %struct.nlattr* %2, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @nla_attr_size(i32 0)
%9 = sub nsw i32 %7, %8
%10 = tail call i32 @nla_parse(%struct.nlattr** %0, i32 %1, %struct.nlattr* %5, i32 %9)
ret i32 %10
}