#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*/ __m128i;

/* Variables and functions */
int _mm_cvtsi128_si32(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_min_epu8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_srli_si128(int /*<<< orphan*/, int);
unsigned hmin_epu8(__m128i x) {
  x = _mm_min_epu8(x, _mm_srli_si128(x, 8));
  x = _mm_min_epu8(x, _mm_srli_si128(x, 4));
  x = _mm_min_epu8(x, _mm_srli_si128(x, 2));
  x = _mm_min_epu8(x, _mm_srli_si128(x, 1));
  return _mm_cvtsi128_si32(x) & 0xFF;
}


x86 assembly (clang, -O0):
<hmin_epu8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <_mm_cvtsi128_si32@plt>
and    $0xff,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hmin_epu8>:
push   %rbx
mov    %edi,%ebx
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x4,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x2,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_min_epu8@plt>
mov    %eax,%edi
call   1030 <_mm_cvtsi128_si32@plt>
movzbl %al,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @hmin_epu8(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @_mm_srli_si128(i32 %4, i32 8)
%6 = call i32 @_mm_min_epu8(i32 %3, i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = load i32, i32* %2
%9 = call i32 @_mm_srli_si128(i32 %8, i32 4)
%10 = call i32 @_mm_min_epu8(i32 %7, i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = call i32 @_mm_srli_si128(i32 %12, i32 2)
%14 = call i32 @_mm_min_epu8(i32 %11, i32 %13)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @_mm_srli_si128(i32 %16, i32 1)
%18 = call i32 @_mm_min_epu8(i32 %15, i32 %17)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = call i32 @_mm_cvtsi128_si32(i32 %19)
%21 = and i32 %20, 255
ret i32 %21
}

LLVM IR (-O2):
define i32 @hmin_epu8(i32 %0) {
%2 = tail call i32 @_mm_srli_si128(i32 %0, i32 8)
%3 = tail call i32 @_mm_min_epu8(i32 %0, i32 %2)
%4 = tail call i32 @_mm_srli_si128(i32 %3, i32 4)
%5 = tail call i32 @_mm_min_epu8(i32 %3, i32 %4)
%6 = tail call i32 @_mm_srli_si128(i32 %5, i32 2)
%7 = tail call i32 @_mm_min_epu8(i32 %5, i32 %6)
%8 = tail call i32 @_mm_srli_si128(i32 %7, i32 1)
%9 = tail call i32 @_mm_min_epu8(i32 %7, i32 %8)
%10 = tail call i32 @_mm_cvtsi128_si32(i32 %9)
%11 = and i32 %10, 255
ret i32 %11
}