#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*/ uint8_t;
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_cmpeq_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_loadu_si128(int /*<<< orphan*/ const *);
int _mm_movemask_epi8(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_setzero_si128();
unsigned nzmask(uint8_t const data[32]) {
  return ~(
      (_mm_movemask_epi8(_mm_cmpeq_epi8(
          _mm_loadu_si128(0 + (__m128i const *)data), _mm_setzero_si128()))) |
      (_mm_movemask_epi8(_mm_cmpeq_epi8(
           _mm_loadu_si128(1 + (__m128i const *)data), _mm_setzero_si128()))
       << 16));
}


x86 assembly (clang, -O0):
<nzmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_cmpeq_epi8@plt>
mov    %eax,%edi
call   1050 <_mm_movemask_epi8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_cmpeq_epi8@plt>
mov    %eax,%edi
call   1050 <_mm_movemask_epi8@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
shl    $0x10,%ecx
or     %ecx,%eax
xor    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nzmask>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <_mm_loadu_si128@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_cmpeq_epi8@plt>
mov    %eax,%edi
call   1050 <_mm_movemask_epi8@plt>
mov    %eax,%ebp
add    $0x4,%rbx
mov    %rbx,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <_mm_cmpeq_epi8@plt>
mov    %eax,%edi
call   1050 <_mm_movemask_epi8@plt>
shl    $0x10,%eax
or     %ebp,%eax
not    %eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nzmask(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = getelementptr inbounds i32, i32* %3, i64 0
%5 = call i32 @_mm_loadu_si128(i32* %4)
%6 = call i32 (...) @_mm_setzero_si128()
%7 = call i32 @_mm_cmpeq_epi8(i32 %5, i32 %6)
%8 = call i32 @_mm_movemask_epi8(i32 %7)
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = call i32 @_mm_loadu_si128(i32* %10)
%12 = call i32 (...) @_mm_setzero_si128()
%13 = call i32 @_mm_cmpeq_epi8(i32 %11, i32 %12)
%14 = call i32 @_mm_movemask_epi8(i32 %13)
%15 = shl i32 %14, 16
%16 = or i32 %8, %15
%17 = xor i32 %16, -1
ret i32 %17
}

LLVM IR (-O2):
define i32 @nzmask(i32* %0) {
%2 = tail call i32 @_mm_loadu_si128(i32* %0)
%3 = tail call i32 (...) @_mm_setzero_si128()
%4 = tail call i32 @_mm_cmpeq_epi8(i32 %2, i32 %3)
%5 = tail call i32 @_mm_movemask_epi8(i32 %4)
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = tail call i32 @_mm_loadu_si128(i32* %6)
%8 = tail call i32 (...) @_mm_setzero_si128()
%9 = tail call i32 @_mm_cmpeq_epi8(i32 %7, i32 %8)
%10 = tail call i32 @_mm_movemask_epi8(i32 %9)
%11 = shl i32 %10, 16
%12 = or i32 %11, %5
%13 = xor i32 %12, -1
ret i32 %13
}