#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 */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, long, long, long, int, int, long);
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
void etime_print(char *txt, struct timeval *tval_s, struct timeval *tval_e) {
  struct timeval tval_r;
  long int h;
  int m;
  int s;
  timersub(tval_e, tval_s, &tval_r);
  h = ((long int)tval_r.tv_sec) / 3600;
  m = ((int)((long int)tval_r.tv_sec) % 3600) / 60;
  s = (int)((long int)tval_r.tv_sec) % 60;
  printf("%s: %ld.%06ld (%ld:%02d:%02d.%06ld)\n", txt, (long int)tval_r.tv_sec,
         (long int)tval_r.tv_usec, h, m, s, (long int)tval_r.tv_usec);
}


x86 assembly (clang, -O0):
<etime_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <timersub@plt>
mov    -0x20(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
mov    -0x38(%rbp),%r10d
mov    -0x28(%rbp),%rax
lea    0xe5e(%rip),%rdi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<etime_print>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rax
mov    %rdi,%r14
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1040 <timersub@plt>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rbx
movabs $0x48d159e26af37c05,%rdx
59 d1 48
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%r8
shr    $0x3f,%r8
sar    $0xa,%rdx
add    %rdx,%r8
movslq %ebx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0xb,%edx
add    %esi,%edx
imul   $0xe10,%edx,%edx
mov    %eax,%esi
sub    %edx,%esi
movswl %si,%edx
imul   $0xffff8889,%edx,%edx
shr    $0x10,%edx
add    %esi,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
sar    $0x5,%esi
add    %edx,%esi
movswl %si,%r9d
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x3c,%edx,%edx
sub    %edx,%eax
lea    0xe37(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
push   %rcx
push   %rax
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [37 x i8] c"%s: %ld.%06ld (%ld:%02d:%02d.%06ld)\0A\00"
define void @etime_print(i8* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i8*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca %struct.timeval
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%11 = load %struct.timeval*, %struct.timeval** %6
%12 = load %struct.timeval*, %struct.timeval** %5
%13 = call i32 @timersub(%struct.timeval* %11, %struct.timeval* %12, %struct.timeval* %7)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sdiv i64 %15, 3600
store i64 %16, i64* %8
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = srem i32 %19, 3600
%21 = sdiv i32 %20, 60
store i32 %21, i32* %9
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = srem i32 %24, 60
store i32 %25, i32* %10
%26 = load i8*, i8** %4
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%30 = load i64, i64* %29
%31 = load i64, i64* %8
%32 = load i32, i32* %9
%33 = load i32, i32* %10
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%35 = load i64, i64* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %26, i64 %28, i64 %30, i64 %31, i32 %32, i32 %33, i64 %35)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [37 x i8] c"%s: %ld.%06ld (%ld:%02d:%02d.%06ld)\0A\00"
define void @etime_print(i8* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %4 to i8*
%6 = call i32 @timersub(%struct.timeval* %2, %struct.timeval* %1, %struct.timeval* %4)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%8 = load i64, i64* %7
%9 = sdiv i64 %8, 3600
%10 = trunc i64 %8 to i32
%11 = srem i32 %10, 3600
%12 = trunc i32 %11 to i16
%13 = sdiv i16 %12, 60
%14 = sext i16 %13 to i32
%15 = srem i32 %10, 60
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%17 = load i64, i64* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %8, i64 %17, i64 %9, i32 %14, i32 %15, i64 %17)
ret void
}