#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;
struct sockaddr_nl {
  int dummy;
};
struct msghdr {
  int member_1;
  int member_3;
  int /*<<< orphan*/ member_6;
  int /*<<< orphan*/ member_5;
  int /*<<< orphan*/ *member_4;
  struct iovec *member_2;
  struct sockaddr_nl *member_0;
};
struct iovec {
  size_t member_1;
  int /*<<< orphan*/ *member_0;
};
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ sa;

/* Variables and functions */
int /*<<< orphan*/ recvmsg(int, struct msghdr *, int /*<<< orphan*/);
ssize_t recv_msg(int fd, uint8_t *buffer, size_t maxlen) {
  struct sockaddr_nl sa;
  struct iovec iov = {buffer, maxlen};
  struct msghdr msg = {&sa, sizeof(sa), &iov, 1, NULL, 0, 0};
  return recvmsg(fd, &msg, 0);
}


x86 assembly (clang, -O0):
<recv_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rax
mov    %eax,-0x58(%rbp)
movl   $0x4,-0x54(%rbp)
lea    -0x30(%rbp),%rax
mov    %eax,-0x50(%rbp)
movl   $0x1,-0x4c(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x58(%rbp),%rsi
xor    %edx,%edx
call   1030 <recvmsg@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_msg>:
sub    $0x48,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdx,0x18(%rsp)
lea    0x8(%rsp),%rax
mov    %eax,0x20(%rsp)
movl   $0x4,0x24(%rsp)
lea    0x10(%rsp),%rax
mov    %eax,0x28(%rsp)
movl   $0x1,0x2c(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
lea    0x20(%rsp),%rsi
xor    %edx,%edx
call   1030 <recvmsg@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
%struct.sockaddr_nl = type { i32 }
%struct.iovec = type { i64, i32* }
%struct.msghdr = type { i32, i32, i32, i32, i32*, %struct.iovec*, %struct.sockaddr_nl* }
define i32 @recv_msg(i32 %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca %struct.sockaddr_nl
%8 = alloca %struct.iovec
%9 = alloca %struct.msghdr
store i32 %0, i32* %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = getelementptr inbounds %struct.iovec, %struct.iovec* %8, i32 0, i32 0
%11 = load i32*, i32** %5
%12 = ptrtoint i32* %11 to i64
store i64 %12, i64* %10
%13 = getelementptr inbounds %struct.iovec, %struct.iovec* %8, i32 0, i32 1
%14 = load i64, i64* %6
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %13
%16 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 0
%17 = ptrtoint %struct.sockaddr_nl* %7 to i32
store i32 %17, i32* %16
%18 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 1
store i32 4, i32* %18
%19 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 2
%20 = ptrtoint %struct.iovec* %8 to i32
store i32 %20, i32* %19
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 3
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 4
store i32* null, i32** %22
%23 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 5
store %struct.iovec* null, %struct.iovec** %23
%24 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 6
store %struct.sockaddr_nl* null, %struct.sockaddr_nl** %24
%25 = load i32, i32* %4
%26 = call i32 @recvmsg(i32 %25, %struct.msghdr* %9, i32 0)
ret i32 %26
}

LLVM IR (-O2):
%struct.sockaddr_nl = type { i32 }
%struct.iovec = type { i64, i32* }
%struct.msghdr = type { i32, i32, i32, i32, i32*, %struct.iovec*, %struct.sockaddr_nl* }
define i32 @recv_msg(i32 %0, i32* %1, i64 %2) {
%4 = alloca %struct.sockaddr_nl
%5 = alloca %struct.iovec
%6 = alloca %struct.msghdr
%7 = bitcast %struct.sockaddr_nl* %4 to i8*
%8 = bitcast %struct.iovec* %5 to i8*
%9 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 0, i32 0
%10 = ptrtoint i32* %1 to i64
store i64 %10, i64* %9
%11 = getelementptr inbounds %struct.iovec, %struct.iovec* %5, i64 0, i32 1
%12 = inttoptr i64 %2 to i32*
store i32* %12, i32** %11
%13 = bitcast %struct.msghdr* %6 to i8*
%14 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 0
%15 = ptrtoint %struct.sockaddr_nl* %4 to i64
%16 = trunc i64 %15 to i32
store i32 %16, i32* %14
%17 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 1
store i32 4, i32* %17
%18 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 2
%19 = ptrtoint %struct.iovec* %5 to i64
%20 = trunc i64 %19 to i32
store i32 %20, i32* %18
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 3
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %6, i64 0, i32 4
%23 = bitcast i32** %22 to i8*
%24 = call i32 @recvmsg(i32 %0, %struct.msghdr* %6, i32 0)
ret i32 %24
}