#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 /*<<< orphan*/ _mm_add_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_alignr_epi8(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_set1_epi8(int);
int /*<<< orphan*/ _mm_subs_epu8(int /*<<< orphan*/, int /*<<< orphan*/);
__m128i carryContinuations(__m128i initial_lengths, __m128i previous_carries) {
  __m128i right1 =
      _mm_subs_epu8(_mm_alignr_epi8(initial_lengths, previous_carries, 16 - 1),
                    _mm_set1_epi8(1));
  __m128i sum = _mm_add_epi8(initial_lengths, right1);
  __m128i right2 = _mm_subs_epu8(_mm_alignr_epi8(sum, previous_carries, 16 - 2),
                                 _mm_set1_epi8(2));
  return _mm_add_epi8(sum, right2);
}


x86 assembly (clang, -O0):
<carryContinuations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0xf,%edx
call   1030 <_mm_alignr_epi8@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1,%edi
call   1040 <_mm_set1_epi8@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_subs_epu8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi8@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0xe,%edx
call   1030 <_mm_alignr_epi8@plt>
mov    %eax,-0x18(%rbp)
mov    $0x2,%edi
call   1040 <_mm_set1_epi8@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_subs_epu8@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <_mm_add_epi8@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carryContinuations>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0xf,%edx
call   1030 <_mm_alignr_epi8@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1040 <_mm_set1_epi8@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_subs_epu8@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_add_epi8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14d,%esi
mov    $0xe,%edx
call   1030 <_mm_alignr_epi8@plt>
mov    %eax,%ebp
mov    $0x2,%edi
call   1040 <_mm_set1_epi8@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_subs_epu8@plt>
mov    %ebx,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <_mm_add_epi8@plt>

LLVM IR (-O0):
define i32 @carryContinuations(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @_mm_alignr_epi8(i32 %8, i32 %9, i32 15)
%11 = call i32 @_mm_set1_epi8(i32 1)
%12 = call i32 @_mm_subs_epu8(i32 %10, i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = load i32, i32* %5
%15 = call i32 @_mm_add_epi8(i32 %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = call i32 @_mm_alignr_epi8(i32 %16, i32 %17, i32 14)
%19 = call i32 @_mm_set1_epi8(i32 2)
%20 = call i32 @_mm_subs_epu8(i32 %18, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @_mm_add_epi8(i32 %21, i32 %22)
ret i32 %23
}

LLVM IR (-O2):
define i32 @carryContinuations(i32 %0, i32 %1) {
%3 = tail call i32 @_mm_alignr_epi8(i32 %0, i32 %1, i32 15)
%4 = tail call i32 @_mm_set1_epi8(i32 1)
%5 = tail call i32 @_mm_subs_epu8(i32 %3, i32 %4)
%6 = tail call i32 @_mm_add_epi8(i32 %0, i32 %5)
%7 = tail call i32 @_mm_alignr_epi8(i32 %6, i32 %1, i32 14)
%8 = tail call i32 @_mm_set1_epi8(i32 2)
%9 = tail call i32 @_mm_subs_epu8(i32 %7, i32 %8)
%10 = tail call i32 @_mm_add_epi8(i32 %6, i32 %9)
ret i32 %10
}