#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 */

/* Variables and functions */
int /*<<< orphan*/ BLKGETSIZE;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, unsigned long *);
scalar_t__ malloc(int);
int memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int fd1 = 0, fd2 = 0;
  unsigned char *buf1 = NULL;
  unsigned char *buf2 = NULL;
  unsigned long c = 0, min = 0;
  int res = 0;
  if (argc != 3) {
    fprintf(stderr, "Invalid number of parameters.\n");
    return EXIT_FAILURE;
  }
  fd1 = open(argv[1], O_RDONLY);
  if (fd1 < 0) {
    fprintf(stderr, "Failed to open first block device.\n");
    goto err;
  }
  fd2 = open(argv[2], O_RDONLY);
  if (fd2 < 0) {
    fprintf(stderr, "Failed to open second block device.\n");
    goto err;
  }
  ioctl(fd1, BLKGETSIZE, &c);
  fprintf(stdout, "First block device size: %lu\n", c);
  min = c;
  ioctl(fd2, BLKGETSIZE, &c);
  fprintf(stdout, "Second block device size: %lu\n", c);
  if (c < min) {
    min = c;
  }
  min = min / 8;
  buf1 = (unsigned char *)malloc(4096);
  if (!buf1) {
    fprintf(stderr, "Failed to allocate memory.\n");
    goto err;
  }
  memset(buf1, 0x00, 4096);
  buf2 = (unsigned char *)malloc(4096);
  if (!buf2) {
    fprintf(stderr, "Failed to allocate memory.\n");
    goto err;
  }
  memset(buf2, 0x00, 4096);
  fprintf(stdout, "Reading %lu blocks...\n", min);
  for (c = 0; c < min; c++) {
    memset(buf1, 0x00, 4096);
    memset(buf2, 0x00, 4096);
    res = read(fd1, buf1, 4096);
    if (res < 4096) {
      fprintf(stdout, "End of first block device.\n");
      break;
    }
    res = read(fd2, buf2, 4096);
    if (res < 4096) {
      fprintf(stdout, "End of first block device.\n");
      break;
    }
    res = memcmp(buf1, buf2, 4096);
    if (res != 0) {
      fprintf(stdout, "Block differ at block number : %lu\n", c);
    }
  }
  if (buf1)
    free(buf1);
  if (buf2)
    free(buf2);
  if (fd1 > 0)
    close(fd1);
  if (fd2 > 0)
    close(fd2);
  return EXIT_SUCCESS;
err:
  if (buf1)
    free(buf1);
  if (buf2)
    free(buf2);
  if (fd1 > 0)
    close(fd1);
  if (fd2 > 0)
    close(fd2);
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120d <main+0x7d>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    156f <main+0x3df>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    124c <main+0xbc>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <main+0x387>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    128b <main+0xfb>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <main+0x387>
mov    -0x14(%rbp),%edi
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1050 <ioctl@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2d03(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1050 <ioctl@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    1309 <main+0x179>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x3,%rax
mov    %rax,-0x38(%rbp)
mov    $0x1000,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    134a <main+0x1ba>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <main+0x387>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    $0x1000,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    138f <main+0x1ff>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1517 <main+0x387>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    14ba <main+0x32a>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1000,-0x3c(%rbp)
jge    142d <main+0x29d>
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14ba <main+0x32a>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1000,-0x3c(%rbp)
jge    146a <main+0x2da>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14ba <main+0x32a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x1000,%edx
call   1080 <memcmp@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     14a4 <main+0x314>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xc57(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14a9 <main+0x319>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    13c2 <main+0x232>
cmpq   $0x0,-0x20(%rbp)
je     14ce <main+0x33e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
je     14e2 <main+0x352>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x14(%rbp)
jle    14f4 <main+0x364>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x18(%rbp)
jle    1506 <main+0x376>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    0x2aab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    156f <main+0x3df>
cmpq   $0x0,-0x20(%rbp)
je     152b <main+0x39b>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
je     153f <main+0x3af>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x14(%rbp)
jle    1551 <main+0x3c1>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x18(%rbp)
jle    1563 <main+0x3d3>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    0x2a5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
cmp    $0x3,%edi
jne    12cd <main+0x13d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e2e(%rip),%rbp
mov    0x0(%rbp),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     1388 <main+0x1f8>
mov    %eax,%r15d
mov    0x10(%rbx),%rdi
mov    0x0(%rbp),%esi
call   10b0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
js     13a8 <main+0x218>
mov    0x2de5(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rsp,%r13
mov    %r15d,%edi
mov    %r13,%rdx
call   1050 <ioctl@plt>
mov    0x2dbd(%rip),%rbx
mov    (%rbx),%edi
mov    (%rsp),%rdx
lea    0xe58(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rsp),%r12
mov    0x0(%rbp),%esi
mov    %r14d,%edi
mov    %r13,%rdx
call   1050 <ioctl@plt>
mov    (%rbx),%edi
mov    (%rsp),%rdx
lea    0xe50(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rsp),%rax
cmp    %r12,%rax
cmovb  %rax,%r12
mov    $0x1000,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     13ba <main+0x22a>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    $0x1000,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1403 <main+0x273>
mov    %rax,%rbp
mov    %r12,%r13
shr    $0x3,%r13
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
movq   $0x0,(%rsp)
cmp    $0x8,%r12
mov    0x2cfa(%rip),%r12
jae    1305 <main+0x175>
jmp    143b <main+0x2ab>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
jmp    1398 <main+0x208>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp),%rax
add    $0x1,%rax
mov    %rax,(%rsp)
cmp    %r13,%rax
jae    143b <main+0x2ab>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
cmp    $0x1000,%eax
jl     1429 <main+0x299>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
cmp    $0x1000,%eax
jl     1429 <main+0x299>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1080 <memcmp@plt>
test   %eax,%eax
je     12f0 <main+0x160>
mov    (%r12),%edi
mov    (%rsp),%rdx
lea    0xd78(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12f0 <main+0x160>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xc87(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c22(%rip),%rbx
jmp    13f2 <main+0x262>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
jmp    13ca <main+0x23a>
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
lea    0xcdb(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
test   %r15d,%r15d
je     13de <main+0x24e>
mov    %r15d,%edi
call   1060 <close@plt>
mov    0x2be3(%rip),%rbx
test   %r14d,%r14d
jle    13f2 <main+0x262>
mov    %r14d,%edi
call   1060 <close@plt>
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
lea    0xc92(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15d,%r15d
jne    13d6 <main+0x246>
jmp    13de <main+0x24e>
mov    (%r12),%edi
lea    0xca4(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
test   %r15d,%r15d
jle    1458 <main+0x2c8>
mov    %r15d,%edi
call   1060 <close@plt>
mov    0x2b59(%rip),%rbx
test   %r14d,%r14d
jg     13ea <main+0x25a>
jmp    13f2 <main+0x262>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Invalid number of parameters.\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [36 x i8] c"Failed to open first block device.\0A\00"
@.str.2 = [37 x i8] c"Failed to open second block device.\0A\00"
@BLKGETSIZE = global i32 0
@stdout = global i32 0
@.str.3 = [30 x i8] c"First block device size: %lu\0A\00"
@.str.4 = [31 x i8] c"Second block device size: %lu\0A\00"
@.str.5 = [28 x i8] c"Failed to allocate memory.\0A\00"
@.str.6 = [23 x i8] c"Reading %lu blocks...\0A\00"
@.str.7 = [28 x i8] c"End of first block device.\0A\00"
@.str.8 = [36 x i8] c"Block differ at block number : %lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i64 0, i64* %10
store i64 0, i64* %11
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %178
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = call i32 @open(i8* %22, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %152
30: ; preds = %19
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* %33, i32 %34)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %152
41: ; preds = %30
%42 = load i32, i32* %6
%43 = load i32, i32* @BLKGETSIZE
%44 = call i32 @ioctl(i32 %42, i32 %43, i64* %10)
%45 = load i32, i32* @stdout
%46 = load i64, i64* %10
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %46)
%48 = load i64, i64* %10
store i64 %48, i64* %11
%49 = load i32, i32* %7
%50 = load i32, i32* @BLKGETSIZE
%51 = call i32 @ioctl(i32 %49, i32 %50, i64* %10)
%52 = load i32, i32* @stdout
%53 = load i64, i64* %10
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64 %53)
%55 = load i64, i64* %10
%56 = load i64, i64* %11
%57 = icmp ult i64 %55, %56
br i1 %57, label %58, label %60
58: ; preds = %41
%59 = load i64, i64* %10
store i64 %59, i64* %11
br label %60
60: ; preds = %58, %41
%61 = load i64, i64* %11
%62 = udiv i64 %61, 8
store i64 %62, i64* %11
%63 = call i64 @malloc(i32 4096)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %8
%65 = load i8*, i8** %8
%66 = icmp ne i8* %65, null
br i1 %66, label %70, label %67
67: ; preds = %60
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %152
70: ; preds = %60
%71 = load i8*, i8** %8
%72 = call i32 @memset(i8* %71, i32 0, i32 4096)
%73 = call i64 @malloc(i32 4096)
%74 = inttoptr i64 %73 to i8*
store i8* %74, i8** %9
%75 = load i8*, i8** %9
%76 = icmp ne i8* %75, null
br i1 %76, label %80, label %77
77: ; preds = %70
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %152
80: ; preds = %70
%81 = load i8*, i8** %9
%82 = call i32 @memset(i8* %81, i32 0, i32 4096)
%83 = load i32, i32* @stdout
%84 = load i64, i64* %11
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i64 %84)
store i64 0, i64* %10
br label %86
86: ; preds = %123, %80
%87 = load i64, i64* %10
%88 = load i64, i64* %11
%89 = icmp ult i64 %87, %88
br i1 %89, label %90, label %126
90: ; preds = %86
%91 = load i8*, i8** %8
%92 = call i32 @memset(i8* %91, i32 0, i32 4096)
%93 = load i8*, i8** %9
%94 = call i32 @memset(i8* %93, i32 0, i32 4096)
%95 = load i32, i32* %6
%96 = load i8*, i8** %8
%97 = call i32 @read(i32 %95, i8* %96, i32 4096)
store i32 %97, i32* %12
%98 = load i32, i32* %12
%99 = icmp slt i32 %98, 4096
br i1 %99, label %100, label %103
100: ; preds = %90
%101 = load i32, i32* @stdout
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
br label %126
103: ; preds = %90
%104 = load i32, i32* %7
%105 = load i8*, i8** %9
%106 = call i32 @read(i32 %104, i8* %105, i32 4096)
store i32 %106, i32* %12
%107 = load i32, i32* %12
%108 = icmp slt i32 %107, 4096
br i1 %108, label %109, label %112
109: ; preds = %103
%110 = load i32, i32* @stdout
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
br label %126
112: ; preds = %103
%113 = load i8*, i8** %8
%114 = load i8*, i8** %9
%115 = call i32 @memcmp(i8* %113, i8* %114, i32 4096)
store i32 %115, i32* %12
%116 = load i32, i32* %12
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %112
%119 = load i32, i32* @stdout
%120 = load i64, i64* %10
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %120)
br label %122
122: ; preds = %118, %112
br label %123
123: ; preds = %122
%124 = load i64, i64* %10
%125 = add i64 %124, 1
store i64 %125, i64* %10
br label %86
126: ; preds = %109, %100, %86
%127 = load i8*, i8** %8
%128 = icmp ne i8* %127, null
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = load i8*, i8** %8
%131 = call i32 @free(i8* %130)
br label %132
132: ; preds = %129, %126
%133 = load i8*, i8** %9
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %138
135: ; preds = %132
%136 = load i8*, i8** %9
%137 = call i32 @free(i8* %136)
br label %138
138: ; preds = %135, %132
%139 = load i32, i32* %6
%140 = icmp sgt i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %138
%142 = load i32, i32* %6
%143 = call i32 @close(i32 %142)
br label %144
144: ; preds = %141, %138
%145 = load i32, i32* %7
%146 = icmp sgt i32 %145, 0
br i1 %146, label %147, label %150
147: ; preds = %144
%148 = load i32, i32* %7
%149 = call i32 @close(i32 %148)
br label %150
150: ; preds = %147, %144
%151 = load i32, i32* @EXIT_SUCCESS
store i32 %151, i32* %3
br label %178
152: ; preds = %77, %67, %38, %27
%153 = load i8*, i8** %8
%154 = icmp ne i8* %153, null
br i1 %154, label %155, label %158
155: ; preds = %152
%156 = load i8*, i8** %8
%157 = call i32 @free(i8* %156)
br label %158
158: ; preds = %155, %152
%159 = load i8*, i8** %9
%160 = icmp ne i8* %159, null
br i1 %160, label %161, label %164
161: ; preds = %158
%162 = load i8*, i8** %9
%163 = call i32 @free(i8* %162)
br label %164
164: ; preds = %161, %158
%165 = load i32, i32* %6
%166 = icmp sgt i32 %165, 0
br i1 %166, label %167, label %170
167: ; preds = %164
%168 = load i32, i32* %6
%169 = call i32 @close(i32 %168)
br label %170
170: ; preds = %167, %164
%171 = load i32, i32* %7
%172 = icmp sgt i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %170
%174 = load i32, i32* %7
%175 = call i32 @close(i32 %174)
br label %176
176: ; preds = %173, %170
%177 = load i32, i32* @EXIT_FAILURE
store i32 %177, i32* %3
br label %178
178: ; preds = %176, %150, %15
%179 = load i32, i32* %3
ret i32 %179
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Invalid number of parameters.\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [36 x i8] c"Failed to open first block device.\0A\00"
@.str.2 = [37 x i8] c"Failed to open second block device.\0A\00"
@BLKGETSIZE = global i32 0
@stdout = global i32 0
@.str.3 = [30 x i8] c"First block device size: %lu\0A\00"
@.str.4 = [31 x i8] c"Second block device size: %lu\0A\00"
@.str.5 = [28 x i8] c"Failed to allocate memory.\0A\00"
@.str.6 = [23 x i8] c"Reading %lu blocks...\0A\00"
@.str.7 = [28 x i8] c"End of first block device.\0A\00"
@.str.8 = [36 x i8] c"Block differ at block number : %lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %103
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %103
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = tail call i32 @open(i8* %20, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %95
27: ; preds = %18
%28 = load i32, i32* @BLKGETSIZE
%29 = call i32 @ioctl(i32 %13, i32 %28, i64* %3)
%30 = load i32, i32* @stdout
%31 = load i64, i64* %3
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %31)
%33 = load i64, i64* %3
%34 = load i32, i32* @BLKGETSIZE
%35 = call i32 @ioctl(i32 %22, i32 %34, i64* %3)
%36 = load i32, i32* @stdout
%37 = load i64, i64* %3
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64 %37)
%39 = load i64, i64* %3
%40 = icmp ult i64 %39, %33
%41 = select i1 %40, i64 %39, i64 %33
%42 = lshr i64 %41, 3
%43 = call i64 @malloc(i32 4096)
%44 = inttoptr i64 %43 to i8*
%45 = icmp eq i64 %43, 0
br i1 %45, label %46, label %49
46: ; preds = %27
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %95
49: ; preds = %27
%50 = call i32 @memset(i8* %44, i32 0, i32 4096)
%51 = call i64 @malloc(i32 4096)
%52 = inttoptr i64 %51 to i8*
%53 = icmp eq i64 %51, 0
br i1 %53, label %91, label %54
54: ; preds = %49
%55 = call i32 @memset(i8* %52, i32 0, i32 4096)
%56 = load i32, i32* @stdout
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i64 %42)
store i64 0, i64* %3
%58 = icmp ult i64 %41, 8
br i1 %58, label %81, label %59
59: ; preds = %54, %74
%60 = call i32 @memset(i8* %44, i32 0, i32 4096)
%61 = call i32 @memset(i8* %52, i32 0, i32 4096)
%62 = call i32 @read(i32 %13, i8* %44, i32 4096)
%63 = icmp slt i32 %62, 4096
br i1 %63, label %78, label %64
64: ; preds = %59
%65 = call i32 @read(i32 %22, i8* %52, i32 4096)
%66 = icmp slt i32 %65, 4096
br i1 %66, label %78, label %67
67: ; preds = %64
%68 = call i32 @memcmp(i8* %44, i8* %52, i32 4096)
%69 = icmp eq i32 %68, 0
br i1 %69, label %74, label %70
70: ; preds = %67
%71 = load i32, i32* @stdout
%72 = load i64, i64* %3
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %72)
br label %74
74: ; preds = %67, %70
%75 = load i64, i64* %3
%76 = add i64 %75, 1
store i64 %76, i64* %3
%77 = icmp ult i64 %76, %42
br i1 %77, label %59, label %81
78: ; preds = %64, %59
%79 = load i32, i32* @stdout
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
br label %81
81: ; preds = %74, %78, %54
%82 = call i32 @free(i8* %44)
%83 = call i32 @free(i8* %52)
%84 = icmp sgt i32 %13, 0
br i1 %84, label %85, label %87
85: ; preds = %81
%86 = call i32 @close(i32 %13)
br label %87
87: ; preds = %85, %81
%88 = icmp sgt i32 %22, 0
br i1 %88, label %89, label %103
89: ; preds = %87
%90 = call i32 @close(i32 %22)
br label %103
91: ; preds = %49
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%94 = call i32 @free(i8* %44)
br label %95
95: ; preds = %46, %24, %91
%96 = icmp eq i32 %13, 0
br i1 %96, label %99, label %97
97: ; preds = %95
%98 = call i32 @close(i32 %13)
br label %99
99: ; preds = %97, %95
%100 = icmp sgt i32 %22, 0
br i1 %100, label %101, label %103
101: ; preds = %99
%102 = call i32 @close(i32 %22)
br label %103
103: ; preds = %15, %99, %101, %87, %89, %6
%104 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %89 ], [ @EXIT_SUCCESS, %87 ], [ @EXIT_FAILURE, %101 ], [ @EXIT_FAILURE, %99 ], [ @EXIT_FAILURE, %15 ]
%105 = load i32, i32* %104
ret i32 %105
}