#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 unsigned long uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
unsigned short crc_ccitt_update(unsigned short, unsigned long);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned long *, int, unsigned long,
                         int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int fwrite(unsigned long *, unsigned long, int, int /*<<< orphan*/ *);
unsigned long *malloc(unsigned long);
int /*<<< orphan*/ memset(unsigned long *, int, unsigned long);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
unsigned long strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 5) {
    printf("Usage: crcgen <filename> <length> <signature> <version>\r\n");
    return 1;
  }
  unsigned long length = strtol(argv[2], NULL, 0);
  unsigned long devid = strtol(argv[3], NULL, 0);
  unsigned long version = strtol(argv[4], NULL, 0);
  if (length > length + 8) {
    printf("Ha ha, very funny.\n");
    return 1;
  }
  uint8_t *data = malloc(length + 8);
  if (!data) {
    perror("malloc");
    return 1;
  }
  memset(data, 0xff, length);
  FILE *f;
  f = fopen(argv[1], "rb+");
  if (f == 0) {
    printf("Unable to open file %s\r\n", argv[1]);
    return 1;
  }
  fread(data, 1, length, f);
  data[length - 8] = (devid & 0xFF);
  data[length - 7] = ((devid >> 8) & 0xFF);
  data[length - 6] = ((devid >> 16) & 0xff);
  data[length - 5] = ((devid >> 24) & 0xff);
  data[length - 4] = (version & 0xFF);
  data[length - 3] = ((version >> 8) & 0xFF);
  unsigned long l;
  unsigned short crc = 0xFFFF;
  for (l = 0; l < length - 2; l++)
    crc = crc_ccitt_update(crc, data[l]);
  data[length - 2] = (crc & 0xFF);
  data[length - 1] = ((crc >> 8) & 0xFF);
  if (fseek(f, 0, SEEK_SET)) {
    perror("fseek");
    return 1;
  }
  if (fwrite(data, length, 1, f) != 1) {
    perror("fwrite");
    return 1;
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11ea <main+0x3a>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jbe    125e <main+0xae>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1292 <main+0xe2>
lea    0xdcd(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xff,%esi
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xda2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12e9 <main+0x139>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x20(%rbp),%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x8,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
shr    $0x8,%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x7,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
shr    $0x10,%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x6,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdx
shr    $0x18,%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x5,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x4,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdx
shr    $0x8,%rdx
and    $0xff,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x3,%rcx
mov    %rdx,(%rax,%rcx,8)
movw   $0xffff,-0x42(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jae    1401 <main+0x251>
mov    -0x42(%rbp),%ax
mov    -0x30(%rbp),%rcx
mov    -0x40(%rbp),%rdx
mov    (%rcx,%rdx,8),%rsi
movzwl %ax,%edi
call   1080 <crc_ccitt_update@plt>
mov    %ax,-0x42(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    13bf <main+0x20f>
movzwl -0x42(%rbp),%eax
and    $0xff,%eax
movslq %eax,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
mov    %rdx,(%rax,%rcx,8)
movzwl -0x42(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
movslq %eax,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%rdi
mov    0x2b99(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
cmp    $0x0,%rax
je     1472 <main+0x2c2>
lea    0xc11(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
je     14a9 <main+0x2f9>
lea    0xbe0(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14b9 <main+0x309>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x5,%edi
jne    1211 <main+0x51>
mov    %rsi,%r12
mov    0x10(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %rax,%r14
mov    0x18(%r12),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %rax,%rbx
mov    0x20(%r12),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
cmp    $0xfffffffffffffff8,%r14
jb     1233 <main+0x73>
lea    0xe22(%rip),%rdi
jmp    1218 <main+0x58>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%rbp
lea    0x8(%r14),%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     135c <main+0x19c>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1070 <memset@plt>
mov    0x8(%r12),%rdi
lea    0xda0(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12eb <main+0x12b>
mov    %rax,%r15
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <fread@plt>
movzbl %bl,%eax
mov    %rax,-0x40(%r13,%r14,8)
movzbl %bh,%eax
mov    %rax,-0x38(%r13,%r14,8)
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %rax,-0x30(%r13,%r14,8)
shr    $0x18,%ebx
mov    %rbx,-0x28(%r13,%r14,8)
mov    %rbp,%rcx
movzbl %cl,%eax
mov    %rax,-0x20(%r13,%r14,8)
movzbl %ch,%eax
mov    %rax,-0x18(%r13,%r14,8)
mov    %r14,%rbp
add    $0xfffffffffffffffe,%rbp
je     1303 <main+0x143>
mov    $0xffff,%ax
xor    %ebx,%ebx
xchg   %ax,%ax
mov    0x0(%r13,%rbx,8),%rsi
movzwl %ax,%edi
call   1090 <crc_ccitt_update@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12d0 <main+0x110>
movzwl %ax,%eax
jmp    1308 <main+0x148>
mov    0x8(%r12),%rsi
lea    0xd14(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    121d <main+0x5d>
mov    $0xffff,%eax
movzbl %al,%ecx
mov    %rcx,-0x10(%r13,%r14,8)
shr    $0x8,%eax
mov    %rax,-0x8(%r13,%r14,8)
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
test   %rax,%rax
jne    1365 <main+0x1a5>
mov    $0x1,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
call   10e0 <fwrite@plt>
cmp    $0x1,%eax
jne    1376 <main+0x1b6>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %ebp,%ebp
jmp    1222 <main+0x62>
lea    0xc9d(%rip),%rdi
jmp    136c <main+0x1ac>
lea    0xcb8(%rip),%rdi
call   10d0 <perror@plt>
jmp    121d <main+0x5d>
lea    0xcad(%rip),%rdi
call   10d0 <perror@plt>
jmp    1222 <main+0x62>

LLVM IR (-O0):
@.str = [58 x i8] c"Usage: crcgen <filename> <length> <signature> <version>\0D\0A\00"
@.str.1 = [20 x i8] c"Ha ha, very funny.\0A\00"
@.str.2 = [7 x i8] c"malloc\00"
@.str.3 = [4 x i8] c"rb+\00"
@.str.4 = [25 x i8] c"Unable to open file %s\0D\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [6 x i8] c"fseek\00"
@.str.6 = [7 x i8] c"fwrite\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 5
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %154
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i64 @strtol(i8* %20, i32* null, i32 0)
store i64 %21, i64* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i64 @strtol(i8* %24, i32* null, i32 0)
store i64 %25, i64* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i64 @strtol(i8* %28, i32* null, i32 0)
store i64 %29, i64* %8
%30 = load i64, i64* %6
%31 = load i64, i64* %6
%32 = add i64 %31, 8
%33 = icmp ugt i64 %30, %32
br i1 %33, label %34, label %36
34: ; preds = %17
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %154
36: ; preds = %17
%37 = load i64, i64* %6
%38 = add i64 %37, 8
%39 = call i64* @malloc(i64 %38)
store i64* %39, i64** %9
%40 = load i64*, i64** %9
%41 = icmp ne i64* %40, null
br i1 %41, label %44, label %42
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %154
44: ; preds = %36
%45 = load i64*, i64** %9
%46 = load i64, i64* %6
%47 = call i32 @memset(i64* %45, i32 255, i64 %46)
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32* %51, i32** %10
%52 = load i32*, i32** %10
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %59
54: ; preds = %44
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %57)
store i32 1, i32* %3
br label %154
59: ; preds = %44
%60 = load i64*, i64** %9
%61 = load i64, i64* %6
%62 = load i32*, i32** %10
%63 = call i32 @fread(i64* %60, i32 1, i64 %61, i32* %62)
%64 = load i64, i64* %7
%65 = and i64 %64, 255
%66 = load i64*, i64** %9
%67 = load i64, i64* %6
%68 = sub i64 %67, 8
%69 = getelementptr inbounds i64, i64* %66, i64 %68
store i64 %65, i64* %69
%70 = load i64, i64* %7
%71 = lshr i64 %70, 8
%72 = and i64 %71, 255
%73 = load i64*, i64** %9
%74 = load i64, i64* %6
%75 = sub i64 %74, 7
%76 = getelementptr inbounds i64, i64* %73, i64 %75
store i64 %72, i64* %76
%77 = load i64, i64* %7
%78 = lshr i64 %77, 16
%79 = and i64 %78, 255
%80 = load i64*, i64** %9
%81 = load i64, i64* %6
%82 = sub i64 %81, 6
%83 = getelementptr inbounds i64, i64* %80, i64 %82
store i64 %79, i64* %83
%84 = load i64, i64* %7
%85 = lshr i64 %84, 24
%86 = and i64 %85, 255
%87 = load i64*, i64** %9
%88 = load i64, i64* %6
%89 = sub i64 %88, 5
%90 = getelementptr inbounds i64, i64* %87, i64 %89
store i64 %86, i64* %90
%91 = load i64, i64* %8
%92 = and i64 %91, 255
%93 = load i64*, i64** %9
%94 = load i64, i64* %6
%95 = sub i64 %94, 4
%96 = getelementptr inbounds i64, i64* %93, i64 %95
store i64 %92, i64* %96
%97 = load i64, i64* %8
%98 = lshr i64 %97, 8
%99 = and i64 %98, 255
%100 = load i64*, i64** %9
%101 = load i64, i64* %6
%102 = sub i64 %101, 3
%103 = getelementptr inbounds i64, i64* %100, i64 %102
store i64 %99, i64* %103
store i16 -1, i16* %12
store i64 0, i64* %11
br label %104
104: ; preds = %116, %59
%105 = load i64, i64* %11
%106 = load i64, i64* %6
%107 = sub i64 %106, 2
%108 = icmp ult i64 %105, %107
br i1 %108, label %109, label %119
109: ; preds = %104
%110 = load i16, i16* %12
%111 = load i64*, i64** %9
%112 = load i64, i64* %11
%113 = getelementptr inbounds i64, i64* %111, i64 %112
%114 = load i64, i64* %113
%115 = call zeroext i16 @crc_ccitt_update(i16 zeroext %110, i64 %114)
store i16 %115, i16* %12
br label %116
116: ; preds = %109
%117 = load i64, i64* %11
%118 = add i64 %117, 1
store i64 %118, i64* %11
br label %104
119: ; preds = %104
%120 = load i16, i16* %12
%121 = zext i16 %120 to i32
%122 = and i32 %121, 255
%123 = sext i32 %122 to i64
%124 = load i64*, i64** %9
%125 = load i64, i64* %6
%126 = sub i64 %125, 2
%127 = getelementptr inbounds i64, i64* %124, i64 %126
store i64 %123, i64* %127
%128 = load i16, i16* %12
%129 = zext i16 %128 to i32
%130 = ashr i32 %129, 8
%131 = and i32 %130, 255
%132 = sext i32 %131 to i64
%133 = load i64*, i64** %9
%134 = load i64, i64* %6
%135 = sub i64 %134, 1
%136 = getelementptr inbounds i64, i64* %133, i64 %135
store i64 %132, i64* %136
%137 = load i32*, i32** %10
%138 = load i32, i32* @SEEK_SET
%139 = call i64 @fseek(i32* %137, i32 0, i32 %138)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %119
%142 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %154
143: ; preds = %119
%144 = load i64*, i64** %9
%145 = load i64, i64* %6
%146 = load i32*, i32** %10
%147 = call i32 @fwrite(i64* %144, i64 %145, i32 1, i32* %146)
%148 = icmp ne i32 %147, 1
br i1 %148, label %149, label %151
149: ; preds = %143
%150 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %154
151: ; preds = %143
%152 = load i32*, i32** %10
%153 = call i32 @fclose(i32* %152)
store i32 0, i32* %3
br label %154
154: ; preds = %151, %149, %141, %54, %42, %34, %15
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"malloc\00"
@.str.3 = [4 x i8] c"rb+\00"
@.str.4 = [25 x i8] c"Unable to open file %s\0D\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [6 x i8] c"fseek\00"
@.str.6 = [7 x i8] c"fwrite\00"
@str = [19 x i8] c"Ha ha, very funny.\00"
@str.7 = [57 x i8] c"Usage: crcgen <filename> <length> <signature> <version>\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.7, i64 0, i64 0))
br label %91
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @strtol(i8* nocapture %8, i32* null, i32 0)
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 0)
%13 = getelementptr inbounds i8*, i8** %1, i64 4
%14 = load i8*, i8** %13
%15 = tail call i64 @strtol(i8* nocapture %14, i32* null, i32 0)
%16 = icmp ugt i64 %9, -9
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %91
19: ; preds = %6
%20 = add nuw i64 %9, 8
%21 = tail call i64* @malloc(i64 %20)
%22 = icmp eq i64* %21, null
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %91
25: ; preds = %19
%26 = tail call i32 @memset(i64* %21, i32 255, i64 %9)
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i8*, i8** %27
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %32)
br label %91
34: ; preds = %25
%35 = tail call i32 @fread(i64* %21, i32 1, i64 %9, i32* %29)
%36 = and i64 %12, 255
%37 = add i64 %9, -8
%38 = getelementptr inbounds i64, i64* %21, i64 %37
store i64 %36, i64* %38
%39 = lshr i64 %12, 8
%40 = and i64 %39, 255
%41 = add i64 %9, -7
%42 = getelementptr inbounds i64, i64* %21, i64 %41
store i64 %40, i64* %42
%43 = lshr i64 %12, 16
%44 = and i64 %43, 255
%45 = add i64 %9, -6
%46 = getelementptr inbounds i64, i64* %21, i64 %45
store i64 %44, i64* %46
%47 = lshr i64 %12, 24
%48 = and i64 %47, 255
%49 = add i64 %9, -5
%50 = getelementptr inbounds i64, i64* %21, i64 %49
store i64 %48, i64* %50
%51 = and i64 %15, 255
%52 = add i64 %9, -4
%53 = getelementptr inbounds i64, i64* %21, i64 %52
store i64 %51, i64* %53
%54 = lshr i64 %15, 8
%55 = and i64 %54, 255
%56 = add i64 %9, -3
%57 = getelementptr inbounds i64, i64* %21, i64 %56
store i64 %55, i64* %57
%58 = add i64 %9, -2
%59 = icmp eq i64 %58, 0
br i1 %59, label %70, label %60
60: ; preds = %34, %60
%61 = phi i16 [ %65, %60 ], [ -1, %34 ]
%62 = phi i64 [ %66, %60 ], [ 0, %34 ]
%63 = getelementptr inbounds i64, i64* %21, i64 %62
%64 = load i64, i64* %63
%65 = tail call zeroext i16 @crc_ccitt_update(i16 zeroext %61, i64 %64)
%66 = add nuw i64 %62, 1
%67 = icmp eq i64 %66, %58
br i1 %67, label %68, label %60
68: ; preds = %60
%69 = zext i16 %65 to i32
br label %70
70: ; preds = %68, %34
%71 = phi i32 [ 65535, %34 ], [ %69, %68 ]
%72 = and i32 %71, 255
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i64, i64* %21, i64 %58
store i64 %73, i64* %74
%75 = lshr i32 %71, 8
%76 = zext i32 %75 to i64
%77 = add i64 %9, -1
%78 = getelementptr inbounds i64, i64* %21, i64 %77
store i64 %76, i64* %78
%79 = load i32, i32* @SEEK_SET
%80 = tail call i64 @fseek(i32* %29, i32 0, i32 %79)
%81 = icmp eq i64 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %70
%83 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %91
84: ; preds = %70
%85 = tail call i32 @fwrite(i64* %21, i64 %9, i32 1, i32* %29)
%86 = icmp eq i32 %85, 1
br i1 %86, label %89, label %87
87: ; preds = %84
%88 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %91
89: ; preds = %84
%90 = tail call i32 @fclose(i32* %29)
br label %91
91: ; preds = %17, %31, %89, %87, %82, %23, %4
%92 = phi i32 [ 1, %4 ], [ 1, %17 ], [ 1, %23 ], [ 1, %31 ], [ 1, %82 ], [ 1, %87 ], [ 0, %89 ]
ret i32 %92
}