#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char **argv) {
  uint8_t bytes[3];
  bytes[0] = 0x80;
  bytes[1] = 0;
  bytes[2] = 63;
  uint32_t crc;
  for (int i = 0; i < 3; i++) {
    crc = crc ^ (bytes[i] << 8);
    for (int j = 0; j < 8; j++) {
      if (crc & 0x8000) {
        crc = (crc << 1) ^ 0x1021;
      } else {
        crc = crc << 1;
      }
      printf("%u\n", crc);
    }
  }
  printf("%u\n", crc);
  printf("0x%02X 0x%02X\n", (crc >> 8) & 0xFF, crc & 0xFF);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x80,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x3f,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11cf <main+0xbf>
mov    -0x20(%rbp),%eax
movslq -0x24(%rbp),%rcx
mov    -0x1c(%rbp,%rcx,4),%ecx
shl    $0x8,%ecx
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x8,-0x28(%rbp)
jge    11bc <main+0xac>
mov    -0x20(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1194 <main+0x84>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
xor    $0x1021,%eax
mov    %eax,-0x20(%rbp)
jmp    119d <main+0x8d>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1166 <main+0x56>
jmp    11c1 <main+0xb1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1142 <main+0x32>
mov    -0x20(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
sar    $0x8,%esi
and    $0xff,%esi
mov    -0x20(%rbp),%edx
and    $0xff,%edx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x80,0xc(%rsp)
movl   $0x3f,0x14(%rsp)
mov    $0x80,%eax
lea    0xec8(%rip),%r14
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
shl    $0x8,%eax
xor    %ebx,%eax
lea    (%rax,%rax,1),%ecx
mov    %ecx,%r15d
xor    $0x1021,%r15d
test   $0x8000,%eax
cmove  %ecx,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%r15,%r15,1),%eax
mov    %eax,%ebx
xor    $0x1021,%ebx
test   $0x8000,%r15d
cmove  %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%rbx,%rbx,1),%eax
mov    %eax,%r15d
xor    $0x1021,%r15d
test   $0x8000,%ebx
cmove  %eax,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%r15,%r15,1),%eax
mov    %eax,%ebx
xor    $0x1021,%ebx
test   $0x8000,%r15d
cmove  %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%rbx,%rbx,1),%eax
mov    %eax,%r15d
xor    $0x1021,%r15d
test   $0x8000,%ebx
cmove  %eax,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%r15,%r15,1),%eax
mov    %eax,%ebx
xor    $0x1021,%ebx
test   $0x8000,%r15d
cmove  %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%rbx,%rbx,1),%eax
mov    %eax,%r15d
xor    $0x1021,%r15d
test   $0x8000,%ebx
cmove  %eax,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%r15,%r15,1),%eax
mov    %eax,%ebx
xor    $0x1021,%ebx
test   $0x8000,%r15d
cmove  %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%r12
je     1270 <main+0x160>
mov    0x10(%rsp,%r12,4),%eax
add    $0x1,%r12
jmp    1140 <main+0x30>
lea    0xd89(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl %bh,%esi
movzbl %bl,%edx
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0A\00"
@.str.1 = [15 x i8] c"0x%02X 0x%02X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
store i32 128, i32* %10
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 1
store i32 0, i32* %11
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 2
store i32 63, i32* %12
store i32 0, i32* %8
br label %13
13: ; preds = %45, %2
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %48
16: ; preds = %13
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = shl i32 %21, 8
%23 = xor i32 %17, %22
store i32 %23, i32* %7
store i32 0, i32* %9
br label %24
24: ; preds = %41, %16
%25 = load i32, i32* %9
%26 = icmp slt i32 %25, 8
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load i32, i32* %7
%29 = and i32 %28, 32768
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* %7
%33 = shl i32 %32, 1
%34 = xor i32 %33, 4129
store i32 %34, i32* %7
br label %38
35: ; preds = %27
%36 = load i32, i32* %7
%37 = shl i32 %36, 1
store i32 %37, i32* %7
br label %38
38: ; preds = %35, %31
%39 = load i32, i32* %7
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %24
44: ; preds = %24
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %13
48: ; preds = %13
%49 = load i32, i32* %7
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %7
%52 = ashr i32 %51, 8
%53 = and i32 %52, 255
%54 = load i32, i32* %7
%55 = and i32 %54, 255
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %53, i32 %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
@.str.1 = [15 x i8] c"0x%02X 0x%02X\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = bitcast [3 x i32]* %3 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32 128, i32* %5
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 0, i32* %6
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 63, i32* %7
br label %14
8: ; preds = %14
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %66)
%10 = lshr i32 %66, 8
%11 = and i32 %10, 255
%12 = and i32 %66, 255
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
ret i32 0
14: ; preds = %70, %2
%15 = phi i32 [ 128, %2 ], [ %72, %70 ]
%16 = phi i64 [ 0, %2 ], [ %68, %70 ]
%17 = phi i32 [ undef, %2 ], [ %66, %70 ]
%18 = shl i32 %15, 8
%19 = xor i32 %18, %17
%20 = and i32 %19, 32768
%21 = icmp eq i32 %20, 0
%22 = shl i32 %19, 1
%23 = xor i32 %22, 4129
%24 = select i1 %21, i32 %22, i32 %23
%25 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = and i32 %24, 32768
%27 = icmp eq i32 %26, 0
%28 = shl i32 %24, 1
%29 = xor i32 %28, 4129
%30 = select i1 %27, i32 %28, i32 %29
%31 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = and i32 %30, 32768
%33 = icmp eq i32 %32, 0
%34 = shl i32 %30, 1
%35 = xor i32 %34, 4129
%36 = select i1 %33, i32 %34, i32 %35
%37 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = and i32 %36, 32768
%39 = icmp eq i32 %38, 0
%40 = shl i32 %36, 1
%41 = xor i32 %40, 4129
%42 = select i1 %39, i32 %40, i32 %41
%43 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = and i32 %42, 32768
%45 = icmp eq i32 %44, 0
%46 = shl i32 %42, 1
%47 = xor i32 %46, 4129
%48 = select i1 %45, i32 %46, i32 %47
%49 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = and i32 %48, 32768
%51 = icmp eq i32 %50, 0
%52 = shl i32 %48, 1
%53 = xor i32 %52, 4129
%54 = select i1 %51, i32 %52, i32 %53
%55 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = and i32 %54, 32768
%57 = icmp eq i32 %56, 0
%58 = shl i32 %54, 1
%59 = xor i32 %58, 4129
%60 = select i1 %57, i32 %58, i32 %59
%61 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = and i32 %60, 32768
%63 = icmp eq i32 %62, 0
%64 = shl i32 %60, 1
%65 = xor i32 %64, 4129
%66 = select i1 %63, i32 %64, i32 %65
%67 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %66)
%68 = add nuw nsw i64 %16, 1
%69 = icmp eq i64 %68, 3
br i1 %69, label %8, label %70
70: ; preds = %14
%71 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 %68
%72 = load i32, i32* %71
br label %14
}