#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 */
unsigned char poly(int *, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ seqprint(unsigned char *, int);
void makeseq(int tap, int len) {
  unsigned char seq[2 * ((1 << 16) - 1)];
  int mem, i;
  mem = 0;
  for (i = 0; i < ((1 << 16) - 1); ++i)
    poly(&mem, tap, 1);
  for (i = 0; i < 2 * ((1 << 16) - 1); ++i)
    seq[i] = poly(&mem, tap, 1);
  printf("\nx^%d + x^%d + 1 =\n", 16, tap);
  seqprint(seq, len);
  for (i = 0; i < 2 * ((1 << 16) - 1); ++i)
    seq[i] ^= 1;
  seqprint(seq, len);
}


x86 assembly (clang, -O0):
<makeseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20020,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x20014(%rbp)
movl   $0x0,-0x20018(%rbp)
cmpl   $0xffff,-0x20018(%rbp)
jge    118d <makeseq+0x5d>
mov    -0x4(%rbp),%esi
lea    -0x20014(%rbp),%rdi
mov    $0x1,%edx
call   1040 <poly@plt>
mov    -0x20018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20018(%rbp)
jmp    1155 <makeseq+0x25>
movl   $0x0,-0x20018(%rbp)
cmpl   $0x1fffe,-0x20018(%rbp)
jge    11df <makeseq+0xaf>
mov    -0x4(%rbp),%esi
lea    -0x20014(%rbp),%rdi
mov    $0x1,%edx
call   1040 <poly@plt>
mov    %al,%cl
movslq -0x20018(%rbp),%rax
mov    %cl,-0x20010(%rbp,%rax,1)
mov    -0x20018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20018(%rbp)
jmp    1197 <makeseq+0x67>
mov    -0x4(%rbp),%edx
lea    0xe17(%rip),%rdi
mov    $0x10,%esi
call   1030 <printf@plt>
lea    -0x20010(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <seqprint@plt>
movl   $0x0,-0x20018(%rbp)
cmpl   $0x1fffe,-0x20018(%rbp)
jge    1249 <makeseq+0x119>
movslq -0x20018(%rbp),%rax
movzbl -0x20010(%rbp,%rax,1),%ecx
ff
xor    $0x1,%ecx
mov    %cl,-0x20010(%rbp,%rax,1)
mov    -0x20018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20018(%rbp)
jmp    120c <makeseq+0xdc>
lea    -0x20010(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <seqprint@plt>
add    $0x20020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeseq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x20018,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
mov    $0xffff,%ebx
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <poly@plt>
add    $0xffffffff,%ebx
jne    1160 <makeseq+0x30>
xor    %ebx,%ebx
lea    0xc(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <poly@plt>
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x1fffe,%rbx
jne    1180 <makeseq+0x50>
lea    0xe79(%rip),%rdi
mov    $0x10,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
mov    %r14d,%esi
call   1050 <seqprint@plt>
xor    %eax,%eax
movaps 0xe37(%rip),%xmm0
nopl   0x0(%rax)
movaps 0x10(%rsp,%rax,1),%xmm1
xorps  %xmm0,%xmm1
movaps 0x20(%rsp,%rax,1),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x10(%rsp,%rax,1)
movaps %xmm2,0x20(%rsp,%rax,1)
movaps 0x30(%rsp,%rax,1),%xmm1
xorps  %xmm0,%xmm1
movaps 0x40(%rsp,%rax,1),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x30(%rsp,%rax,1)
movaps %xmm2,0x40(%rsp,%rax,1)
movaps 0x50(%rsp,%rax,1),%xmm1
xorps  %xmm0,%xmm1
movaps 0x60(%rsp,%rax,1),%xmm2
xorps  %xmm0,%xmm2
movaps %xmm1,0x50(%rsp,%rax,1)
movaps %xmm2,0x60(%rsp,%rax,1)
add    $0x60,%rax
cmp    $0x1ffe0,%rax
jne    11d0 <makeseq+0xa0>
movsd  0x1fff0(%rsp),%xmm0
movaps 0xdd6(%rip),%xmm1
xorps  %xmm1,%xmm0
movsd  0x1fff8(%rsp),%xmm2
xorps  %xmm1,%xmm2
movlhps %xmm2,%xmm0
movaps %xmm0,0x1fff0(%rsp)
movsd  0x20000(%rsp),%xmm0
xorps  %xmm1,%xmm0
movlps %xmm0,0x20000(%rsp)
xorb   $0x1,0x20008(%rsp)
01
xorb   $0x1,0x20009(%rsp)
01
xorb   $0x1,0x2000a(%rsp)
01
xorb   $0x1,0x2000b(%rsp)
01
xorb   $0x1,0x2000c(%rsp)
01
xorb   $0x1,0x2000d(%rsp)
01
lea    0x10(%rsp),%rdi
mov    %r14d,%esi
call   1050 <seqprint@plt>
add    $0x20018,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0Ax^%d + x^%d + 1 =\0A\00"
define void @makeseq(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [131070 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %14, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 65535
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %3
%13 = call zeroext i8 @poly(i32* %6, i32 %12, i32 1)
br label %14
14: ; preds = %11
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %8
17: ; preds = %8
store i32 0, i32* %7
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 131070
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %3
%23 = call zeroext i8 @poly(i32* %6, i32 %22, i32 1)
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [131070 x i8], [131070 x i8]* %5, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %21
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %18
30: ; preds = %18
%31 = load i32, i32* %3
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 16, i32 %31)
%33 = getelementptr inbounds [131070 x i8], [131070 x i8]* %5, i64 0, i64 0
%34 = load i32, i32* %4
%35 = call i32 @seqprint(i8* %33, i32 %34)
store i32 0, i32* %7
br label %36
36: ; preds = %47, %30
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 131070
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [131070 x i8], [131070 x i8]* %5, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = xor i32 %44, 1
%46 = trunc i32 %45 to i8
store i8 %46, i8* %42
br label %47
47: ; preds = %39
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %36
50: ; preds = %36
%51 = getelementptr inbounds [131070 x i8], [131070 x i8]* %5, i64 0, i64 0
%52 = load i32, i32* %4
%53 = call i32 @seqprint(i8* %51, i32 %52)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0Ax^%d + x^%d + 1 =\0A\00"
define void @makeseq(i32 %0, i32 %1) {
%3 = alloca [131070 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %10, %7 ]
%9 = call zeroext i8 @poly(i32* %4, i32 %0, i32 1)
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, 65535
br i1 %11, label %12, label %7
12: ; preds = %7, %12
%13 = phi i64 [ %16, %12 ], [ 0, %7 ]
%14 = call zeroext i8 @poly(i32* %4, i32 %0, i32 1)
%15 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 %13
store i8 %14, i8* %15
%16 = add nuw nsw i64 %13, 1
%17 = icmp eq i64 %16, 131070
br i1 %17, label %18, label %12
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 16, i32 %0)
%20 = call i32 @seqprint(i8* %5, i32 %1)
br label %21
21: ; preds = %21, %18
%22 = phi i64 [ 0, %18 ], [ %55, %21 ]
%23 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 %22
%24 = bitcast i8* %23 to <16 x i8>*
%25 = load <16 x i8>, <16 x i8>* %24
%26 = getelementptr inbounds i8, i8* %23, i64 16
%27 = bitcast i8* %26 to <16 x i8>*
%28 = load <16 x i8>, <16 x i8>* %27
%29 = xor <16 x i8> %25, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%30 = xor <16 x i8> %28, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%31 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> %29, <16 x i8>* %31
%32 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %30, <16 x i8>* %32
%33 = add nuw nsw i64 %22, 32
%34 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 %33
%35 = bitcast i8* %34 to <16 x i8>*
%36 = load <16 x i8>, <16 x i8>* %35
%37 = getelementptr inbounds i8, i8* %34, i64 16
%38 = bitcast i8* %37 to <16 x i8>*
%39 = load <16 x i8>, <16 x i8>* %38
%40 = xor <16 x i8> %36, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%41 = xor <16 x i8> %39, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%42 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> %40, <16 x i8>* %42
%43 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %43
%44 = add nuw nsw i64 %22, 64
%45 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 %44
%46 = bitcast i8* %45 to <16 x i8>*
%47 = load <16 x i8>, <16 x i8>* %46
%48 = getelementptr inbounds i8, i8* %45, i64 16
%49 = bitcast i8* %48 to <16 x i8>*
%50 = load <16 x i8>, <16 x i8>* %49
%51 = xor <16 x i8> %47, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%52 = xor <16 x i8> %50, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%53 = bitcast i8* %45 to <16 x i8>*
store <16 x i8> %51, <16 x i8>* %53
%54 = bitcast i8* %48 to <16 x i8>*
store <16 x i8> %52, <16 x i8>* %54
%55 = add nuw nsw i64 %22, 96
%56 = icmp eq i64 %55, 131040
br i1 %56, label %57, label %21
57: ; preds = %21
%58 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131040
%59 = bitcast i8* %58 to <8 x i8>*
%60 = load <8 x i8>, <8 x i8>* %59
%61 = xor <8 x i8> %60, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%62 = bitcast i8* %58 to <8 x i8>*
store <8 x i8> %61, <8 x i8>* %62
%63 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131048
%64 = bitcast i8* %63 to <8 x i8>*
%65 = load <8 x i8>, <8 x i8>* %64
%66 = xor <8 x i8> %65, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%67 = bitcast i8* %63 to <8 x i8>*
store <8 x i8> %66, <8 x i8>* %67
%68 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131056
%69 = bitcast i8* %68 to <8 x i8>*
%70 = load <8 x i8>, <8 x i8>* %69
%71 = xor <8 x i8> %70, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%72 = bitcast i8* %68 to <8 x i8>*
store <8 x i8> %71, <8 x i8>* %72
%73 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131064
%74 = load i8, i8* %73
%75 = xor i8 %74, 1
store i8 %75, i8* %73
%76 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131065
%77 = load i8, i8* %76
%78 = xor i8 %77, 1
store i8 %78, i8* %76
%79 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131066
%80 = load i8, i8* %79
%81 = xor i8 %80, 1
store i8 %81, i8* %79
%82 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131067
%83 = load i8, i8* %82
%84 = xor i8 %83, 1
store i8 %84, i8* %82
%85 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131068
%86 = load i8, i8* %85
%87 = xor i8 %86, 1
store i8 %87, i8* %85
%88 = getelementptr inbounds [131070 x i8], [131070 x i8]* %3, i64 0, i64 131069
%89 = load i8, i8* %88
%90 = xor i8 %89, 1
store i8 %90, i8* %88
%91 = call i32 @seqprint(i8* %5, i32 %1)
ret void
}