#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 uint64_t;

/* Variables and functions */
void ZipperMergeAndAdd(const uint64_t v1, const uint64_t v0, uint64_t *add1,
                       uint64_t *add0) {
  *add0 += (((v0 & 0xff000000ull) | (v1 & 0xff00000000ull)) >> 24) |
           (((v0 & 0xff0000000000ull) | (v1 & 0xff000000000000ull)) >> 16) |
           (v0 & 0xff0000ull) | ((v0 & 0xff00ull) << 32) |
           ((v1 & 0xff00000000000000ull) >> 8) | (v0 << 56);
  *add1 += (((v1 & 0xff000000ull) | (v0 & 0xff00000000ull)) >> 24) |
           (v1 & 0xff0000ull) | ((v1 & 0xff0000000000ull) >> 16) |
           ((v1 & 0xff00ull) << 24) | ((v0 & 0xff000000000000ull) >> 8) |
           ((v1 & 0xffull) << 48) | (v0 & 0xff00000000000000ull);
}


x86 assembly (clang, -O0):
<ZipperMergeAndAdd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movslq -0x8(%rbp),%rdx
movabs $0xff000000,%rax
and    %rax,%rdx
movslq -0x4(%rbp),%rax
movabs $0xff00000000,%rcx
and    %rcx,%rax
or     %rax,%rdx
shr    $0x18,%rdx
movslq -0x8(%rbp),%rax
movabs $0xff0000000000,%rcx
and    %rcx,%rax
movslq -0x4(%rbp),%rcx
movabs $0xff000000000000,%rsi
and    %rsi,%rcx
or     %rcx,%rax
shr    $0x10,%rax
or     %rax,%rdx
movslq -0x8(%rbp),%rax
and    $0xff0000,%rax
or     %rax,%rdx
movslq -0x8(%rbp),%rax
and    $0xff00,%rax
shl    $0x20,%rax
or     %rax,%rdx
movslq -0x4(%rbp),%rax
movabs $0xff00000000000000,%rcx
and    %rcx,%rax
shr    $0x8,%rax
or     %rax,%rdx
mov    -0x8(%rbp),%eax
mov    $0x38,%ecx
shl    %cl,%eax
cltq
or     %rax,%rdx
mov    -0x18(%rbp),%rax
movslq (%rax),%rcx
add    %rdx,%rcx
mov    %ecx,(%rax)
movslq -0x4(%rbp),%rdx
movabs $0xff000000,%rax
and    %rax,%rdx
movslq -0x8(%rbp),%rax
movabs $0xff00000000,%rcx
and    %rcx,%rax
or     %rax,%rdx
shr    $0x18,%rdx
movslq -0x4(%rbp),%rax
and    $0xff0000,%rax
or     %rax,%rdx
movslq -0x4(%rbp),%rax
movabs $0xff0000000000,%rcx
and    %rcx,%rax
shr    $0x10,%rax
or     %rax,%rdx
movslq -0x4(%rbp),%rax
and    $0xff00,%rax
shl    $0x18,%rax
or     %rax,%rdx
movslq -0x8(%rbp),%rax
movabs $0xff000000000000,%rcx
and    %rcx,%rax
shr    $0x8,%rax
or     %rax,%rdx
movslq -0x4(%rbp),%rax
and    $0xff,%rax
shl    $0x30,%rax
or     %rax,%rdx
movslq -0x8(%rbp),%rax
movabs $0xff00000000000000,%rcx
and    %rcx,%rax
or     %rax,%rdx
mov    -0x10(%rbp),%rax
movslq (%rax),%rcx
add    %rdx,%rcx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZipperMergeAndAdd>:
movslq %esi,%rax
movslq %edi,%rcx
mov    %ecx,%esi
and    $0xff000000,%esi
movabs $0xff00000000,%rdi
and    %rax,%rdi
or     %rsi,%rdi
shr    $0x18,%rdi
mov    %ecx,%eax
and    $0xff0000,%eax
shr    $0x10,%rcx
and    $0xff000000,%ecx
or     %eax,%ecx
or     %ecx,%edi
add    %edi,(%rdx)
ret

LLVM IR (-O0):
define void @ZipperMergeAndAdd(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = and i64 %10, 4278190080
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = and i64 %13, 1095216660480
%15 = or i64 %11, %14
%16 = lshr i64 %15, 24
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = and i64 %18, 280375465082880
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = and i64 %21, 71776119061217280
%23 = or i64 %19, %22
%24 = lshr i64 %23, 16
%25 = or i64 %16, %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = and i64 %27, 16711680
%29 = or i64 %25, %28
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = and i64 %31, 65280
%33 = shl i64 %32, 32
%34 = or i64 %29, %33
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = and i64 %36, -72057594037927936
%38 = lshr i64 %37, 8
%39 = or i64 %34, %38
%40 = load i32, i32* %6
%41 = shl i32 %40, 56
%42 = sext i32 %41 to i64
%43 = or i64 %39, %42
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = add i64 %46, %43
%48 = trunc i64 %47 to i32
store i32 %48, i32* %44
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = and i64 %50, 4278190080
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = and i64 %53, 1095216660480
%55 = or i64 %51, %54
%56 = lshr i64 %55, 24
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = and i64 %58, 16711680
%60 = or i64 %56, %59
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = and i64 %62, 280375465082880
%64 = lshr i64 %63, 16
%65 = or i64 %60, %64
%66 = load i32, i32* %5
%67 = sext i32 %66 to i64
%68 = and i64 %67, 65280
%69 = shl i64 %68, 24
%70 = or i64 %65, %69
%71 = load i32, i32* %6
%72 = sext i32 %71 to i64
%73 = and i64 %72, 71776119061217280
%74 = lshr i64 %73, 8
%75 = or i64 %70, %74
%76 = load i32, i32* %5
%77 = sext i32 %76 to i64
%78 = and i64 %77, 255
%79 = shl i64 %78, 48
%80 = or i64 %75, %79
%81 = load i32, i32* %6
%82 = sext i32 %81 to i64
%83 = and i64 %82, -72057594037927936
%84 = or i64 %80, %83
%85 = load i32*, i32** %7
%86 = load i32, i32* %85
%87 = sext i32 %86 to i64
%88 = add i64 %87, %84
%89 = trunc i64 %88 to i32
store i32 %89, i32* %85
ret void
}

LLVM IR (-O2):
define void @ZipperMergeAndAdd(i32 %0, i32 %1, i32* nocapture %2, i32* nocapture readnone %3) {
%5 = sext i32 %1 to i64
%6 = sext i32 %0 to i64
%7 = and i64 %6, 4278190080
%8 = and i64 %5, 1095216660480
%9 = or i64 %8, %7
%10 = lshr exact i64 %9, 24
%11 = and i64 %6, 16711680
%12 = lshr i64 %6, 16
%13 = and i64 %12, 4278190080
%14 = or i64 %13, %11
%15 = or i64 %14, %10
%16 = load i32, i32* %2
%17 = trunc i64 %15 to i32
%18 = add i32 %16, %17
store i32 %18, i32* %2
ret void
}