#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__ uint64_t;
typedef int /*<<< orphan*/ str_time_elapsed;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int, unsigned int,
                            unsigned int, ...);
scalar_t__ time(int /*<<< orphan*/ *);
char *get_time_elapsed(uint64_t start_time) {
  unsigned long elapsed_second;
  elapsed_second = (unsigned long)(time(NULL) - start_time);
  unsigned int day, hour, min, second;
  static char str_time_elapsed[64];
  if (elapsed_second < 24 * 3600) {
    hour = elapsed_second / 3600;
    min = (elapsed_second - 3600 * hour) / 60;
    second = elapsed_second - hour * 3600 - min * 60;
    snprintf(str_time_elapsed, sizeof(str_time_elapsed), "%02u:%02u:%02u", hour,
             min, second);
  } else {
    day = elapsed_second / 24 / 3600;
    elapsed_second = elapsed_second - day * 24 * 3600;
    hour = elapsed_second / 3600;
    min = (elapsed_second - 3600 * hour) / 60;
    second = elapsed_second - hour * 3600 - min * 60;
    snprintf(str_time_elapsed, sizeof(str_time_elapsed),
             "%u days %02u:%02u:%02u", day, hour, min, second);
  }
  return str_time_elapsed;
}


x86 assembly (clang, -O0):
<get_time_elapsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
sub    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x15180,-0x10(%rbp)
jae    11bf <get_time_elapsed+0x9f>
mov    -0x10(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xe10,-0x18(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xe10,-0x18(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
imul   $0x3c,-0x1c(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
lea    0x2e99(%rip),%rdi
mov    $0x40,%esi
lea    0xe55(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1266 <get_time_elapsed+0x146>
mov    -0x10(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x18,-0x14(%rbp),%ecx
imul   $0xe10,%ecx,%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xe10,-0x18(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xe10,-0x18(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
imul   $0x3c,-0x1c(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0x2df0(%rip),%rdi
mov    $0x40,%esi
lea    0xda4(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2dd3(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time_elapsed>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%r9
sub    %rbx,%r9
cmp    $0x1517f,%r9
ja     118a <get_time_elapsed+0x6a>
mov    %r9d,%eax
mov    $0x91a2b3c5,%ecx
imul   %rax,%rcx
shr    $0x2b,%rcx
imul   $0xe10,%ecx,%eax
sub    %rax,%r9
movabs $0x8888888888888889,%rdx
88 88 88
mov    %r9,%rax
mul    %rdx
mov    %rdx,%r8
shr    $0x5,%r8
imul   $0xffffffc4,%r8d,%eax
add    %eax,%r9d
lea    0x2ec4(%rip),%rdi
lea    0xe85(%rip),%rdx
mov    $0x40,%esi
jmp    1206 <get_time_elapsed+0xe6>
movabs $0xc22e450672894ab7,%rcx
45 2e c2
mov    %r9,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x10,%rcx
imul   $0x15180,%ecx,%eax
sub    %rax,%r9
mov    %r9,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rdx
2b 1a 09
mul    %rdx
mov    %rdx,%r8
shr    $0x3,%r8
imul   $0xe10,%r8d,%eax
sub    %rax,%r9
movabs $0x8888888888888889,%rdx
88 88 88
mov    %r9,%rax
mul    %rdx
mov    %rdx,%rax
shr    $0x5,%rax
imul   $0xffffffc4,%eax,%edx
add    %edx,%r9d
mov    %r9d,(%rsp)
lea    0x2e49(%rip),%rdi
lea    0xe02(%rip),%rdx
mov    $0x40,%esi
mov    %eax,%r9d
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2e2c(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@get_time_elapsed.str_time_elapsed = internal global [64 x i8] zeroinitializer
@.str = [15 x i8] c"%02u:%02u:%02u\00"
@.str.1 = [23 x i8] c"%u days %02u:%02u:%02u\00"
define i8* @get_time_elapsed(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64 %0, i64* %2
%8 = call i64 @time(i32* null)
%9 = load i64, i64* %2
%10 = sub nsw i64 %8, %9
store i64 %10, i64* %3
%11 = load i64, i64* %3
%12 = icmp ult i64 %11, 86400
br i1 %12, label %13, label %38
13: ; preds = %1
%14 = load i64, i64* %3
%15 = udiv i64 %14, 3600
%16 = trunc i64 %15 to i32
store i32 %16, i32* %5
%17 = load i64, i64* %3
%18 = load i32, i32* %5
%19 = mul i32 3600, %18
%20 = zext i32 %19 to i64
%21 = sub i64 %17, %20
%22 = udiv i64 %21, 60
%23 = trunc i64 %22 to i32
store i32 %23, i32* %6
%24 = load i64, i64* %3
%25 = load i32, i32* %5
%26 = mul i32 %25, 3600
%27 = zext i32 %26 to i64
%28 = sub i64 %24, %27
%29 = load i32, i32* %6
%30 = mul i32 %29, 60
%31 = zext i32 %30 to i64
%32 = sub i64 %28, %31
%33 = trunc i64 %32 to i32
store i32 %33, i32* %7
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %35, i32 %36)
br label %74
38: ; preds = %1
%39 = load i64, i64* %3
%40 = udiv i64 %39, 24
%41 = udiv i64 %40, 3600
%42 = trunc i64 %41 to i32
store i32 %42, i32* %4
%43 = load i64, i64* %3
%44 = load i32, i32* %4
%45 = mul i32 %44, 24
%46 = mul i32 %45, 3600
%47 = zext i32 %46 to i64
%48 = sub i64 %43, %47
store i64 %48, i64* %3
%49 = load i64, i64* %3
%50 = udiv i64 %49, 3600
%51 = trunc i64 %50 to i32
store i32 %51, i32* %5
%52 = load i64, i64* %3
%53 = load i32, i32* %5
%54 = mul i32 3600, %53
%55 = zext i32 %54 to i64
%56 = sub i64 %52, %55
%57 = udiv i64 %56, 60
%58 = trunc i64 %57 to i32
store i32 %58, i32* %6
%59 = load i64, i64* %3
%60 = load i32, i32* %5
%61 = mul i32 %60, 3600
%62 = zext i32 %61 to i64
%63 = sub i64 %59, %62
%64 = load i32, i32* %6
%65 = mul i32 %64, 60
%66 = zext i32 %65 to i64
%67 = sub i64 %63, %66
%68 = trunc i64 %67 to i32
store i32 %68, i32* %7
%69 = load i32, i32* %4
%70 = load i32, i32* %5
%71 = load i32, i32* %6
%72 = load i32, i32* %7
%73 = call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %69, i32 %70, i32 %71, i32 %72)
br label %74
74: ; preds = %38, %13
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0)
}

LLVM IR (-O2):
@get_time_elapsed.str_time_elapsed = internal global [64 x i8] zeroinitializer
@.str = [15 x i8] c"%02u:%02u:%02u\00"
@.str.1 = [23 x i8] c"%u days %02u:%02u:%02u\00"
define i8* @get_time_elapsed(i64 %0) {
%2 = tail call i64 @time(i32* null)
%3 = sub nsw i64 %2, %0
%4 = icmp ult i64 %3, 86400
br i1 %4, label %5, label %17
5: ; preds = %1
%6 = trunc i64 %3 to i32
%7 = udiv i32 %6, 3600
%8 = mul nuw nsw i32 %7, 3600
%9 = zext i32 %8 to i64
%10 = sub nsw i64 %3, %9
%11 = udiv i64 %10, 60
%12 = trunc i64 %11 to i32
%13 = mul i64 %11, -60
%14 = add i64 %13, %10
%15 = trunc i64 %14 to i32
%16 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %12, i32 %15)
br label %34
17: ; preds = %1
%18 = udiv i64 %3, 86400
%19 = trunc i64 %18 to i32
%20 = mul nuw i64 %18, 86400
%21 = and i64 %20, 4294967168
%22 = sub i64 %3, %21
%23 = udiv i64 %22, 3600
%24 = trunc i64 %23 to i32
%25 = mul nuw i64 %23, 3600
%26 = and i64 %25, 4294967280
%27 = sub i64 %22, %26
%28 = udiv i64 %27, 60
%29 = trunc i64 %28 to i32
%30 = mul i64 %28, -60
%31 = add i64 %30, %27
%32 = trunc i64 %31 to i32
%33 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %24, i32 %29, i32 %32)
br label %34
34: ; preds = %17, %5
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_elapsed.str_time_elapsed, i64 0, i64 0)
}