#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 /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(void *, int, int, int /*<<< orphan*/ *);
int fwrite(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  typedef unsigned char f_mode;
  struct new_apg_bf_hdr {
    char id[5];
    char version[3];
    unsigned long int fs;
    f_mode mode;
  };
  struct old_apg_bf_hdr {
    char id[8];
    unsigned long int fs;
  };
  struct new_apg_bf_hdr new_bf_hdr;
  struct old_apg_bf_hdr old_bf_hdr;
  char old_etalon_bf_id[] = "APGBF101";
  char new_etalon_bf_id[] = "APGBF";
  char new_etalon_bf_ver[] = "110";
  FILE *old_f;
  FILE *new_f;
  unsigned char tmp_buf;
  if (argc != 3) {
    printf("Usage: bfconvert old_bf_file_name new_bf_file_name\n");
    return (-1);
  }
  if ((old_f = fopen(argv[1], "r")) == NULL) {
    perror("open the old bloom-filter file");
    return (-1);
  }
  if ((new_f = fopen(argv[2], "w")) == NULL) {
    perror("open the new bloom-filter file");
    return (-1);
  }
  if (fread((void *)&old_bf_hdr, 12, 1, old_f) != 1)
    if (ferror(old_f) != 0) {
      perror("read from the old bloom-filter file");
      return (-1);
    }
  if ((old_bf_hdr.id[0] != old_etalon_bf_id[0]) ||
      (old_bf_hdr.id[1] != old_etalon_bf_id[1]) ||
      (old_bf_hdr.id[2] != old_etalon_bf_id[2]) ||
      (old_bf_hdr.id[3] != old_etalon_bf_id[3]) ||
      (old_bf_hdr.id[4] != old_etalon_bf_id[4]) ||
      (old_bf_hdr.id[5] != old_etalon_bf_id[5]) ||
      (old_bf_hdr.id[6] != old_etalon_bf_id[6]) ||
      (old_bf_hdr.id[7] != old_etalon_bf_id[7])) {
    fprintf(stderr, "Input file is not APG bloom filter file v1.0.1\n");
    fflush(stderr);
    return (-1);
  }
  new_bf_hdr.id[0] = new_etalon_bf_id[0];
  new_bf_hdr.id[1] = new_etalon_bf_id[1];
  new_bf_hdr.id[2] = new_etalon_bf_id[2];
  new_bf_hdr.id[3] = new_etalon_bf_id[3];
  new_bf_hdr.id[4] = new_etalon_bf_id[4];
  new_bf_hdr.version[0] = new_etalon_bf_ver[0];
  new_bf_hdr.version[1] = new_etalon_bf_ver[1];
  new_bf_hdr.version[2] = new_etalon_bf_ver[2];
  new_bf_hdr.fs = old_bf_hdr.fs;
  new_bf_hdr.mode = 0x00;
  if (fwrite((void *)&new_bf_hdr, 13, 1, new_f) != 1) {
    perror("write to the new bloom-filter file");
    return (-1);
  }
  while (fread((void *)&tmp_buf, 1, 1, old_f) == 1) {
    if (fwrite((void *)&tmp_buf, 1, 1, new_f) != 1) {
      perror("write to the new bloom-filter file");
      return (-1);
    }
  }
  if (ferror(old_f) != 0) {
    perror("read from the old bloom-filter file");
    return (-1);
  }
  if (fclose(old_f) == EOF) {
    perror("close old bloom-filter file");
    return (-1);
  }
  if (fclose(new_f) == EOF) {
    perror("close new bloom-filter file");
    return (-1);
  }
  printf("\nInput file has been successfuly converted\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe53(%rip),%rax
mov    %rax,-0x41(%rbp)
mov    0xe51(%rip),%al
mov    %al,-0x39(%rbp)
mov    0xe49(%rip),%eax
mov    %eax,-0x47(%rbp)
mov    0xe43(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xe3b(%rip),%eax
mov    %eax,-0x4b(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11f9 <main+0x69>
lea    0xe2b(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1233 <main+0xa3>
lea    0xe27(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    126d <main+0xdd>
lea    0xe0e(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
lea    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0xc,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     12bd <main+0x12d>
mov    -0x58(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     12b8 <main+0x128>
lea    0xde2(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
jmp    12bd <main+0x12d>
movsbl -0x38(%rbp),%eax
movsbl -0x41(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x37(%rbp),%eax
movsbl -0x40(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x36(%rbp),%eax
movsbl -0x3f(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x35(%rbp),%eax
movsbl -0x3e(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x34(%rbp),%eax
movsbl -0x3d(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x33(%rbp),%eax
movsbl -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x32(%rbp),%eax
movsbl -0x3b(%rbp),%ecx
cmp    %ecx,%eax
jne    133d <main+0x1ad>
movsbl -0x31(%rbp),%eax
movsbl -0x3a(%rbp),%ecx
cmp    %ecx,%eax
je     136c <main+0x1dc>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
mov    -0x47(%rbp),%al
mov    %al,-0x28(%rbp)
mov    -0x46(%rbp),%al
mov    %al,-0x27(%rbp)
mov    -0x45(%rbp),%al
mov    %al,-0x26(%rbp)
mov    -0x44(%rbp),%al
mov    %al,-0x25(%rbp)
mov    -0x43(%rbp),%al
mov    %al,-0x24(%rbp)
mov    -0x4b(%rbp),%al
mov    %al,-0x23(%rbp)
mov    -0x4a(%rbp),%al
mov    %al,-0x22(%rbp)
mov    -0x49(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
mov    -0x60(%rbp),%rcx
mov    $0xd,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
je     13e0 <main+0x250>
lea    0xd0e(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
jmp    13e5 <main+0x255>
mov    -0x58(%rbp),%rcx
lea    -0x61(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    143c <main+0x2ac>
mov    -0x60(%rbp),%rcx
lea    -0x61(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
je     1437 <main+0x2a7>
lea    0xcb7(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
jmp    13e5 <main+0x255>
mov    -0x58(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1467 <main+0x2d7>
lea    0xc33(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2b71(%rip),%rcx
cmp    (%rcx),%rax
jne    1498 <main+0x308>
lea    0xc79(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
mov    -0x60(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2b40(%rip),%rcx
cmp    (%rcx),%rax
jne    14c9 <main+0x339>
lea    0xc64(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14dc <main+0x34c>
lea    0xc68(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
cmp    $0x3,%edi
jne    12b0 <main+0x120>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     131d <main+0x18d>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe55(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1326 <main+0x196>
mov    %rax,%r14
lea    0x8(%rsp),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
je     120a <main+0x7a>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    132f <main+0x19f>
movq   0x8(%rsp),%xmm0
movq   %xmm0,%rax
movabs $0x3130314642475041,%rcx
31 30 31
cmp    %rcx,%rax
jne    12c1 <main+0x131>
movabs $0x3031314642475041,%rax
31 31 30
mov    %rax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,0x20(%rsp)
movb   $0x0,0x28(%rsp)
lea    0x18(%rsp),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
jne    12a4 <main+0x114>
lea    0x7(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    12df <main+0x14f>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
cmp    $0x1,%eax
je     1270 <main+0xe0>
lea    0xdeb(%rip),%rdi
jmp    1348 <main+0x1b8>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
jmp    134d <main+0x1bd>
mov    0x2d10(%rip),%rbx
mov    (%rbx),%edi
lea    0xd95(%rip),%rsi
call   1070 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
jmp    134d <main+0x1bd>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    132f <main+0x19f>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x2ced(%rip),%rbx
cmp    (%rbx),%rax
je     1338 <main+0x1a8>
mov    %r14,%rdi
call   1060 <fclose@plt>
cmp    (%rbx),%rax
je     1341 <main+0x1b1>
lea    0xddd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    1352 <main+0x1c2>
lea    0xcde(%rip),%rdi
jmp    1348 <main+0x1b8>
lea    0xcf6(%rip),%rdi
jmp    1348 <main+0x1b8>
lea    0xd0c(%rip),%rdi
jmp    1348 <main+0x1b8>
lea    0xd7a(%rip),%rdi
jmp    1348 <main+0x1b8>
lea    0xd8d(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.new_apg_bf_hdr = type { [5 x i8], [3 x i8], i64, i8 }
%struct.old_apg_bf_hdr = type { [8 x i8], i64 }
@__const.main.old_etalon_bf_id = [9 x i8] c"APGBF101\00"
@__const.main.new_etalon_bf_id = [6 x i8] c"APGBF\00"
@__const.main.new_etalon_bf_ver = [4 x i8] c"110\00"
@.str = [52 x i8] c"Usage: bfconvert old_bf_file_name new_bf_file_name\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"open the old bloom-filter file\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [31 x i8] c"open the new bloom-filter file\00"
@.str.5 = [36 x i8] c"read from the old bloom-filter file\00"
@stderr = global i32 0
@.str.6 = [48 x i8] c"Input file is not APG bloom filter file v1.0.1\0A\00"
@.str.7 = [35 x i8] c"write to the new bloom-filter file\00"
@EOF = global i64 0
@.str.8 = [28 x i8] c"close old bloom-filter file\00"
@.str.9 = [28 x i8] c"close new bloom-filter file\00"
@.str.10 = [44 x i8] c"\0AInput file has been successfuly converted\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.new_apg_bf_hdr
%7 = alloca %struct.old_apg_bf_hdr
%8 = alloca [9 x i8]
%9 = alloca [6 x i8]
%10 = alloca [4 x i8]
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [9 x i8]* %8 to i8*
%15 = bitcast [6 x i8]* %9 to i8*
%16 = bitcast [4 x i8]* %10 to i8*
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %11
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
29: ; preds = %21
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %33, i32** %12
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
37: ; preds = %29
%38 = bitcast %struct.old_apg_bf_hdr* %7 to i8*
%39 = load i32*, i32** %11
%40 = call i32 @fread(i8* %38, i32 12, i32 1, i32* %39)
%41 = icmp ne i32 %40, 1
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i32*, i32** %11
%44 = call i64 @ferror(i32* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
48: ; preds = %42
br label %49
49: ; preds = %48, %37
%50 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%51 = getelementptr inbounds [8 x i8], [8 x i8]* %50, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %53, %56
br i1 %57, label %121, label %58
58: ; preds = %49
%59 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%60 = getelementptr inbounds [8 x i8], [8 x i8]* %59, i64 0, i64 1
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %62, %65
br i1 %66, label %121, label %67
67: ; preds = %58
%68 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%69 = getelementptr inbounds [8 x i8], [8 x i8]* %68, i64 0, i64 2
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 2
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %71, %74
br i1 %75, label %121, label %76
76: ; preds = %67
%77 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%78 = getelementptr inbounds [8 x i8], [8 x i8]* %77, i64 0, i64 3
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 3
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp ne i32 %80, %83
br i1 %84, label %121, label %85
85: ; preds = %76
%86 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%87 = getelementptr inbounds [8 x i8], [8 x i8]* %86, i64 0, i64 4
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 4
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %89, %92
br i1 %93, label %121, label %94
94: ; preds = %85
%95 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%96 = getelementptr inbounds [8 x i8], [8 x i8]* %95, i64 0, i64 5
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 5
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %98, %101
br i1 %102, label %121, label %103
103: ; preds = %94
%104 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%105 = getelementptr inbounds [8 x i8], [8 x i8]* %104, i64 0, i64 6
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 6
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp ne i32 %107, %110
br i1 %111, label %121, label %112
112: ; preds = %103
%113 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 0
%114 = getelementptr inbounds [8 x i8], [8 x i8]* %113, i64 0, i64 7
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = getelementptr inbounds [9 x i8], [9 x i8]* %8, i64 0, i64 7
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp ne i32 %116, %119
br i1 %120, label %121, label %126
121: ; preds = %112, %103, %94, %85, %76, %67, %58, %49
%122 = load i32, i32* @stderr
%123 = call i32 @fprintf(i32 %122, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%124 = load i32, i32* @stderr
%125 = call i32 @fflush(i32 %124)
store i32 -1, i32* %3
br label %203
126: ; preds = %112
%127 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%128 = load i8, i8* %127
%129 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 0
%130 = getelementptr inbounds [5 x i8], [5 x i8]* %129, i64 0, i64 0
store i8 %128, i8* %130
%131 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 1
%132 = load i8, i8* %131
%133 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 0
%134 = getelementptr inbounds [5 x i8], [5 x i8]* %133, i64 0, i64 1
store i8 %132, i8* %134
%135 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 2
%136 = load i8, i8* %135
%137 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 0
%138 = getelementptr inbounds [5 x i8], [5 x i8]* %137, i64 0, i64 2
store i8 %136, i8* %138
%139 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 3
%140 = load i8, i8* %139
%141 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 0
%142 = getelementptr inbounds [5 x i8], [5 x i8]* %141, i64 0, i64 3
store i8 %140, i8* %142
%143 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 4
%144 = load i8, i8* %143
%145 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 0
%146 = getelementptr inbounds [5 x i8], [5 x i8]* %145, i64 0, i64 4
store i8 %144, i8* %146
%147 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%148 = load i8, i8* %147
%149 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 1
%150 = getelementptr inbounds [3 x i8], [3 x i8]* %149, i64 0, i64 0
store i8 %148, i8* %150
%151 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 1
%152 = load i8, i8* %151
%153 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 1
%154 = getelementptr inbounds [3 x i8], [3 x i8]* %153, i64 0, i64 1
store i8 %152, i8* %154
%155 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 2
%156 = load i8, i8* %155
%157 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 1
%158 = getelementptr inbounds [3 x i8], [3 x i8]* %157, i64 0, i64 2
store i8 %156, i8* %158
%159 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %7, i32 0, i32 1
%160 = load i64, i64* %159
%161 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 2
store i64 %160, i64* %161
%162 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %6, i32 0, i32 3
store i8 0, i8* %162
%163 = bitcast %struct.new_apg_bf_hdr* %6 to i8*
%164 = load i32*, i32** %12
%165 = call i32 @fwrite(i8* %163, i32 13, i32 1, i32* %164)
%166 = icmp ne i32 %165, 1
br i1 %166, label %167, label %169
167: ; preds = %126
%168 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
169: ; preds = %126
br label %170
170: ; preds = %180, %169
%171 = load i32*, i32** %11
%172 = call i32 @fread(i8* %13, i32 1, i32 1, i32* %171)
%173 = icmp eq i32 %172, 1
br i1 %173, label %174, label %181
174: ; preds = %170
%175 = load i32*, i32** %12
%176 = call i32 @fwrite(i8* %13, i32 1, i32 1, i32* %175)
%177 = icmp ne i32 %176, 1
br i1 %177, label %178, label %180
178: ; preds = %174
%179 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
180: ; preds = %174
br label %170
181: ; preds = %170
%182 = load i32*, i32** %11
%183 = call i64 @ferror(i32* %182)
%184 = icmp ne i64 %183, 0
br i1 %184, label %185, label %187
185: ; preds = %181
%186 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
187: ; preds = %181
%188 = load i32*, i32** %11
%189 = call i64 @fclose(i32* %188)
%190 = load i64, i64* @EOF
%191 = icmp eq i64 %189, %190
br i1 %191, label %192, label %194
192: ; preds = %187
%193 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
194: ; preds = %187
%195 = load i32*, i32** %12
%196 = call i64 @fclose(i32* %195)
%197 = load i64, i64* @EOF
%198 = icmp eq i64 %196, %197
br i1 %198, label %199, label %201
199: ; preds = %194
%200 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %3
br label %203
201: ; preds = %194
%202 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %3
br label %203
203: ; preds = %201, %199, %192, %185, %178, %167, %121, %46, %35, %27, %19
%204 = load i32, i32* %3
ret i32 %204
}

LLVM IR (-O2):
%struct.new_apg_bf_hdr = type { [5 x i8], [3 x i8], i64, i8 }
%struct.old_apg_bf_hdr = type { [8 x i8], i64 }
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"open the old bloom-filter file\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [31 x i8] c"open the new bloom-filter file\00"
@.str.5 = [36 x i8] c"read from the old bloom-filter file\00"
@stderr = global i32 0
@.str.6 = [48 x i8] c"Input file is not APG bloom filter file v1.0.1\0A\00"
@.str.7 = [35 x i8] c"write to the new bloom-filter file\00"
@EOF = global i64 0
@.str.8 = [28 x i8] c"close old bloom-filter file\00"
@.str.9 = [28 x i8] c"close new bloom-filter file\00"
@str = [43 x i8] c"\0AInput file has been successfuly converted\00"
@str.11 = [51 x i8] c"Usage: bfconvert old_bf_file_name new_bf_file_name\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.new_apg_bf_hdr
%4 = alloca %struct.old_apg_bf_hdr
%5 = alloca i8
%6 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 0, i64 0
%7 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %4, i64 0, i32 0, i64 0
%8 = icmp eq i32 %0, 3
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.11, i64 0, i64 0))
br label %87
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %87
18: ; preds = %11
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %87
25: ; preds = %18
%26 = call i32 @fread(i8* %7, i32 12, i32 1, i32* %14)
%27 = icmp eq i32 %26, 1
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = tail call i64 @ferror(i32* %14)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %87
33: ; preds = %28, %25
%34 = bitcast %struct.old_apg_bf_hdr* %4 to <8 x i8>*
%35 = load <8 x i8>, <8 x i8>* %34
%36 = freeze <8 x i8> %35
%37 = bitcast <8 x i8> %36 to i64
%38 = icmp eq i64 %37, 3544387084570021953
br i1 %38, label %44, label %39
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = tail call i32 @fflush(i32 %42)
br label %87
44: ; preds = %33
store i8 65, i8* %6
%45 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 0, i64 1
store i8 80, i8* %45
%46 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 0, i64 2
store i8 71, i8* %46
%47 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 0, i64 3
store i8 66, i8* %47
%48 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 0, i64 4
store i8 70, i8* %48
%49 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 1, i64 0
store i8 49, i8* %49
%50 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 1, i64 1
store i8 49, i8* %50
%51 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 1, i64 2
store i8 48, i8* %51
%52 = getelementptr inbounds %struct.old_apg_bf_hdr, %struct.old_apg_bf_hdr* %4, i64 0, i32 1
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 2
store i64 %53, i64* %54
%55 = getelementptr inbounds %struct.new_apg_bf_hdr, %struct.new_apg_bf_hdr* %3, i64 0, i32 3
store i8 0, i8* %55
%56 = call i32 @fwrite(i8* %6, i32 13, i32 1, i32* %21)
%57 = icmp eq i32 %56, 1
br i1 %57, label %60, label %58
58: ; preds = %44
%59 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %87
60: ; preds = %44, %63
%61 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %14)
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %68
63: ; preds = %60
%64 = call i32 @fwrite(i8* %5, i32 1, i32 1, i32* %21)
%65 = icmp eq i32 %64, 1
br i1 %65, label %60, label %66
66: ; preds = %63
%67 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %87
68: ; preds = %60
%69 = tail call i64 @ferror(i32* %14)
%70 = icmp eq i64 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %68
%72 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %87
73: ; preds = %68
%74 = tail call i64 @fclose(i32* %14)
%75 = load i64, i64* @EOF
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %87
79: ; preds = %73
%80 = tail call i64 @fclose(i32* %21)
%81 = load i64, i64* @EOF
%82 = icmp eq i64 %80, %81
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %87
85: ; preds = %79
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %87
87: ; preds = %85, %83, %77, %71, %66, %58, %39, %31, %23, %16, %9
%88 = phi i32 [ -1, %9 ], [ -1, %16 ], [ -1, %23 ], [ -1, %31 ], [ -1, %39 ], [ -1, %58 ], [ -1, %66 ], [ -1, %71 ], [ -1, %77 ], [ -1, %83 ], [ 0, %85 ]
ret i32 %88
}