#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int EXIT_FAILURE;
scalar_t__ clock();
int /*<<< orphan*/ free(char *);
char *get_string_file(char *);
int /*<<< orphan*/ printf(char *, ...);
int rsync(char *, char *, int);
int rsync_checksum(char *, char *, int);
int main(int ac, char **av) {
  int ret = EXIT_FAILURE;
  char *buf1, *buf2;
  if (ac == 3) {
    if (!(buf1 = get_string_file(av[1])) || !(buf2 = get_string_file(av[2])))
      return ret;
    clock_t begin, end;
    float time_spent;
    begin = clock();
    ret = rsync(buf1, buf2, 512);
    end = clock();
    time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
    printf("RSync result: %s Time %0.2f\n", ret == 0 ? "EQUAL" : "FAIL",
           time_spent);
    begin = clock();
    ret = rsync_checksum(buf1, buf2, 512);
    end = clock();
    time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
    printf("Checksum result: %s Time %0.2f\n", ret == 0 ? "EQUAL" : "FAIL",
           time_spent);
    free(buf1);
    free(buf2);
  } else
    printf("I need arguments ./my_rsync /path/file/1 /path/file/2\n");
  return ret;
}


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)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    12da <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <get_string_file@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <get_string_file@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11cd <main+0x6d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ee <main+0x18e>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x200,%edx
call   1080 <rsync@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2ddc(%rip),%rax
divsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xe00(%rip),%rsi
lea    0xdf3(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbf(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x200,%edx
call   1070 <rsync_checksum@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d61(%rip),%rax
divsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xd85(%rip),%rsi
lea    0xd78(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    12e8 <main+0x188>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%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
mov    0x2e56(%rip),%rax
mov    (%rax),%ebp
cmp    $0x3,%edi
jne    1287 <main+0x117>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <get_string_file@plt>
test   %rax,%rax
je     1293 <main+0x123>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
call   1070 <get_string_file@plt>
test   %rax,%rax
je     1293 <main+0x123>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x200,%edx
call   1090 <rsync@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2dfc(%rip),%rax
divsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
test   %ebp,%ebp
lea    0xe20(%rip),%r13
lea    0xe1f(%rip),%rbx
mov    %rbx,%rsi
cmove  %r13,%rsi
cvtss2sd %xmm0,%xmm0
lea    0xdea(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x200,%edx
call   1080 <rsync_checksum@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r12,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2d96(%rip),%rax
divsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
test   %ebp,%ebp
cmove  %r13,%rbx
cvtss2sd %xmm0,%xmm0
lea    0xdbd(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1293 <main+0x123>
lea    0xdba(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [29 x i8] c"RSync result: %s Time %0.2f\0A\00"
@.str.1 = [6 x i8] c"EQUAL\00"
@.str.2 = [5 x i8] c"FAIL\00"
@.str.3 = [32 x i8] c"Checksum result: %s Time %0.2f\0A\00"
@.str.4 = [55 x i8] c"I need arguments ./my_rsync /path/file/1 /path/file/2\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %72
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i8* @get_string_file(i8* %18)
store i8* %19, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i8* @get_string_file(i8* %24)
store i8* %25, i8** %8
%26 = icmp ne i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %21, %15
%28 = load i32, i32* %6
store i32 %28, i32* %3
br label %76
29: ; preds = %21
%30 = call i64 (...) @clock()
store i64 %30, i64* %9
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = call i32 @rsync(i8* %31, i8* %32, i32 512)
store i32 %33, i32* %6
%34 = call i64 (...) @clock()
store i64 %34, i64* %10
%35 = load i64, i64* %10
%36 = load i64, i64* %9
%37 = sub nsw i64 %35, %36
%38 = sitofp i64 %37 to double
%39 = load double, double* @CLOCKS_PER_SEC
%40 = fdiv double %38, %39
%41 = fptrunc double %40 to float
store float %41, float* %11
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%46 = load float, float* %11
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %45, double %47)
%49 = call i64 (...) @clock()
store i64 %49, i64* %9
%50 = load i8*, i8** %7
%51 = load i8*, i8** %8
%52 = call i32 @rsync_checksum(i8* %50, i8* %51, i32 512)
store i32 %52, i32* %6
%53 = call i64 (...) @clock()
store i64 %53, i64* %10
%54 = load i64, i64* %10
%55 = load i64, i64* %9
%56 = sub nsw i64 %54, %55
%57 = sitofp i64 %56 to double
%58 = load double, double* @CLOCKS_PER_SEC
%59 = fdiv double %57, %58
%60 = fptrunc double %59 to float
store float %60, float* %11
%61 = load i32, i32* %6
%62 = icmp eq i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%65 = load float, float* %11
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %64, double %66)
%68 = load i8*, i8** %7
%69 = call i32 @free(i8* %68)
%70 = load i8*, i8** %8
%71 = call i32 @free(i8* %70)
br label %74
72: ; preds = %2
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %72, %29
%75 = load i32, i32* %6
store i32 %75, i32* %3
br label %76
76: ; preds = %74, %27
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [29 x i8] c"RSync result: %s Time %0.2f\0A\00"
@.str.1 = [6 x i8] c"EQUAL\00"
@.str.2 = [5 x i8] c"FAIL\00"
@.str.3 = [32 x i8] c"Checksum result: %s Time %0.2f\0A\00"
@str = [54 x i8] c"I need arguments ./my_rsync /path/file/1 /path/file/2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @EXIT_FAILURE
%4 = icmp eq i32 %0, 3
br i1 %4, label %5, label %42
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i8* @get_string_file(i8* %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %44, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i8* @get_string_file(i8* %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %44, label %15
15: ; preds = %10
%16 = tail call i64 (...) @clock()
%17 = tail call i32 @rsync(i8* %8, i8* %13, i32 512)
%18 = tail call i64 (...) @clock()
%19 = sub nsw i64 %18, %16
%20 = sitofp i64 %19 to double
%21 = load double, double* @CLOCKS_PER_SEC
%22 = fdiv double %20, %21
%23 = fptrunc double %22 to float
%24 = icmp eq i32 %17, 0
%25 = select i1 %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%26 = fpext float %23 to double
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %25, double %26)
%28 = tail call i64 (...) @clock()
%29 = tail call i32 @rsync_checksum(i8* %8, i8* %13, i32 512)
%30 = tail call i64 (...) @clock()
%31 = sub nsw i64 %30, %28
%32 = sitofp i64 %31 to double
%33 = load double, double* @CLOCKS_PER_SEC
%34 = fdiv double %32, %33
%35 = fptrunc double %34 to float
%36 = icmp eq i32 %29, 0
%37 = select i1 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%38 = fpext float %35 to double
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %37, double %38)
%40 = tail call i32 @free(i8* %8)
%41 = tail call i32 @free(i8* %13)
br label %44
42: ; preds = %2
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %15, %42, %5, %10
%45 = phi i32 [ %3, %10 ], [ %3, %5 ], [ %29, %15 ], [ %3, %42 ]
ret i32 %45
}