#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  uint16_t i;
  int j;
  int xor_flag;
  uint16_t result;
  printf("/*\n"
         " * This file is autogenerated by %s\n"
         " * See http://github.com/zqad/crc16-ccitt"
         " for more information\n"
         " */\n\n",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/zqad/crc16-ccitt/refs/heads/master/"
         "crc16-ccitt-generate-table.c");
  printf("#include <stdint.h>\n\n");
  printf("uint16_t crc16_ccitt_table[] = {\n\t");
  for (i = 0; i < 256; i++) {
    result = i << 8;
    for (j = 0; j < 8; j++) {
      xor_flag = result & 0x8000;
      result <<= 1;
      if (xor_flag)
        result ^= 0x1021;
    }
    printf("0x%04hX,", result);
    if ((i + 1) % 8)
      printf(" ");
    else if (i != 255)
      printf("\n\t");
  }
  printf("\n};\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    0xf3f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1228 <main+0x118>
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11ba <main+0xaa>
mov    -0x14(%rbp),%eax
and    $0x8000,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a7 <main+0x97>
mov    -0x14(%rbp),%eax
xor    $0x1021,%eax
mov    %eax,-0x14(%rbp)
jmp    11ac <main+0x9c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x64>
mov    -0x14(%rbp),%esi
lea    0xf7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f5 <main+0xe5>
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1215 <main+0x105>
cmpl   $0xff,-0x8(%rbp)
je     1210 <main+0x100>
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1215 <main+0x105>
jmp    121a <main+0x10a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <main+0x47>
lea    0xf1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xec1(%rip),%rdi
lea    0xf26(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xfde(%rip),%rdi
call   1040 <puts@plt>
lea    0xfa6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xfbb(%rip),%r15
lea    0xfb1(%rip),%r14
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    119f <main+0x6f>
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x200,%ebp
mov    %ebx,%r12d
cmp    $0x100,%ebx
je     1268 <main+0x138>
mov    %ebp,%eax
xor    $0x1021,%eax
test   $0x80,%r12b
cmove  %ebp,%eax
lea    (%rax,%rax,1),%ecx
mov    %ecx,%edx
xor    $0x1021,%edx
test   $0x8000,%eax
cmove  %ecx,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1021,%ecx
test   $0x8000,%edx
cmove  %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%edx
xor    $0x1021,%edx
test   $0x8000,%ecx
cmove  %eax,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1021,%ecx
test   $0x8000,%edx
cmove  %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%edx
xor    $0x1021,%edx
test   $0x8000,%ecx
cmove  %eax,%edx
lea    (%rdx,%rdx,1),%eax
mov    %eax,%ecx
xor    $0x1021,%ecx
test   $0x8000,%edx
cmove  %eax,%ecx
lea    (%rcx,%rcx,1),%eax
mov    %eax,%esi
xor    $0x1021,%esi
test   $0x8000,%ecx
cmove  %eax,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%r12),%ebx
test   $0x7,%bl
jne    1180 <main+0x50>
cmp    $0xff,%r12d
je     1268 <main+0x138>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118a <main+0x5a>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [108 x i8] c"/*\0A * This file is autogenerated by %s\0A * See http://github.com/zqad/crc16-ccitt for more information\0A */\0A\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zqad/crc16-ccitt/refs/heads/master/crc16-ccitt-generate-table.c\00"
@.str.2 = [22 x i8] c"#include <stdint.h>\0A\0A\00"
@.str.3 = [35 x i8] c"uint16_t crc16_ccitt_table[] = {\0A\09\00"
@.str.4 = [9 x i8] c"0x%04hX,\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [3 x i8] c"\0A\09\00"
@.str.7 = [5 x i8] c"\0A};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %9
9: ; preds = %48, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %51
12: ; preds = %9
%13 = load i32, i32* %2
%14 = shl i32 %13, 8
store i32 %14, i32* %5
store i32 0, i32* %3
br label %15
15: ; preds = %29, %12
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 8
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i32, i32* %5
%20 = and i32 %19, 32768
store i32 %20, i32* %4
%21 = load i32, i32* %5
%22 = shl i32 %21, 1
store i32 %22, i32* %5
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* %5
%27 = xor i32 %26, 4129
store i32 %27, i32* %5
br label %28
28: ; preds = %25, %18
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %15
32: ; preds = %15
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
%37 = srem i32 %36, 8
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %47
41: ; preds = %32
%42 = load i32, i32* %2
%43 = icmp ne i32 %42, 255
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %44, %41
br label %47
47: ; preds = %46, %39
br label %48
48: ; preds = %47
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %9
51: ; preds = %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [108 x i8] c"/*\0A * This file is autogenerated by %s\0A * See http://github.com/zqad/crc16-ccitt for more information\0A */\0A\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zqad/crc16-ccitt/refs/heads/master/crc16-ccitt-generate-table.c\00"
@.str.3 = [35 x i8] c"uint16_t crc16_ccitt_table[] = {\0A\09\00"
@.str.4 = [9 x i8] c"0x%04hX,\00"
@.str.6 = [3 x i8] c"\0A\09\00"
@str = [21 x i8] c"#include <stdint.h>\0A\00"
@str.8 = [4 x i8] c"\0A};\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([108 x i8], [108 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %4
4: ; preds = %0, %56
%5 = phi i32 [ 0, %0 ], [ %47, %56 ]
%6 = shl i32 %5, 9
%7 = and i32 %5, 128
%8 = icmp eq i32 %7, 0
%9 = xor i32 %6, 4129
%10 = select i1 %8, i32 %6, i32 %9
%11 = and i32 %10, 32768
%12 = shl i32 %10, 1
%13 = icmp eq i32 %11, 0
%14 = xor i32 %12, 4129
%15 = select i1 %13, i32 %12, i32 %14
%16 = and i32 %15, 32768
%17 = shl i32 %15, 1
%18 = icmp eq i32 %16, 0
%19 = xor i32 %17, 4129
%20 = select i1 %18, i32 %17, i32 %19
%21 = and i32 %20, 32768
%22 = shl i32 %20, 1
%23 = icmp eq i32 %21, 0
%24 = xor i32 %22, 4129
%25 = select i1 %23, i32 %22, i32 %24
%26 = and i32 %25, 32768
%27 = shl i32 %25, 1
%28 = icmp eq i32 %26, 0
%29 = xor i32 %27, 4129
%30 = select i1 %28, i32 %27, i32 %29
%31 = and i32 %30, 32768
%32 = shl i32 %30, 1
%33 = icmp eq i32 %31, 0
%34 = xor i32 %32, 4129
%35 = select i1 %33, i32 %32, i32 %34
%36 = and i32 %35, 32768
%37 = shl i32 %35, 1
%38 = icmp eq i32 %36, 0
%39 = xor i32 %37, 4129
%40 = select i1 %38, i32 %37, i32 %39
%41 = and i32 %40, 32768
%42 = shl i32 %40, 1
%43 = icmp eq i32 %41, 0
%44 = xor i32 %42, 4129
%45 = select i1 %43, i32 %42, i32 %44
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %45)
%47 = add nuw nsw i32 %5, 1
%48 = and i32 %47, 7
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %4
%51 = tail call i32 @putchar(i32 32)
br label %56
52: ; preds = %4
%53 = icmp eq i32 %5, 255
br i1 %53, label %58, label %54
54: ; preds = %52
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %56
56: ; preds = %50, %54
%57 = icmp eq i32 %47, 256
br i1 %57, label %58, label %4
58: ; preds = %52, %56
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}