#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*/ uint8_t;
typedef scalar_t__ ssize_t;
typedef int off_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ find_marker_v1(int /*<<< orphan*/ *, scalar_t__);
scalar_t__ find_marker_v2(int /*<<< orphan*/ *, scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int lseek(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ *malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ read(int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int verify_v1(int, int /*<<< orphan*/);
int verify_v2(int, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int in;
  off_t device_size, nio, total_read;
  uint8_t *buf;
  ssize_t marker_ofs;
  int marker_ver;
  if (argc <= 1) {
    printf("Usage:\n  cdrverify device\n");
    return 1;
  }
  in = open(argv[1], O_RDONLY);
  if (in == -1) {
    fprintf(stderr, "cdrverify: failed to open device %s\n", argv[1]);
    return 1;
  }
  device_size = lseek(in, 0, SEEK_END);
  if (device_size == (off_t)-1) {
    fprintf(stderr, "cdrverify: lseek() failed (%s)\n", strerror(errno));
    return 1;
  }
  buf = malloc((1024 * 1024));
  nio = (device_size + (1024 * 1024) - 1) / (1024 * 1024);
  marker_ver = 0;
  marker_ofs = -1;
  total_read = 0;
  printf("scanning for marker...");
  fflush(stdout);
  while (nio > 0 && total_read < (16 * 1024 * 1024)) {
    ssize_t len, m1, m2;
    --nio;
    if (lseek(in, nio * (1024 * 1024), SEEK_SET) == (off_t)-1) {
      fprintf(stderr, "cdrverify: lseek() failed (%s)\n", strerror(errno));
      return 1;
    }
    if ((len = read(in, buf, (1024 * 1024))) <= 0) {
      fprintf(stderr, "cdrverify: read() failed (%s)\n", strerror(errno));
      return 1;
    }
    total_read += len;
    m1 = find_marker_v1(buf, len);
    m2 = find_marker_v2(buf, len);
    if (m2 >= 0 && m2 >= m1) {
      marker_ver = 2;
      marker_ofs = m2;
      break;
    } else if (m1 >= 0) {
      marker_ver = 1;
      marker_ofs = m1;
      break;
    }
  }
  int r = 1;
  switch (marker_ver) {
  case 1:
    printf(" found v1.\n");
    r = verify_v1(in, buf + marker_ofs);
    break;
  case 2:
    printf(" found v2.\n");
    r = verify_v2(in, buf + marker_ofs);
    break;
  default:
    printf(" not found\n");
  }
  free(buf);
  return r;
}


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)
cmpl   $0x1,-0x8(%rbp)
jg     1208 <main+0x38>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150b <main+0x33b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1254 <main+0x84>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd8(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150b <main+0x33b>
mov    -0x14(%rbp),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    12ac <main+0xdc>
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xda5(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150b <main+0x33b>
mov    $0x100000,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x100000,%eax
sub    $0x1,%eax
mov    $0x100000,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x34(%rbp)
movq   $0xffffffffffffffff,-0x30(%rbp)
ff
movl   $0x0,-0x20(%rbp)
lea    0xd73(%rip),%rdi
call   1040 <printf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x59(%rbp)
jle    131c <main+0x14c>
cmpl   $0x1000000,-0x20(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    132c <main+0x15c>
jmp    146a <main+0x29a>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
shl    $0x14,%esi
mov    0x2c7b(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
jne    138d <main+0x1bd>
mov    0x2c74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x60(%rbp),%edi
mov    %rax,%rdx
lea    0xcc4(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150b <main+0x33b>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x100000,%edx
call   1070 <read@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jg     13e4 <main+0x214>
mov    0x2c1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xca4(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    150b <main+0x33b>
mov    -0x40(%rbp),%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10f0 <find_marker_v1@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <find_marker_v2@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jl     1441 <main+0x271>
mov    -0x50(%rbp),%rax
cmp    -0x48(%rbp),%rax
jl     1441 <main+0x271>
movl   $0x2,-0x34(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    146a <main+0x29a>
cmpq   $0x0,-0x48(%rbp)
jl     1460 <main+0x290>
movl   $0x1,-0x34(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    146a <main+0x29a>
jmp    1465 <main+0x295>
jmp    1300 <main+0x130>
movl   $0x1,-0x54(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x68(%rbp)
sub    $0x1,%eax
je     1496 <main+0x2c6>
jmp    1485 <main+0x2b5>
mov    -0x68(%rbp),%eax
sub    $0x2,%eax
je     14c3 <main+0x2f3>
jmp    14f0 <main+0x320>
lea    0xbf9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,%esi
call   10d0 <verify_v1@plt>
mov    %eax,-0x54(%rbp)
jmp    14fc <main+0x32c>
lea    0xbd8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,%esi
call   1060 <verify_v2@plt>
mov    %eax,-0x54(%rbp)
jmp    14fc <main+0x32c>
lea    0xbb7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1,%edi
jg     1204 <main+0x24>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
jmp    13f3 <main+0x213>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     135c <main+0x17c>
mov    %eax,%r15d
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
cmp    $0xffffffff,%eax
je     1372 <main+0x192>
mov    %eax,%ebp
mov    %r15d,0xc(%rsp)
mov    $0x100000,%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
lea    0xfffff(%rbp),%eax
add    $0x1ffffe,%ebp
test   %eax,%eax
cmovns %eax,%ebp
mov    %ebp,%r15d
sar    $0x14,%r15d
lea    0xdce(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
and    $0xfff00000,%ebp
add    $0xfff00000,%ebp
mov    %r13,0x10(%rsp)
jmp    12bb <main+0xdb>
nopl   (%rax)
add    %ebx,%r14d
add    $0xfff00000,%ebp
add    $0xffffffff,%r15d
test   %r12,%r12
mov    0x10(%rsp),%r13
jns    13a5 <main+0x1c5>
test   %r15d,%r15d
jle    1392 <main+0x1b2>
cmp    $0xffffff,%r14d
jg     1392 <main+0x1b2>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edx
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <lseek@plt>
cmp    $0xffffffff,%eax
je     1372 <main+0x192>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x100000,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    13cb <main+0x1eb>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
call   1100 <find_marker_v1@plt>
mov    %rax,%r12
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <find_marker_v2@plt>
test   %rax,%rax
js     12a0 <main+0xc0>
mov    %rax,%r13
cmp    %r12,%rax
jl     12a0 <main+0xc0>
lea    0xd3b(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%rax
lea    (%rax,%r13,4),%esi
mov    %rax,%r13
mov    0xc(%rsp),%edi
call   1070 <verify_v2@plt>
jmp    13bf <main+0x1df>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xc90(%rip),%rsi
jmp    13ee <main+0x20e>
mov    0x2c57(%rip),%rax
mov    (%rax),%ebx
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc95(%rip),%rsi
jmp    13e9 <main+0x209>
lea    0xcf8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    13c1 <main+0x1e1>
lea    0xcda(%rip),%rdi
call   1040 <puts@plt>
lea    0x0(%r13,%r12,4),%esi
mov    0xc(%rsp),%edi
call   10e0 <verify_v1@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1030 <free@plt>
jmp    13f8 <main+0x218>
mov    0x2bfe(%rip),%rax
mov    (%rax),%ebx
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc73(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10a0 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Usage:\0A cdrverify device\0A\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [37 x i8] c"cdrverify: failed to open device %s\0A\00"
@SEEK_END = global i32 0
@.str.2 = [32 x i8] c"cdrverify: lseek() failed (%s)\0A\00"
@errno = global i32 0
@.str.3 = [23 x i8] c"scanning for marker...\00"
@stdout = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [31 x i8] c"cdrverify: read() failed (%s)\0A\00"
@.str.5 = [12 x i8] c" found v1.\0A\00"
@.str.6 = [12 x i8] c" found v2.\0A\00"
@.str.7 = [12 x i8] c" not found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp sle i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %138
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = call i32 @open(i8* %24, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %138
35: ; preds = %21
%36 = load i32, i32* %6
%37 = load i32, i32* @SEEK_END
%38 = call i32 @lseek(i32 %36, i32 0, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %44)
store i32 1, i32* %3
br label %138
46: ; preds = %35
%47 = call i32* @malloc(i32 1048576)
store i32* %47, i32** %10
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1048576
%50 = sub nsw i32 %49, 1
%51 = sdiv i32 %50, 1048576
store i32 %51, i32* %8
store i32 0, i32* %12
store i64 -1, i64* %11
store i32 0, i32* %9
%52 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* @stdout
%54 = call i32 @fflush(i32 %53)
br label %55
55: ; preds = %113, %46
%56 = load i32, i32* %8
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* %9
%60 = icmp slt i32 %59, 16777216
br label %61
61: ; preds = %58, %55
%62 = phi i1 [ false, %55 ], [ %60, %58 ]
br i1 %62, label %63, label %114
63: ; preds = %61
%64 = load i32, i32* %8
%65 = add nsw i32 %64, -1
store i32 %65, i32* %8
%66 = load i32, i32* %6
%67 = load i32, i32* %8
%68 = mul nsw i32 %67, 1048576
%69 = load i32, i32* @SEEK_SET
%70 = call i32 @lseek(i32 %66, i32 %68, i32 %69)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %77
72: ; preds = %63
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = call i8* @strerror(i32 %74)
%76 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %75)
store i32 1, i32* %3
br label %138
77: ; preds = %63
%78 = load i32, i32* %6
%79 = load i32*, i32** %10
%80 = call i64 @read(i32 %78, i32* %79, i32 1048576)
store i64 %80, i64* %13
%81 = icmp sle i64 %80, 0
br i1 %81, label %82, label %87
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %85)
store i32 1, i32* %3
br label %138
87: ; preds = %77
%88 = load i64, i64* %13
%89 = load i32, i32* %9
%90 = sext i32 %89 to i64
%91 = add nsw i64 %90, %88
%92 = trunc i64 %91 to i32
store i32 %92, i32* %9
%93 = load i32*, i32** %10
%94 = load i64, i64* %13
%95 = call i64 @find_marker_v1(i32* %93, i64 %94)
store i64 %95, i64* %14
%96 = load i32*, i32** %10
%97 = load i64, i64* %13
%98 = call i64 @find_marker_v2(i32* %96, i64 %97)
store i64 %98, i64* %15
%99 = load i64, i64* %15
%100 = icmp sge i64 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %87
%102 = load i64, i64* %15
%103 = load i64, i64* %14
%104 = icmp sge i64 %102, %103
br i1 %104, label %105, label %107
105: ; preds = %101
store i32 2, i32* %12
%106 = load i64, i64* %15
store i64 %106, i64* %11
br label %114
107: ; preds = %101, %87
%108 = load i64, i64* %14
%109 = icmp sge i64 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %107
store i32 1, i32* %12
%111 = load i64, i64* %14
store i64 %111, i64* %11
br label %114
112: ; preds = %107
br label %113
113: ; preds = %112
br label %55
114: ; preds = %110, %105, %61
store i32 1, i32* %16
%115 = load i32, i32* %12
switch i32 %115, label %132 [
i32 1, label %116
i32 2, label %124
]
116: ; preds = %114
%117 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%118 = load i32, i32* %6
%119 = load i32*, i32** %10
%120 = load i64, i64* %11
%121 = getelementptr inbounds i32, i32* %119, i64 %120
%122 = ptrtoint i32* %121 to i32
%123 = call i32 @verify_v1(i32 %118, i32 %122)
store i32 %123, i32* %16
br label %134
124: ; preds = %114
%125 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%126 = load i32, i32* %6
%127 = load i32*, i32** %10
%128 = load i64, i64* %11
%129 = getelementptr inbounds i32, i32* %127, i64 %128
%130 = ptrtoint i32* %129 to i32
%131 = call i32 @verify_v2(i32 %126, i32 %130)
store i32 %131, i32* %16
br label %134
132: ; preds = %114
%133 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %134
134: ; preds = %132, %124, %116
%135 = load i32*, i32** %10
%136 = call i32 @free(i32* %135)
%137 = load i32, i32* %16
store i32 %137, i32* %3
br label %138
138: ; preds = %134, %82, %72, %41, %29, %19
%139 = load i32, i32* %3
ret i32 %139
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [37 x i8] c"cdrverify: failed to open device %s\0A\00"
@SEEK_END = global i32 0
@.str.2 = [32 x i8] c"cdrverify: lseek() failed (%s)\0A\00"
@errno = global i32 0
@.str.3 = [23 x i8] c"scanning for marker...\00"
@stdout = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [31 x i8] c"cdrverify: read() failed (%s)\0A\00"
@str = [11 x i8] c" found v2.\00"
@str.8 = [11 x i8] c" found v1.\00"
@str.9 = [11 x i8] c" not found\00"
@str.10 = [26 x i8] c"Usage:\0A cdrverify device\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.10, i64 0, i64 0))
br label %84
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %7
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %84
16: ; preds = %6
%17 = load i32, i32* @SEEK_END
%18 = tail call i32 @lseek(i32 %10, i32 0, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %84
25: ; preds = %16
%26 = tail call i32* @malloc(i32 1048576)
%27 = add nsw i32 %18, 1048575
%28 = sdiv i32 %27, 1048576
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @stdout
%31 = tail call i32 @fflush(i32 %30)
br label %32
32: ; preds = %63, %25
%33 = phi i32 [ 0, %25 ], [ %65, %63 ]
%34 = phi i32 [ %28, %25 ], [ %39, %63 ]
%35 = icmp sgt i32 %34, 0
%36 = icmp slt i32 %33, 16777216
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %38, label %79
38: ; preds = %32
%39 = add nsw i32 %34, -1
%40 = shl nsw i32 %39, 20
%41 = load i32, i32* @SEEK_SET
%42 = tail call i32 @lseek(i32 %10, i32 %40, i32 %41)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %49
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = tail call i8* @strerror(i32 %46)
%48 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %84
49: ; preds = %38
%50 = tail call i64 @read(i32 %10, i32* %26, i32 1048576)
%51 = icmp slt i64 %50, 1
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = tail call i8* @strerror(i32 %54)
%56 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %55)
br label %84
57: ; preds = %49
%58 = tail call i64 @find_marker_v1(i32* %26, i64 %50)
%59 = tail call i64 @find_marker_v2(i32* %26, i64 %50)
%60 = icmp slt i64 %59, 0
%61 = icmp slt i64 %59, %58
%62 = select i1 %60, i1 true, i1 %61
br i1 %62, label %63, label %73
63: ; preds = %57
%64 = trunc i64 %50 to i32
%65 = add i32 %33, %64
%66 = icmp sgt i64 %58, -1
br i1 %66, label %67, label %32
67: ; preds = %63
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%69 = getelementptr inbounds i32, i32* %26, i64 %58
%70 = ptrtoint i32* %69 to i64
%71 = trunc i64 %70 to i32
%72 = tail call i32 @verify_v1(i32 %10, i32 %71)
br label %81
73: ; preds = %57
%74 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%75 = getelementptr inbounds i32, i32* %26, i64 %59
%76 = ptrtoint i32* %75 to i64
%77 = trunc i64 %76 to i32
%78 = tail call i32 @verify_v2(i32 %10, i32 %77)
br label %81
79: ; preds = %32
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
br label %81
81: ; preds = %79, %73, %67
%82 = phi i32 [ 1, %79 ], [ %78, %73 ], [ %72, %67 ]
%83 = tail call i32 @free(i32* %26)
br label %84
84: ; preds = %52, %44, %81, %20, %12, %4
%85 = phi i32 [ 1, %4 ], [ 1, %12 ], [ 1, %20 ], [ %82, %81 ], [ 1, %44 ], [ 1, %52 ]
ret i32 %85
}