#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 long time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ localtime(long *);
void dd_WriteTimes(FILE *f, time_t starttime, time_t endtime) {
  long ptime, ptime_sec, ptime_minu, ptime_hour;
  ptime = (endtime - starttime);
  ptime_hour = ptime / 3600;
  ptime_minu = (ptime - ptime_hour * 3600) / 60;
  ptime_sec = ptime % 60;
  fprintf(f, "* Computation started at %s", asctime(localtime(&starttime)));
  fprintf(f, "*             ended   at %s", asctime(localtime(&endtime)));
  fprintf(f, "* Total processor time = %ld seconds\n", ptime);
  fprintf(f, "*                      = %ld h %ld m %ld s\n", ptime_hour,
          ptime_minu, ptime_sec);
}


x86 assembly (clang, -O0):
<dd_WriteTimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
imul   $0xe10,-0x38(%rbp),%rcx
sub    %rcx,%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_WriteTimes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r12
mov    %rdi,%r14
mov    %rsi,0x8(%rsp)
mov    %rdx,(%rsp)
sub    %rsi,%r12
movabs $0x48d159e26af37c05,%rcx
59 d1 48
mov    %r12,%rax
imul   %rcx
mov    %rdx,%r15
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xa,%r15
add    %rax,%r15
imul   $0xfffffffffffff1f0,%r15,%rbx
add    %r12,%rbx
movabs $0x8888888888888889,%rcx
88 88 88
mov    %rbx,%rax
imul   %rcx
add    %rdx,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x5,%rbx
add    %rax,%rbx
mov    %r12,%rax
imul   %rcx
add    %r12,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x5,%rdx
add    %rax,%rdx
imul   $0x3c,%rdx,%rax
mov    %r12,%r13
sub    %rax,%r13
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
lea    0xe2c(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rsp,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1040 <asctime@plt>
lea    0xe25(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe2d(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe3f(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"* Computation started at %s\00"
@.str.1 = [28 x i8] c"* ended at %s\00"
@.str.2 = [38 x i8] c"* Total processor time = %ld seconds\0A\00"
@.str.3 = [44 x i8] c"* = %ld h %ld m %ld s\0A\00"
define void @dd_WriteTimes(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%11 = load i64, i64* %6
%12 = load i64, i64* %5
%13 = sub nsw i64 %11, %12
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = sdiv i64 %14, 3600
store i64 %15, i64* %10
%16 = load i64, i64* %7
%17 = load i64, i64* %10
%18 = mul nsw i64 %17, 3600
%19 = sub nsw i64 %16, %18
%20 = sdiv i64 %19, 60
store i64 %20, i64* %9
%21 = load i64, i64* %7
%22 = srem i64 %21, 60
store i64 %22, i64* %8
%23 = load i32*, i32** %4
%24 = call i32 @localtime(i64* %5)
%25 = call i8* @asctime(i32 %24)
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %4
%28 = call i32 @localtime(i64* %6)
%29 = call i8* @asctime(i32 %28)
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32*, i32** %4
%32 = load i64, i64* %7
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i64 %32)
%34 = load i32*, i32** %4
%35 = load i64, i64* %10
%36 = load i64, i64* %9
%37 = load i64, i64* %8
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i64 %35, i64 %36, i64 %37)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"* Computation started at %s\00"
@.str.1 = [28 x i8] c"* ended at %s\00"
@.str.2 = [38 x i8] c"* Total processor time = %ld seconds\0A\00"
@.str.3 = [44 x i8] c"* = %ld h %ld m %ld s\0A\00"
define void @dd_WriteTimes(i32* nocapture %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
store i64 %1, i64* %4
store i64 %2, i64* %5
%6 = sub nsw i64 %2, %1
%7 = sdiv i64 %6, 3600
%8 = mul nsw i64 %7, -3600
%9 = add i64 %8, %6
%10 = sdiv i64 %9, 60
%11 = srem i64 %6, 60
%12 = call i32 @localtime(i64* %4)
%13 = call i8* @asctime(i32 %12)
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @localtime(i64* %5)
%16 = call i8* @asctime(i32 %15)
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i64 %6)
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i64 %7, i64 %10, i64 %11)
ret void
}