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

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, char *, size_t);
int comfirm_checksum(char *, char *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
unsigned int strlen(char *);
int compare_checksums(char *str_file1, char *str_file2, size_t size_rd) {
  unsigned int len1, len2;
  unsigned int cpt1 = 0, cpt2 = 0;
  MD5_CTX ctx1, ctx2;
  unsigned char digest1[MD5_DIGEST_LENGTH], digest2[MD5_DIGEST_LENGTH];
  MD5_Init(&ctx1);
  MD5_Init(&ctx2);
  len1 = strlen(str_file1);
  len2 = strlen(str_file2);
  while (len1 > cpt1 && len2 > cpt2) {
    MD5_Update(&ctx1, str_file1 + cpt1, size_rd);
    MD5_Update(&ctx2, str_file1 + cpt2, size_rd);
    cpt1 += size_rd;
    cpt2 += size_rd;
  }
  MD5_Final(digest1, &ctx1);
  MD5_Final(digest2, &ctx2);
  if (memcmp(digest1, digest2, MD5_DIGEST_LENGTH) == 0)
    return comfirm_checksum(str_file1, str_file2);
  return -1;
}


x86 assembly (clang, -O0):
<compare_checksums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x68(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
lea    -0x34(%rbp),%rdi
call   1060 <MD5_Init@plt>
lea    -0x38(%rbp),%rdi
call   1060 <MD5_Init@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x2c(%rbp),%ecx
mov    %al,-0x69(%rbp)
jbe    1213 <compare_checksums+0xb3>
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
seta   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    1223 <compare_checksums+0xc3>
jmp    1270 <compare_checksums+0x110>
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%eax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
lea    -0x34(%rbp),%rdi
call   1070 <MD5_Update@plt>
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%eax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
lea    -0x38(%rbp),%rdi
call   1070 <MD5_Update@plt>
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x30(%rbp)
jmp    11f6 <compare_checksums+0x96>
mov    -0x68(%rbp),%rdi
lea    -0x34(%rbp),%rsi
call   1030 <MD5_Final@plt>
mov    -0x60(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <MD5_Final@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    0x2d47(%rip),%rax
mov    (%rax),%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    12c6 <compare_checksums+0x166>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <comfirm_checksum@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    12d4 <compare_checksums+0x174>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_checksums>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,-0x58(%rbp)
mov    0x2e5b(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    (%rcx),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
lea    -0x30(%rbp),%rdi
call   1060 <MD5_Init@plt>
lea    -0x2c(%rbp),%rdi
call   1060 <MD5_Init@plt>
mov    %r14,-0x38(%rbp)
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r15,-0x40(%rbp)
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %r14d,%r14d
je     1222 <compare_checksums+0xc2>
mov    %eax,%r15d
test   %eax,%eax
je     1222 <compare_checksums+0xc2>
xor    %r12d,%r12d
nop
mov    %r12d,%r13d
add    -0x38(%rbp),%r13
lea    -0x30(%rbp),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <MD5_Update@plt>
lea    -0x2c(%rbp),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <MD5_Update@plt>
add    %ebx,%r12d
cmp    %r12d,%r14d
jbe    1222 <compare_checksums+0xc2>
cmp    %r12d,%r15d
ja     11f0 <compare_checksums+0x90>
lea    -0x30(%rbp),%rsi
mov    -0x50(%rbp),%r14
mov    %r14,%rdi
call   1030 <MD5_Final@plt>
lea    -0x2c(%rbp),%rsi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdi
call   1030 <MD5_Final@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <memcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1270 <compare_checksums+0x110>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <comfirm_checksum@plt>
mov    -0x58(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
define i32 @compare_checksums(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i32 0, i32* %10
store i32 0, i32* %11
%18 = load i32, i32* @MD5_DIGEST_LENGTH
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %14
%21 = alloca i8, i64 %19
store i64 %19, i64* %15
%22 = load i32, i32* @MD5_DIGEST_LENGTH
%23 = zext i32 %22 to i64
%24 = alloca i8, i64 %23
store i64 %23, i64* %16
%25 = call i32 @MD5_Init(i32* %12)
%26 = call i32 @MD5_Init(i32* %13)
%27 = load i8*, i8** %5
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %8
%29 = load i8*, i8** %6
%30 = call i32 @strlen(i8* %29)
store i32 %30, i32* %9
br label %31
31: ; preds = %41, %3
%32 = load i32, i32* %8
%33 = load i32, i32* %10
%34 = icmp ugt i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %9
%37 = load i32, i32* %11
%38 = icmp ugt i32 %36, %37
br label %39
39: ; preds = %35, %31
%40 = phi i1 [ false, %31 ], [ %38, %35 ]
br i1 %40, label %41, label %64
41: ; preds = %39
%42 = load i8*, i8** %5
%43 = load i32, i32* %10
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i64, i64* %7
%47 = call i32 @MD5_Update(i32* %12, i8* %45, i64 %46)
%48 = load i8*, i8** %5
%49 = load i32, i32* %11
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i64, i64* %7
%53 = call i32 @MD5_Update(i32* %13, i8* %51, i64 %52)
%54 = load i64, i64* %7
%55 = load i32, i32* %10
%56 = zext i32 %55 to i64
%57 = add i64 %56, %54
%58 = trunc i64 %57 to i32
store i32 %58, i32* %10
%59 = load i64, i64* %7
%60 = load i32, i32* %11
%61 = zext i32 %60 to i64
%62 = add i64 %61, %59
%63 = trunc i64 %62 to i32
store i32 %63, i32* %11
br label %31
64: ; preds = %39
%65 = call i32 @MD5_Final(i8* %21, i32* %12)
%66 = call i32 @MD5_Final(i8* %24, i32* %13)
%67 = load i32, i32* @MD5_DIGEST_LENGTH
%68 = call i64 @memcmp(i8* %21, i8* %24, i32 %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %64
%71 = load i8*, i8** %5
%72 = load i8*, i8** %6
%73 = call i32 @comfirm_checksum(i8* %71, i8* %72)
store i32 %73, i32* %4
store i32 1, i32* %17
br label %75
74: ; preds = %64
store i32 -1, i32* %4
store i32 1, i32* %17
br label %75
75: ; preds = %74, %70
%76 = load i8*, i8** %14
%77 = load i32, i32* %4
ret i32 %77
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
define i32 @compare_checksums(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = load i32, i32* @MD5_DIGEST_LENGTH
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = load i32, i32* @MD5_DIGEST_LENGTH
%13 = zext i32 %12 to i64
%14 = alloca i8, i64 %13
%15 = call i32 @MD5_Init(i32* %4)
%16 = call i32 @MD5_Init(i32* %5)
%17 = call i32 @strlen(i8* %0)
%18 = call i32 @strlen(i8* %1)
%19 = icmp ne i32 %17, 0
%20 = icmp ne i32 %18, 0
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %34
22: ; preds = %3
%23 = trunc i64 %2 to i32
br label %24
24: ; preds = %22, %24
%25 = phi i32 [ 0, %22 ], [ %30, %24 ]
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = call i32 @MD5_Update(i32* %4, i8* %27, i64 %2)
%29 = call i32 @MD5_Update(i32* %5, i8* %27, i64 %2)
%30 = add i32 %25, %23
%31 = icmp ugt i32 %17, %30
%32 = icmp ugt i32 %18, %30
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %24, label %34
34: ; preds = %24, %3
%35 = call i32 @MD5_Final(i8* %11, i32* %4)
%36 = call i32 @MD5_Final(i8* %14, i32* %5)
%37 = load i32, i32* @MD5_DIGEST_LENGTH
%38 = call i64 @memcmp(i8* %11, i8* %14, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 @comfirm_checksum(i8* %0, i8* %1)
br label %42
42: ; preds = %34, %40
%43 = phi i32 [ %41, %40 ], [ -1, %34 ]
ret i32 %43
}