#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*/ uint32_t;
typedef int /*<<< orphan*/ u_char;
struct msg {
  int dummy;
};
typedef int /*<<< orphan*/ XDR;

/* Variables and functions */
int /*<<< orphan*/ XDR_DECODE;
int /*<<< orphan*/ xdr_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ xdr_msg(int /*<<< orphan*/ *, struct msg *);
int /*<<< orphan*/ xdrmem_create(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/, int /*<<< orphan*/);
int xdr2msg(struct msg *msg, u_char *buf, uint32_t buflen) {
  XDR xdrs;
  int ret = 0;
  xdrmem_create(&xdrs, buf, buflen, XDR_DECODE);
  if (!xdr_msg(&xdrs, msg))
    ret = -1;
  xdr_destroy(&xdrs);
  return (ret);
}


x86 assembly (clang, -O0):
<xdr2msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    0x2e98(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
call   1050 <xdrmem_create@plt>
mov    -0x8(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1030 <xdr_msg@plt>
cmp    $0x0,%eax
jne    1180 <xdr2msg+0x50>
movl   $0xffffffff,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <xdr_destroy@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr2msg>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb2(%rip),%rax
mov    (%rax),%ecx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1050 <xdrmem_create@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <xdr_msg@plt>
cmp    $0x1,%eax
sbb    %ebx,%ebx
mov    %r14,%rdi
call   1040 <xdr_destroy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.msg = type { i32 }
@XDR_DECODE = global i32 0
define i32 @xdr2msg(%struct.msg* %0, i32* %1, i32 %2) {
%4 = alloca %struct.msg*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.msg* %0, %struct.msg** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %8
%9 = load i32*, i32** %5
%10 = load i32, i32* %6
%11 = load i32, i32* @XDR_DECODE
%12 = call i32 @xdrmem_create(i32* %7, i32* %9, i32 %10, i32 %11)
%13 = load %struct.msg*, %struct.msg** %4
%14 = call i32 @xdr_msg(i32* %7, %struct.msg* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %3
store i32 -1, i32* %8
br label %17
17: ; preds = %16, %3
%18 = call i32 @xdr_destroy(i32* %7)
%19 = load i32, i32* %8
ret i32 %19
}

LLVM IR (-O2):
%struct.msg = type { i32 }
@XDR_DECODE = global i32 0
define i32 @xdr2msg(%struct.msg* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = load i32, i32* @XDR_DECODE
%7 = call i32 @xdrmem_create(i32* %4, i32* %1, i32 %2, i32 %6)
%8 = call i32 @xdr_msg(i32* %4, %struct.msg* %0)
%9 = icmp eq i32 %8, 0
%10 = sext i1 %9 to i32
%11 = call i32 @xdr_destroy(i32* %4)
ret i32 %10
}