#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 rtattr {
  int dummy;
};
struct nlmsghdr {
  int /*<<< orphan*/ nlmsg_len;
};

/* Variables and functions */
int NLMSG_ALIGN(int /*<<< orphan*/);
int /*<<< orphan*/ add_rtattr(struct nlmsghdr *, int, int /*<<< orphan*/ *,
                              int /*<<< orphan*/);
struct rtattr *add_rtattr_nest(struct nlmsghdr *n, int type) {
  struct rtattr *nest =
      ((struct rtattr *)(((void *)(n)) + NLMSG_ALIGN((n)->nlmsg_len)));
  add_rtattr(n, type, NULL, 0);
  return nest;
}


x86 assembly (clang, -O0):
<add_rtattr_nest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <NLMSG_ALIGN@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <add_rtattr@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_rtattr_nest>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <NLMSG_ALIGN@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <add_rtattr@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.rtattr = type { i32 }
%struct.nlmsghdr = type { i32 }
define %struct.rtattr* @add_rtattr_nest(%struct.nlmsghdr* %0, i32 %1) {
%3 = alloca %struct.nlmsghdr*
%4 = alloca i32
%5 = alloca %struct.rtattr*
store %struct.nlmsghdr* %0, %struct.nlmsghdr** %3
store i32 %1, i32* %4
%6 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%7 = bitcast %struct.nlmsghdr* %6 to i8*
%8 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%9 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @NLMSG_ALIGN(i32 %10)
%12 = sext i32 %11 to i64
%13 = getelementptr i8, i8* %7, i64 %12
%14 = bitcast i8* %13 to %struct.rtattr*
store %struct.rtattr* %14, %struct.rtattr** %5
%15 = load %struct.nlmsghdr*, %struct.nlmsghdr** %3
%16 = load i32, i32* %4
%17 = call i32 @add_rtattr(%struct.nlmsghdr* %15, i32 %16, i32* null, i32 0)
%18 = load %struct.rtattr*, %struct.rtattr** %5
ret %struct.rtattr* %18
}

LLVM IR (-O2):
%struct.rtattr = type { i32 }
%struct.nlmsghdr = type { i32 }
define %struct.rtattr* @add_rtattr_nest(%struct.nlmsghdr* %0, i32 %1) {
%3 = bitcast %struct.nlmsghdr* %0 to i8*
%4 = getelementptr inbounds %struct.nlmsghdr, %struct.nlmsghdr* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i32 @NLMSG_ALIGN(i32 %5)
%7 = sext i32 %6 to i64
%8 = getelementptr i8, i8* %3, i64 %7
%9 = bitcast i8* %8 to %struct.rtattr*
%10 = tail call i32 @add_rtattr(%struct.nlmsghdr* %0, i32 %1, i32* null, i32 0)
ret %struct.rtattr* %9
}