#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 in6_addr {
  int dummy;
};
typedef unsigned short __u32;

/* Variables and functions */
int /*<<< orphan*/ __csum_ipv6_magic(struct in6_addr *, struct in6_addr *,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     unsigned int);
unsigned short csum_fold(int /*<<< orphan*/);
int /*<<< orphan*/ htonl(unsigned short);
unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
                                   struct in6_addr *daddr, __u32 len,
                                   unsigned short proto, unsigned int sum) {
  return csum_fold(
      __csum_ipv6_magic(saddr, daddr, htonl(len), htonl(proto), sum));
}


x86 assembly (clang, -O0):
<csum_ipv6_magic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cx,-0x12(%rbp)
mov    %ax,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movzwl -0x12(%rbp),%edi
call   1030 <htonl@plt>
mov    %eax,-0x1c(%rbp)
movzwl -0x14(%rbp),%edi
call   1030 <htonl@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%r8d
call   1040 <__csum_ipv6_magic@plt>
mov    %eax,%edi
call   1050 <csum_fold@plt>
movzwl %ax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csum_ipv6_magic>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,%edi
call   1030 <htonl@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <htonl@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
mov    %r14d,%r8d
call   1040 <__csum_ipv6_magic@plt>
mov    %eax,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <csum_fold@plt>

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
define zeroext i16 @csum_ipv6_magic(%struct.in6_addr* %0, %struct.in6_addr* %1, i16 zeroext %2, i16 zeroext %3, i32 %4) {
%6 = alloca %struct.in6_addr*
%7 = alloca %struct.in6_addr*
%8 = alloca i16
%9 = alloca i16
%10 = alloca i32
store %struct.in6_addr* %0, %struct.in6_addr** %6
store %struct.in6_addr* %1, %struct.in6_addr** %7
store i16 %2, i16* %8
store i16 %3, i16* %9
store i32 %4, i32* %10
%11 = load %struct.in6_addr*, %struct.in6_addr** %6
%12 = load %struct.in6_addr*, %struct.in6_addr** %7
%13 = load i16, i16* %8
%14 = call i32 @htonl(i16 zeroext %13)
%15 = load i16, i16* %9
%16 = call i32 @htonl(i16 zeroext %15)
%17 = load i32, i32* %10
%18 = call i32 @__csum_ipv6_magic(%struct.in6_addr* %11, %struct.in6_addr* %12, i32 %14, i32 %16, i32 %17)
%19 = call zeroext i16 @csum_fold(i32 %18)
ret i16 %19
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
define zeroext i16 @csum_ipv6_magic(%struct.in6_addr* %0, %struct.in6_addr* %1, i16 zeroext %2, i16 zeroext %3, i32 %4) {
%6 = tail call i32 @htonl(i16 zeroext %2)
%7 = tail call i32 @htonl(i16 zeroext %3)
%8 = tail call i32 @__csum_ipv6_magic(%struct.in6_addr* %0, %struct.in6_addr* %1, i32 %6, i32 %7, i32 %4)
%9 = tail call zeroext i16 @csum_fold(i32 %8)
ret i16 %9
}