#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_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  int /*<<< orphan*/ cb_vers;
  int /*<<< orphan*/ cb_prog;
  int /*<<< orphan*/ cb_rpcvers;
};
struct rpc_msg {
  int rm_direction;
  TYPE_1__ rm_call;
  int /*<<< orphan*/ rm_xid;
};
typedef int /*<<< orphan*/ enum_t;
typedef enum msg_type { ____Placeholder_msg_type } msg_type;
typedef scalar_t__ bool_t;
struct TYPE_9__ {
  scalar_t__ x_op;
};
typedef TYPE_2__ XDR;

/* Variables and functions */
int CALL;
scalar_t__ FALSE;
int /*<<< orphan*/ RPC_MSG_VERSION;
scalar_t__ XDR_ENCODE;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ xdr_enum(TYPE_2__ *, int /*<<< orphan*/ *);
scalar_t__ xdr_rpcprog(TYPE_2__ *, int /*<<< orphan*/ *);
scalar_t__ xdr_rpcvers(TYPE_2__ *, int /*<<< orphan*/ *);
scalar_t__ xdr_u_int32_t(TYPE_2__ *, int /*<<< orphan*/ *);
bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg) {
  enum msg_type *prm_direction;
  assert(xdrs != NULL);
  assert(cmsg != NULL);
  prm_direction = &cmsg->rm_direction;
  cmsg->rm_direction = CALL;
  cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
  if ((xdrs->x_op == XDR_ENCODE) && xdr_u_int32_t(xdrs, &(cmsg->rm_xid)) &&
      xdr_enum(xdrs, (enum_t *)prm_direction) &&
      xdr_rpcvers(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
      xdr_rpcprog(xdrs, &(cmsg->rm_call.cb_prog)))
    return (xdr_u_int32_t(xdrs, &(cmsg->rm_call.cb_vers)));
  return (FALSE);
}


x86 assembly (clang, -O0):
<xdr_callhdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e1e(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
jne    124c <xdr_callhdr+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x10,%rsi
call   1060 <xdr_u_int32_t@plt>
cmp    $0x0,%rax
je     124c <xdr_callhdr+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <xdr_enum@plt>
cmp    $0x0,%rax
je     124c <xdr_callhdr+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
add    $0x8,%rsi
call   1030 <xdr_rpcvers@plt>
cmp    $0x0,%rax
je     124c <xdr_callhdr+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
add    $0x4,%rsi
call   1070 <xdr_rpcprog@plt>
cmp    $0x0,%rax
je     124c <xdr_callhdr+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
call   1060 <xdr_u_int32_t@plt>
mov    %rax,-0x8(%rbp)
jmp    125a <xdr_callhdr+0x10a>
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdr_callhdr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rbx)
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rbx)
mov    (%r14),%rax
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%rax
jne    11f5 <xdr_callhdr+0xa5>
lea    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1060 <xdr_u_int32_t@plt>
test   %rax,%rax
je     11f5 <xdr_callhdr+0xa5>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <xdr_enum@plt>
test   %rax,%rax
je     11f5 <xdr_callhdr+0xa5>
lea    0xc(%rbx),%rsi
mov    %r14,%rdi
call   1030 <xdr_rpcvers@plt>
test   %rax,%rax
je     11f5 <xdr_callhdr+0xa5>
lea    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1070 <xdr_rpcprog@plt>
test   %rax,%rax
je     11f5 <xdr_callhdr+0xa5>
add    $0x4,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <xdr_u_int32_t@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_9__ = type { i64 }
%struct.rpc_msg = type { i32, %struct.TYPE_8__, i32 }
%struct.TYPE_8__ = type { i32, i32, i32 }
@CALL = global i32 0
@RPC_MSG_VERSION = global i32 0
@XDR_ENCODE = global i64 0
@FALSE = global i64 0
define i64 @xdr_callhdr(%struct.TYPE_9__* %0, %struct.rpc_msg* %1) {
%3 = alloca i64
%4 = alloca %struct.TYPE_9__*
%5 = alloca %struct.rpc_msg*
%6 = alloca i32*
store %struct.TYPE_9__* %0, %struct.TYPE_9__** %4
store %struct.rpc_msg* %1, %struct.rpc_msg** %5
%7 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%8 = icmp ne %struct.TYPE_9__* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%12 = icmp ne %struct.rpc_msg* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%16 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %15, i32 0, i32 0
store i32* %16, i32** %6
%17 = load i32, i32* @CALL
%18 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%19 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %18, i32 0, i32 0
store i32 %17, i32* %19
%20 = load i32, i32* @RPC_MSG_VERSION
%21 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%22 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %21, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %22, i32 0, i32 2
store i32 %20, i32* %23
%24 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%25 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load i64, i64* @XDR_ENCODE
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %60
29: ; preds = %2
%30 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%31 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%32 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %31, i32 0, i32 2
%33 = call i64 @xdr_u_int32_t(%struct.TYPE_9__* %30, i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %60
35: ; preds = %29
%36 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%37 = load i32*, i32** %6
%38 = call i64 @xdr_enum(%struct.TYPE_9__* %36, i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %60
40: ; preds = %35
%41 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%42 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%43 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %42, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %43, i32 0, i32 2
%45 = call i64 @xdr_rpcvers(%struct.TYPE_9__* %41, i32* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %60
47: ; preds = %40
%48 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%49 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%50 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %49, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %50, i32 0, i32 1
%52 = call i64 @xdr_rpcprog(%struct.TYPE_9__* %48, i32* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %47
%55 = load %struct.TYPE_9__*, %struct.TYPE_9__** %4
%56 = load %struct.rpc_msg*, %struct.rpc_msg** %5
%57 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %56, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %57, i32 0, i32 0
%59 = call i64 @xdr_u_int32_t(%struct.TYPE_9__* %55, i32* %58)
store i64 %59, i64* %3
br label %62
60: ; preds = %47, %40, %35, %29, %2
%61 = load i64, i64* @FALSE
store i64 %61, i64* %3
br label %62
62: ; preds = %60, %54
%63 = load i64, i64* %3
ret i64 %63
}

LLVM IR (-O2):
%struct.TYPE_9__ = type { i64 }
%struct.rpc_msg = type { i32, %struct.TYPE_8__, i32 }
%struct.TYPE_8__ = type { i32, i32, i32 }
@CALL = global i32 0
@RPC_MSG_VERSION = global i32 0
@XDR_ENCODE = global i64 0
@FALSE = global i64 0
define i64 @xdr_callhdr(%struct.TYPE_9__* %0, %struct.rpc_msg* %1) {
%3 = icmp ne %struct.TYPE_9__* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne %struct.rpc_msg* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %1, i64 0, i32 0
%10 = load i32, i32* @CALL
store i32 %10, i32* %9
%11 = load i32, i32* @RPC_MSG_VERSION
%12 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %1, i64 0, i32 1, i32 2
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %0, i64 0, i32 0
%14 = load i64, i64* %13
%15 = load i64, i64* @XDR_ENCODE
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %2
%18 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %1, i64 0, i32 2
%19 = tail call i64 @xdr_u_int32_t(%struct.TYPE_9__* %0, i32* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %17
%22 = tail call i64 @xdr_enum(%struct.TYPE_9__* %0, i32* %9)
%23 = icmp eq i64 %22, 0
br i1 %23, label %34, label %24
24: ; preds = %21
%25 = tail call i64 @xdr_rpcvers(%struct.TYPE_9__* %0, i32* %12)
%26 = icmp eq i64 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %1, i64 0, i32 1, i32 1
%29 = tail call i64 @xdr_rpcprog(%struct.TYPE_9__* %0, i32* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = getelementptr inbounds %struct.rpc_msg, %struct.rpc_msg* %1, i64 0, i32 1, i32 0
%33 = tail call i64 @xdr_u_int32_t(%struct.TYPE_9__* %0, i32* %32)
br label %36
34: ; preds = %27, %24, %21, %17, %2
%35 = load i64, i64* @FALSE
br label %36
36: ; preds = %34, %31
%37 = phi i64 [ %33, %31 ], [ %35, %34 ]
ret i64 %37
}