#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 dummy;
};

/* Variables and functions */
struct rtattr *rtattr_hdr(struct nlmsghdr *);
scalar_t__ rtattr_pack(struct nlmsghdr *, size_t, unsigned short, void const *,
                       size_t);
struct rtattr *_rtattr_begin(struct nlmsghdr *nh, size_t req_sz,
                             unsigned short rta_type, const void *payload,
                             size_t size) {
  struct rtattr *ret = rtattr_hdr(nh);
  if (rtattr_pack(nh, req_sz, rta_type, payload, size))
    return 0;
  return ret;
}


x86 assembly (clang, -O0):
<_rtattr_begin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dx,%ax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rtattr_hdr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1a(%rbp),%ax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
movzwl %ax,%edx
call   1040 <rtattr_pack@plt>
cmp    $0x0,%rax
je     117f <_rtattr_begin+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    1187 <_rtattr_begin+0x67>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_rtattr_begin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <rtattr_hdr@plt>
mov    %rax,%r13
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <rtattr_pack@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmove  %r13,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rtattr = type { i32 }
%struct.nlmsghdr = type { i32 }
define %struct.rtattr* @_rtattr_begin(%struct.nlmsghdr* %0, i64 %1, i16 zeroext %2, i8* %3, i64 %4) {
%6 = alloca %struct.rtattr*
%7 = alloca %struct.nlmsghdr*
%8 = alloca i64
%9 = alloca i16
%10 = alloca i8*
%11 = alloca i64
%12 = alloca %struct.rtattr*
store %struct.nlmsghdr* %0, %struct.nlmsghdr** %7
store i64 %1, i64* %8
store i16 %2, i16* %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%13 = load %struct.nlmsghdr*, %struct.nlmsghdr** %7
%14 = call %struct.rtattr* @rtattr_hdr(%struct.nlmsghdr* %13)
store %struct.rtattr* %14, %struct.rtattr** %12
%15 = load %struct.nlmsghdr*, %struct.nlmsghdr** %7
%16 = load i64, i64* %8
%17 = load i16, i16* %9
%18 = load i8*, i8** %10
%19 = load i64, i64* %11
%20 = call i64 @rtattr_pack(%struct.nlmsghdr* %15, i64 %16, i16 zeroext %17, i8* %18, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %5
store %struct.rtattr* null, %struct.rtattr** %6
br label %25
23: ; preds = %5
%24 = load %struct.rtattr*, %struct.rtattr** %12
store %struct.rtattr* %24, %struct.rtattr** %6
br label %25
25: ; preds = %23, %22
%26 = load %struct.rtattr*, %struct.rtattr** %6
ret %struct.rtattr* %26
}

LLVM IR (-O2):
%struct.rtattr = type { i32 }
%struct.nlmsghdr = type { i32 }
define %struct.rtattr* @_rtattr_begin(%struct.nlmsghdr* %0, i64 %1, i16 zeroext %2, i8* %3, i64 %4) {
%6 = tail call %struct.rtattr* @rtattr_hdr(%struct.nlmsghdr* %0)
%7 = tail call i64 @rtattr_pack(%struct.nlmsghdr* %0, i64 %1, i16 zeroext %2, i8* %3, i64 %4)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, %struct.rtattr* %6, %struct.rtattr* null
ret %struct.rtattr* %9
}