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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void code128_append_pattern(int pattern, int pattern_length, char *out) {
  assert(pattern & (1 << (pattern_length - 1)));
  int i;
  for (i = pattern_length - 1; i >= 0; i--) {
    *out++ = (unsigned char)((pattern & (1 << i)) ? 255 : 0);
  }
}


x86 assembly (clang, -O0):
<code128_append_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1189 <code128_append_pattern+0x79>
mov    -0x4(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edx
xor    %eax,%eax
mov    $0xff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <code128_append_pattern+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<code128_append_pattern>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r14d
lea    -0x1(%r15),%ebp
mov    $0x1,%edi
mov    %ebp,%ecx
shl    %cl,%edi
and    %r14d,%edi
call   1030 <assert@plt>
test   %r15d,%r15d
jle    1561 <code128_append_pattern+0x451>
cmp    $0xf,%ebp
jb     1550 <code128_append_pattern+0x440>
mov    %ebp,%ecx
add    $0x1,%rcx
mov    %rcx,%rax
and    $0xfffffffffffffff0,%rax
movd   %ebp,%xmm0
pshufd $0x0,%xmm0,%xmm4
movdqa 0xe9a(%rip),%xmm14
paddd  %xmm4,%xmm14
movdqa 0xe9c(%rip),%xmm15
paddd  %xmm4,%xmm15
movdqa 0xe9e(%rip),%xmm10
paddd  %xmm4,%xmm10
paddd  0xea1(%rip),%xmm4
movd   %r14d,%xmm0
pshufd $0x0,%xmm0,%xmm13
lea    -0x10(%rax),%rdx
mov    %rdx,%rsi
shr    $0x4,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     156c <code128_append_pattern+0x45c>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
movdqa 0xe7c(%rip),%xmm8
movdqa 0xe84(%rip),%xmm6
pxor   %xmm11,%xmm11
pcmpeqd %xmm12,%xmm12
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm4,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm8,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm7
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm0
punpckldq %xmm0,%xmm7
movdqa %xmm10,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm8,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pmuludq %xmm6,%xmm5
pshufd $0xe8,%xmm5,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm15,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm8,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm0
movdqa %xmm14,%xmm5
pslld  $0x17,%xmm5
paddd  %xmm8,%xmm5
cvttps2dq %xmm5,%xmm5
pshufd $0xf5,%xmm5,%xmm2
pmuludq %xmm6,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm5
pand   %xmm13,%xmm5
pand   %xmm13,%xmm0
pand   %xmm13,%xmm1
pand   %xmm13,%xmm7
pcmpeqd %xmm11,%xmm7
pxor   %xmm12,%xmm7
pcmpeqd %xmm11,%xmm1
pxor   %xmm12,%xmm1
packssdw %xmm1,%xmm7
pcmpeqd %xmm11,%xmm0
pxor   %xmm12,%xmm0
pcmpeqd %xmm11,%xmm5
pxor   %xmm12,%xmm5
packssdw %xmm5,%xmm0
packsswb %xmm0,%xmm7
movdqu %xmm7,(%rbx,%rdx,1)
movdqa %xmm14,%xmm1
movdqa 0xd6f(%rip),%xmm3
paddd  %xmm3,%xmm1
movdqa %xmm15,%xmm5
paddd  %xmm3,%xmm5
movdqa %xmm10,%xmm0
paddd  %xmm3,%xmm0
movdqa %xmm4,%xmm2
paddd  %xmm3,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm8,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm9
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm7
pmuludq %xmm6,%xmm9
pshufd $0xe8,%xmm9,%xmm2
punpckldq %xmm2,%xmm7
pslld  $0x17,%xmm0
paddd  %xmm8,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm5
paddd  %xmm8,%xmm5
cvttps2dq %xmm5,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm5
pmuludq %xmm6,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm5
pslld  $0x17,%xmm1
paddd  %xmm8,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm13,%xmm1
pand   %xmm13,%xmm5
pand   %xmm13,%xmm0
pand   %xmm13,%xmm7
pcmpeqd %xmm11,%xmm7
pxor   %xmm12,%xmm7
pcmpeqd %xmm11,%xmm0
pxor   %xmm12,%xmm0
packssdw %xmm0,%xmm7
pcmpeqd %xmm11,%xmm5
pxor   %xmm12,%xmm5
pcmpeqd %xmm11,%xmm1
pxor   %xmm12,%xmm1
packssdw %xmm1,%xmm5
packsswb %xmm5,%xmm7
movdqu %xmm7,0x10(%rbx,%rdx,1)
add    $0x20,%rdx
movdqa 0xc60(%rip),%xmm0
paddd  %xmm0,%xmm4
paddd  %xmm0,%xmm10
paddd  %xmm0,%xmm15
paddd  %xmm0,%xmm14
add    $0xfffffffffffffffe,%rdi
jne    11e0 <code128_append_pattern+0xd0>
test   $0x1,%sil
je     153d <code128_append_pattern+0x42d>
pslld  $0x17,%xmm4
movdqa 0xbfc(%rip),%xmm6
paddd  %xmm6,%xmm4
cvttps2dq %xmm4,%xmm0
movdqa 0xbfc(%rip),%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm5,%xmm0
pshufd $0xe8,%xmm0,%xmm4
pmuludq %xmm5,%xmm1
pshufd $0xe8,%xmm1,%xmm0
punpckldq %xmm0,%xmm4
pslld  $0x17,%xmm10
paddd  %xmm6,%xmm10
cvttps2dq %xmm10,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm5,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pmuludq %xmm5,%xmm2
pshufd $0xe8,%xmm2,%xmm0
punpckldq %xmm0,%xmm1
pslld  $0x17,%xmm15
paddd  %xmm6,%xmm15
cvttps2dq %xmm15,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm5,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm5,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm14
paddd  %xmm6,%xmm14
cvttps2dq %xmm14,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm5,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm5,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
pand   %xmm13,%xmm2
pand   %xmm13,%xmm0
pand   %xmm13,%xmm1
pand   %xmm13,%xmm4
pxor   %xmm3,%xmm3
pcmpeqd %xmm3,%xmm4
pcmpeqd %xmm5,%xmm5
pxor   %xmm5,%xmm4
pcmpeqd %xmm3,%xmm1
pxor   %xmm5,%xmm1
packssdw %xmm1,%xmm4
pcmpeqd %xmm3,%xmm0
pxor   %xmm5,%xmm0
pcmpeqd %xmm3,%xmm2
pxor   %xmm5,%xmm2
packssdw %xmm2,%xmm0
packsswb %xmm0,%xmm4
movdqu %xmm4,(%rbx,%rdx,1)
cmp    %rax,%rcx
je     1561 <code128_append_pattern+0x451>
sub    %eax,%ebp
add    %rax,%rbx
nopw   0x0(%rax,%rax,1)
bt     %ebp,%r14d
sbb    %eax,%eax
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffff,%ebp
jb     1550 <code128_append_pattern+0x440>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    1437 <code128_append_pattern+0x327>
jmp    153d <code128_append_pattern+0x42d>

LLVM IR (-O0):
define void @code128_append_pattern(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
%11 = shl i32 1, %10
%12 = and i32 %8, %11
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %7
br label %16
16: ; preds = %30, %3
%17 = load i32, i32* %7
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load i32, i32* %4
%21 = load i32, i32* %7
%22 = shl i32 1, %21
%23 = and i32 %20, %22
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 255, i32 0
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
store i8 %27, i8* %28
br label %30
30: ; preds = %19
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
br label %16
33: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @code128_append_pattern(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = add nsw i32 %1, -1
%5 = shl nuw i32 1, %4
%6 = and i32 %5, %0
%7 = tail call i32 @assert(i32 %6)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %78
9: ; preds = %3
%10 = zext i32 %4 to i64
%11 = add nuw nsw i64 %10, 1
%12 = icmp ult i32 %4, 15
br i1 %12, label %65, label %13
13: ; preds = %9
%14 = and i64 %11, 8589934576
%15 = trunc i64 %14 to i32
%16 = sub i32 %4, %15
%17 = getelementptr i8, i8* %2, i64 %14
%18 = insertelement <16 x i32> poison, i32 %4, i64 0
%19 = shufflevector <16 x i32> %18, <16 x i32> poison, <16 x i32> zeroinitializer
%20 = add <16 x i32> %19, <i32 0, i32 -1, i32 -2, i32 -3, i32 -4, i32 -5, i32 -6, i32 -7, i32 -8, i32 -9, i32 -10, i32 -11, i32 -12, i32 -13, i32 -14, i32 -15>
%21 = insertelement <16 x i32> poison, i32 %0, i64 0
%22 = shufflevector <16 x i32> %21, <16 x i32> poison, <16 x i32> zeroinitializer
%23 = add nsw i64 %14, -16
%24 = lshr exact i64 %23, 4
%25 = add nuw nsw i64 %24, 1
%26 = and i64 %25, 1
%27 = icmp eq i64 %23, 0
br i1 %27, label %52, label %28
28: ; preds = %13
%29 = and i64 %25, 2305843009213693950
br label %30
30: ; preds = %30, %28
%31 = phi i64 [ 0, %28 ], [ %48, %30 ]
%32 = phi <16 x i32> [ %20, %28 ], [ %49, %30 ]
%33 = phi i64 [ 0, %28 ], [ %50, %30 ]
%34 = getelementptr i8, i8* %2, i64 %31
%35 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %32
%36 = and <16 x i32> %35, %22
%37 = icmp ne <16 x i32> %36, zeroinitializer
%38 = sext <16 x i1> %37 to <16 x i8>
%39 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> %38, <16 x i8>* %39
%40 = or i64 %31, 16
%41 = add <16 x i32> %32, <i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16>
%42 = getelementptr i8, i8* %2, i64 %40
%43 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %41
%44 = and <16 x i32> %43, %22
%45 = icmp ne <16 x i32> %44, zeroinitializer
%46 = sext <16 x i1> %45 to <16 x i8>
%47 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> %46, <16 x i8>* %47
%48 = add nuw i64 %31, 32
%49 = add <16 x i32> %32, <i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32>
%50 = add i64 %33, 2
%51 = icmp eq i64 %50, %29
br i1 %51, label %52, label %30
52: ; preds = %30, %13
%53 = phi i64 [ 0, %13 ], [ %48, %30 ]
%54 = phi <16 x i32> [ %20, %13 ], [ %49, %30 ]
%55 = icmp eq i64 %26, 0
br i1 %55, label %63, label %56
56: ; preds = %52
%57 = getelementptr i8, i8* %2, i64 %53
%58 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %54
%59 = and <16 x i32> %58, %22
%60 = icmp ne <16 x i32> %59, zeroinitializer
%61 = sext <16 x i1> %60 to <16 x i8>
%62 = bitcast i8* %57 to <16 x i8>*
store <16 x i8> %61, <16 x i8>* %62
br label %63
63: ; preds = %52, %56
%64 = icmp eq i64 %11, %14
br i1 %64, label %78, label %65
65: ; preds = %9, %63
%66 = phi i32 [ %4, %9 ], [ %16, %63 ]
%67 = phi i8* [ %2, %9 ], [ %17, %63 ]
br label %68
68: ; preds = %65, %68
%69 = phi i32 [ %76, %68 ], [ %66, %65 ]
%70 = phi i8* [ %75, %68 ], [ %67, %65 ]
%71 = shl nuw i32 1, %69
%72 = and i32 %71, %0
%73 = icmp ne i32 %72, 0
%74 = sext i1 %73 to i8
%75 = getelementptr inbounds i8, i8* %70, i64 1
store i8 %74, i8* %70
%76 = add nsw i32 %69, -1
%77 = icmp eq i32 %69, 0
br i1 %77, label %78, label %68
78: ; preds = %68, %63, %3
ret void
}