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

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int, unsigned int,
                            unsigned int, ...);
char *get_time_remain(unsigned long remain_second) {
  unsigned int day, hour, min, second;
  static char str_time_remain[64];
  if (remain_second < 24 * 3600) {
    hour = remain_second / 3600;
    min = (remain_second - 3600 * hour) / 60;
    second = remain_second - hour * 3600 - min * 60;
    snprintf(str_time_remain, sizeof(str_time_remain), "%02u:%02u:%02u", hour,
             min, second);
  } else {
    day = remain_second / 24 / 3600;
    remain_second = remain_second - day * 24 * 3600;
    hour = remain_second / 3600;
    min = (remain_second - 3600 * hour) / 60;
    second = remain_second - hour * 3600 - min * 60;
    snprintf(str_time_remain, sizeof(str_time_remain), "%u days %02u:%02u:%02u",
             day, hour, min, second);
  }
  return str_time_remain;
}


x86 assembly (clang, -O0):
<get_time_remain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x15180,-0x8(%rbp)
jae    119e <get_time_remain+0x8e>
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xe10,-0x10(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xe10,-0x10(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
imul   $0x3c,-0x14(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0x2eba(%rip),%rdi
mov    $0x40,%esi
lea    0xe76(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1245 <get_time_remain+0x135>
mov    -0x8(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x18,-0xc(%rbp),%ecx
imul   $0xe10,%ecx,%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xe10,-0x10(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xe10,-0x10(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
imul   $0x3c,-0x14(%rbp),%ecx
mov    %ecx,%ecx
sub    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0x2e11(%rip),%rdi
mov    $0x40,%esi
lea    0xdc5(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2df4(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time_remain>:
push   %rax
mov    %rdi,%r9
cmp    $0x1517f,%rdi
ja     1169 <get_time_remain+0x59>
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    0x2ee5(%rip),%rdi
lea    0xea6(%rip),%rdx
mov    $0x40,%esi
jmp    11e5 <get_time_remain+0xd5>
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    0x2e6a(%rip),%rdi
lea    0xe23(%rip),%rdx
mov    $0x40,%esi
mov    %eax,%r9d
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2e4d(%rip),%rax
pop    %rcx
ret

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

LLVM IR (-O2):
@get_time_remain.str_time_remain = 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_remain(i64 %0) {
%2 = icmp ult i64 %0, 86400
br i1 %2, label %3, label %15
3: ; preds = %1
%4 = trunc i64 %0 to i32
%5 = udiv i32 %4, 3600
%6 = mul nuw nsw i32 %5, 3600
%7 = zext i32 %6 to i64
%8 = sub nsw i64 %0, %7
%9 = udiv i64 %8, 60
%10 = trunc i64 %9 to i32
%11 = mul i64 %9, -60
%12 = add i64 %11, %8
%13 = trunc i64 %12 to i32
%14 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_remain.str_time_remain, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %10, i32 %13)
br label %32
15: ; preds = %1
%16 = udiv i64 %0, 86400
%17 = trunc i64 %16 to i32
%18 = mul nuw i64 %16, 86400
%19 = and i64 %18, 4294967168
%20 = sub i64 %0, %19
%21 = udiv i64 %20, 3600
%22 = trunc i64 %21 to i32
%23 = mul nuw i64 %21, 3600
%24 = and i64 %23, 4294967280
%25 = sub i64 %20, %24
%26 = udiv i64 %25, 60
%27 = trunc i64 %26 to i32
%28 = mul i64 %26, -60
%29 = add i64 %28, %25
%30 = trunc i64 %29 to i32
%31 = tail call i32 (i8*, i32, i8*, i32, i32, i32, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_remain.str_time_remain, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %22, i32 %27, i32 %30)
br label %32
32: ; preds = %15, %3
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_time_remain.str_time_remain, i64 0, i64 0)
}