#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 time_t;

/* Variables and functions */
int /*<<< orphan*/ mfm_get_size_text(long long, char *);
int /*<<< orphan*/ mfm_show_message(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int time(int /*<<< orphan*/ *);
void mfm_copy_progress(long long cur, long long ttl) {
  static time_t tm = 0;
  if (time(NULL) - tm < 1) {
    return;
  }
  char mess[80];
  char cur_txt[40], ttl_txt[40];
  mfm_get_size_text(cur, cur_txt);
  mfm_get_size_text(ttl, ttl_txt);
  sprintf(mess, "Done %s  of  %s", cur_txt, ttl_txt);
  mfm_show_message(mess, 0);
  tm = time(NULL);
}


x86 assembly (clang, -O0):
<mfm_copy_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
sub    0x2ee2(%rip),%eax
cmp    $0x1,%eax
jge    1170 <mfm_copy_progress+0x30>
jmp    11c8 <mfm_copy_progress+0x88>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <mfm_get_size_text@plt>
mov    -0x10(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1040 <mfm_get_size_text@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    0xe57(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
call   1030 <mfm_show_message@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,0x2e7c(%rip)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfm_copy_progress>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
cmp    0x2ee3(%rip),%eax
jle    11b2 <mfm_copy_progress+0x72>
lea    0x30(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <mfm_get_size_text@plt>
mov    %rsp,%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <mfm_get_size_text@plt>
lea    0xe78(%rip),%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <mfm_show_message@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x2e92(%rip)
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@mfm_copy_progress.tm = internal global i32 0
@.str = [16 x i8] c"Done %s of %s\00"
define void @mfm_copy_progress(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [80 x i8]
%6 = alloca [40 x i8]
%7 = alloca [40 x i8]
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = call i32 @time(i32* null)
%9 = load i32, i32* @mfm_copy_progress.tm
%10 = sub nsw i32 %8, %9
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
br label %27
13: ; preds = %2
%14 = load i64, i64* %3
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%16 = call i32 @mfm_get_size_text(i64 %14, i8* %15)
%17 = load i64, i64* %4
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%19 = call i32 @mfm_get_size_text(i64 %17, i8* %18)
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%23 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%25 = call i32 @mfm_show_message(i8* %24, i32 0)
%26 = call i32 @time(i32* null)
store i32 %26, i32* @mfm_copy_progress.tm
br label %27
27: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
@mfm_copy_progress.tm = internal unnamed_addr global i32 0
@.str = [16 x i8] c"Done %s of %s\00"
define void @mfm_copy_progress(i64 %0, i64 %1) {
%3 = alloca [80 x i8]
%4 = alloca [40 x i8]
%5 = alloca [40 x i8]
%6 = tail call i32 @time(i32* null)
%7 = load i32, i32* @mfm_copy_progress.tm
%8 = icmp sgt i32 %6, %7
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%13 = call i32 @mfm_get_size_text(i64 %0, i8* %11)
%14 = call i32 @mfm_get_size_text(i64 %1, i8* %12)
%15 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%16 = call i32 @mfm_show_message(i8* %10, i32 0)
%17 = call i32 @time(i32* null)
store i32 %17, i32* @mfm_copy_progress.tm
br label %18
18: ; preds = %2, %9
ret void
}