#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 msghdr {
  int /*<<< orphan*/ msg_controllen;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ __convert_scm_timestamps(struct msghdr *,
                                            int /*<<< orphan*/);
scalar_t__ socketcall_cp(scalar_t__ (*)(int, struct msghdr *, int), int,
                         struct msghdr *, int, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/);
ssize_t recvmsg(int fd, struct msghdr *msg, int flags) {
  ssize_t r;
  socklen_t orig_controllen = msg->msg_controllen;
  r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0);
  if (r >= 0)
    __convert_scm_timestamps(msg, orig_controllen);
  return r;
}


x86 assembly (clang, -O0):
<recvmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    0x2e94(%rip),%rdi
xor    %r9d,%r9d
mov    %r9d,%r8d
movl   $0x0,(%rsp)
call   1040 <socketcall_cp@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jl     1179 <recvmsg+0x59>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <__convert_scm_timestamps@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recvmsg>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ecx
mov    %rsi,%rbx
mov    %edi,%esi
mov    (%rbx),%r14d
movl   $0x0,(%rsp)
mov    0x2ea0(%rip),%rdi
mov    %rbx,%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <socketcall_cp@plt>
mov    %rax,%rbp
test   %rax,%rax
js     1161 <recvmsg+0x41>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <__convert_scm_timestamps@plt>
mov    %rbp,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.msghdr = type { i32 }
define i64 @recvmsg(i32 %0, %struct.msghdr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.msghdr*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %4
store %struct.msghdr* %1, %struct.msghdr** %5
store i32 %2, i32* %6
%9 = load %struct.msghdr*, %struct.msghdr** %5
%10 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i32 0, i32 0
%11 = load i32, i32* %10
store i32 %11, i32* %8
%12 = load i32, i32* %4
%13 = load %struct.msghdr*, %struct.msghdr** %5
%14 = load i32, i32* %6
%15 = call i64 @socketcall_cp(i64 (i32, %struct.msghdr*, i32)* @recvmsg, i32 %12, %struct.msghdr* %13, i32 %14, i32 0, i32 0, i32 0)
store i64 %15, i64* %7
%16 = load i64, i64* %7
%17 = icmp sge i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %3
%19 = load %struct.msghdr*, %struct.msghdr** %5
%20 = load i32, i32* %8
%21 = call i32 @__convert_scm_timestamps(%struct.msghdr* %19, i32 %20)
br label %22
22: ; preds = %18, %3
%23 = load i64, i64* %7
ret i64 %23
}

LLVM IR (-O2):
%struct.msghdr = type { i32 }
define i64 @recvmsg(i32 %0, %struct.msghdr* %1, i32 %2) {
%4 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i64 @socketcall_cp(i64 (i32, %struct.msghdr*, i32)* @recvmsg, i32 %0, %struct.msghdr* %1, i32 %2, i32 0, i32 0, i32 0)
%7 = icmp sgt i64 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @__convert_scm_timestamps(%struct.msghdr* %1, i32 %5)
br label %10
10: ; preds = %8, %3
ret i64 %6
}