#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 sprintf(char *, char *, char *, int, int, int, int, int, char *);
int sprint_time(char *outbuf, char *prefix, char *postfix) {
  struct timeval curtime;
  gettimeofday(&curtime, NULL);
  return sprintf(outbuf, "%s-%ld:%ld:%ld.%ld.%ld%s\0", 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, postfix);
}


x86 assembly (clang, -O0):
<sprint_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %eax,%r8d
mov    -0x20(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r9d
mov    -0x1c(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    %eax,%r11d
mov    -0x1c(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    %edx,%r10d
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
lea    0xe48(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <sprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprint_time>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movslq (%rsp),%r9
imul   $0xffffffffc22e4507,%r9,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
imul   $0x15180,%eax,%eax
mov    %r9d,%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
add    %eax,%ecx
add    $0x1,%ecx
imul   $0xffffffff91a2b3c5,%r9,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0xb,%eax
add    %edx,%eax
imul   $0xe10,%eax,%eax
mov    %r9d,%edx
sub    %eax,%edx
movswl %dx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %edx,%eax
movzwl %ax,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x5,%edx
add    %eax,%edx
movswl %dx,%r8d
imul   $0xffffffff88888889,%r9,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r9d
movslq 0x4(%rsp),%rax
imul   $0x10624dd3,%rax,%rbx
mov    %rbx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rbx
add    %edx,%ebx
imul   $0x3e8,%ebx,%edx
sub    %edx,%eax
sub    $0x8,%rsp
lea    0xdf4(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
push   %r14
push   %rax
push   %rbx
call   1040 <sprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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