#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct TYPE_2__ {
  int *s6_addr;
};
struct in6_flowlabel_req {
  TYPE_1__ flr_dst;
  int /*<<< orphan*/ flr_share;
  int /*<<< orphan*/ flr_flags;
  int /*<<< orphan*/ flr_label;
  int /*<<< orphan*/ flr_action;
};
typedef int /*<<< orphan*/ req;

/* Variables and functions */
int /*<<< orphan*/ IPV6_FL_A_GET;
int /*<<< orphan*/ SOL_IPV6;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int, struct in6_flowlabel_req *,
                      int);
void flowlabel_get(int fd, uint32_t label, uint8_t share, uint16_t flags) {
  struct in6_flowlabel_req req = {
      .flr_action = IPV6_FL_A_GET,
      .flr_label = htonl(label),
      .flr_flags = flags,
      .flr_share = share,
  };
  req.flr_dst.s6_addr[0] = 0xfd;
  req.flr_dst.s6_addr[15] = 0x1;
  if (setsockopt(fd, SOL_IPV6, 32, &req, sizeof(req)))
    error(1, errno, "setsockopt flowlabel get");
}


x86 assembly (clang, -O0):
<flowlabel_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xfd,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x1,0x3c(%rax)
mov    -0x4(%rbp),%edi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edx
lea    -0x28(%rbp),%rcx
mov    $0x18,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
je     11e0 <flowlabel_get+0xa0>
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe25(%rip),%rdx
call   1060 <error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flowlabel_get>:
push   %rax
mov    %esi,%edi
call   1030 <htonl@plt>

LLVM IR (-O0):
%struct.in6_flowlabel_req = type { %struct.TYPE_2__, i32, i32, i32, i32 }
%struct.TYPE_2__ = type { i32* }
@IPV6_FL_A_GET = global i32 0
@SOL_IPV6 = global i32 0
@errno = global i32 0
@.str = [25 x i8] c"setsockopt flowlabel get\00"
define void @flowlabel_get(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.in6_flowlabel_req
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 0
%11 = bitcast %struct.TYPE_2__* %10 to i8*
%12 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 1
%13 = load i32, i32* %7
store i32 %13, i32* %12
%14 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 2
%15 = load i32, i32* %8
store i32 %15, i32* %14
%16 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 3
%17 = load i32, i32* %6
%18 = call i32 @htonl(i32 %17)
store i32 %18, i32* %16
%19 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 4
%20 = load i32, i32* @IPV6_FL_A_GET
store i32 %20, i32* %19
%21 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 253, i32* %24
%25 = getelementptr inbounds %struct.in6_flowlabel_req, %struct.in6_flowlabel_req* %9, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 15
store i32 1, i32* %28
%29 = load i32, i32* %5
%30 = load i32, i32* @SOL_IPV6
%31 = call i64 @setsockopt(i32 %29, i32 %30, i32 32, %struct.in6_flowlabel_req* %9, i32 24)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %4
%34 = load i32, i32* @errno
%35 = call i32 @error(i32 1, i32 %34, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %33, %4
ret void
}

LLVM IR (-O2):
@IPV6_FL_A_GET = global i32 0
@SOL_IPV6 = global i32 0
@errno = global i32 0
define void @flowlabel_get(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @htonl(i32 %1)
unreachable
}