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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char *, int, char *, int, char *, int,
                          char *);
void bench_time(time_t t) {
  const int one_day = 86400;
  const int one_hour = 3600;
  const int one_min = 60;
  int days;
  int hours;
  int minutes;
  int seconds;
  long int upmind;
  long int upminh;
  days = t / one_day;
  upmind = t - (days * one_day);
  hours = upmind / one_hour;
  upminh = upmind - hours * one_hour;
  minutes = upminh / one_min;
  seconds = upminh - minutes * one_min;
  printf("Elapsed time: %i day%s, %i hour%s, %i minute%s and %i second%s\n\n",
         days, (days > 1) ? "s" : "", hours, (hours > 1) ? "s" : "", minutes,
         (minutes > 1) ? "s" : "", seconds, (seconds > 1) ? "s" : "");
}


x86 assembly (clang, -O0):
<bench_time>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x15180,-0x10(%rbp)
movl   $0xe10,-0x14(%rbp)
movl   $0x3c,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
imul   $0x15180,-0x1c(%rbp),%ecx
sub    %ecx,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
imul   $0xe10,-0x20(%rbp),%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
imul   $0x3c,-0x24(%rbp),%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%ecx
lea    0xe9a(%rip),%rdx
lea    0xe94(%rip),%rax
cmp    $0x1,%ecx
cmovg  %rax,%rdx
mov    -0x20(%rbp),%ecx
mov    -0x20(%rbp),%edi
lea    0xe7f(%rip),%r8
lea    0xe79(%rip),%rax
cmp    $0x1,%edi
cmovg  %rax,%r8
mov    -0x24(%rbp),%r9d
mov    -0x24(%rbp),%edi
lea    0xe63(%rip),%r11
lea    0xe5d(%rip),%rax
cmp    $0x1,%edi
cmovg  %rax,%r11
mov    -0x28(%rbp),%r10d
mov    -0x28(%rbp),%ebx
lea    0xe47(%rip),%rax
lea    0xe41(%rip),%rdi
cmp    $0x1,%ebx
cmovg  %rdi,%rax
lea    0xdf2(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <printf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_time>:
push   %rbx
movslq %edi,%r8
imul   $0xffffffffc22e4507,%r8,%rsi
shr    $0x20,%rsi
add    %r8d,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x10,%esi
add    %eax,%esi
imul   $0xfffeae80,%esi,%eax
add    %r8d,%eax
movslq %eax,%rdi
imul   $0xffffffff91a2b3c5,%rdi,%rax
shr    $0x20,%rax
add    %edi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xb,%eax
add    %ecx,%eax
movslq %eax,%rcx
movabs $0xe1000000000,%rax
imul   %rcx,%rax
sar    $0x20,%rax
mov    %rdi,%r10
sub    %rax,%r10
movabs $0x8888888888888889,%rdx
88 88 88
mov    %r10,%rax
imul   %rdx
mov    %rdx,%r9
add    %r10,%r9
mov    %r9,%rax
shr    $0x3f,%rax
sar    $0x5,%r9
add    %rax,%r9
movabs $0x3c00000000,%rax
imul   %r9,%rax
shr    $0x20,%rax
sub    %eax,%r10d
cmp    $0x2a300,%r8d
lea    0xe90(%rip),%r11
lea    0xe88(%rip),%rax
mov    %rax,%rdx
cmovge %r11,%rdx
cmp    $0x1c20,%edi
mov    %rax,%r8
cmovge %r11,%r8
cmp    $0x2,%r9d
mov    %rax,%rbx
cmovge %r11,%rbx
cmp    $0x2,%r10d
cmovge %r11,%rax
sub    $0x8,%rsp
lea    0xe16(%rip),%rdi
push   %rax
push   %r10
push   %rbx
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Elapsed time: %i day%s, %i hour%s, %i minute%s and %i second%s\0A\0A\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [1 x i8] zeroinitializer
define void @bench_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
store i32 %0, i32* %2
store i32 86400, i32* %3
store i32 3600, i32* %4
store i32 60, i32* %5
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 86400
store i32 %13, i32* %6
%14 = load i32, i32* %2
%15 = load i32, i32* %6
%16 = mul nsw i32 %15, 86400
%17 = sub nsw i32 %14, %16
%18 = sext i32 %17 to i64
store i64 %18, i64* %10
%19 = load i64, i64* %10
%20 = sdiv i64 %19, 3600
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
%22 = load i64, i64* %10
%23 = load i32, i32* %7
%24 = mul nsw i32 %23, 3600
%25 = sext i32 %24 to i64
%26 = sub nsw i64 %22, %25
store i64 %26, i64* %11
%27 = load i64, i64* %11
%28 = sdiv i64 %27, 60
%29 = trunc i64 %28 to i32
store i32 %29, i32* %8
%30 = load i64, i64* %11
%31 = load i32, i32* %8
%32 = mul nsw i32 %31, 60
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %30, %33
%35 = trunc i64 %34 to i32
store i32 %35, i32* %9
%36 = load i32, i32* %6
%37 = load i32, i32* %6
%38 = icmp sgt i32 %37, 1
%39 = zext i1 %38 to i64
%40 = select i1 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%41 = load i32, i32* %7
%42 = load i32, i32* %7
%43 = icmp sgt i32 %42, 1
%44 = zext i1 %43 to i64
%45 = select i1 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%46 = load i32, i32* %8
%47 = load i32, i32* %8
%48 = icmp sgt i32 %47, 1
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%51 = load i32, i32* %9
%52 = load i32, i32* %9
%53 = icmp sgt i32 %52, 1
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%56 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %36, i8* %40, i32 %41, i8* %45, i32 %46, i8* %50, i32 %51, i8* %55)
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"Elapsed time: %i day%s, %i hour%s, %i minute%s and %i second%s\0A\0A\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [1 x i8] zeroinitializer
define void @bench_time(i32 %0) {
%2 = sdiv i32 %0, 86400
%3 = mul nsw i32 %2, -86400
%4 = add i32 %3, %0
%5 = sext i32 %4 to i64
%6 = sdiv i32 %4, 3600
%7 = sext i32 %6 to i64
%8 = mul nsw i64 %7, 15461882265600
%9 = ashr exact i64 %8, 32
%10 = sub nsw i64 %5, %9
%11 = sdiv i64 %10, 60
%12 = trunc i64 %11 to i32
%13 = mul i64 %11, 257698037760
%14 = lshr exact i64 %13, 32
%15 = sub nsw i64 %10, %14
%16 = trunc i64 %15 to i32
%17 = icmp sgt i32 %0, 172799
%18 = select i1 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%19 = icmp sgt i32 %4, 7199
%20 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%21 = icmp sgt i32 %12, 1
%22 = select i1 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%23 = icmp sgt i32 %16, 1
%24 = select i1 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %18, i32 %6, i8* %20, i32 %12, i8* %22, i32 %16, i8* %24)
ret void
}