#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 {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int, int, int, int, int);
void print_time(char *prefix) {
  struct timeval curtime;
  gettimeofday(&curtime, NULL);
  printf("%s %ld:%ld:%ld.%ld.%ld\n", prefix,
         (+1) + (curtime.tv_sec % (3600 * 24)) / 3600,
         (curtime.tv_sec % 3600) / 60, curtime.tv_sec % 60,
         curtime.tv_usec / 1000, curtime.tv_usec % 1000);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
mov    $0x3c,%edi
cltd
idiv   %edi
mov    %edx,%r8d
mov    -0xc(%rbp),%eax
mov    $0x3e8,%edi
cltd
idiv   %edi
mov    %eax,%r9d
mov    -0xc(%rbp),%eax
mov    $0x3e8,%edi
cltd
idiv   %edi
mov    %edx,%eax
mov    -0x14(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    %eax,(%rsp)
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movslq 0x8(%rsp),%r8
imul   $0xffffffffc22e4507,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
imul   $0x15180,%eax,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
sar    $0xb,%ecx
shr    $0x1f,%eax
lea    (%rcx,%rax,1),%edx
add    $0x1,%edx
imul   $0xffffffff91a2b3c5,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xb,%eax
add    %ecx,%eax
imul   $0xe10,%eax,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswl %cx,%ecx
imul   $0xffffffff88888889,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x5,%eax
add    %esi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
movslq 0xc(%rsp),%rax
imul   $0x10624dd3,%rax,%r9
mov    %r9,%rsi
shr    $0x3f,%rsi
sar    $0x26,%r9
add    %esi,%r9d
imul   $0x3e8,%r9d,%esi
sub    %esi,%eax
mov    %eax,(%rsp)
lea    0xdf9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [24 x i8] c"%s %ld:%ld:%ld.%ld.%ld\0A\00"
define void @print_time(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
store i8* %0, i8** %2
%4 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%5 = load i8*, i8** %2
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%7 = load i32, i32* %6
%8 = srem i32 %7, 86400
%9 = sdiv i32 %8, 3600
%10 = add nsw i32 1, %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%12 = load i32, i32* %11
%13 = srem i32 %12, 3600
%14 = sdiv i32 %13, 60
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%16 = load i32, i32* %15
%17 = srem i32 %16, 60
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%19 = load i32, i32* %18
%20 = sdiv i32 %19, 1000
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%22 = load i32, i32* %21
%23 = srem i32 %22, 1000
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %10, i32 %14, i32 %17, i32 %20, i32 %23)
ret void
}

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