#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 uint32_t;
typedef int int64_t;

/* Variables and functions */
int av_gettime_relative();
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *ctime1(char *buf2, int buf_size) {
  int64_t t = av_gettime_relative() / 1000;
  uint32_t h, m, s, ss;
  ss = t % 1000;
  t = t / 1000;
  s = t % 60;
  t = t / 60;
  m = t % 60;
  t = t / 60;
  h = t;
  snprintf(buf2, buf_size, "[%02u:%02u:%02u.%03u]", h, m, s, ss);
  return buf2;
}


x86 assembly (clang, -O0):
<ctime1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <av_gettime_relative@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0xe49(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctime1>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <av_gettime_relative@plt>
movslq %eax,%rcx
imul   $0x10624dd3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
cltq
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
add    %esi,%edx
imul   $0x3e8,%edx,%edx
sub    %edx,%eax
imul   $0x431bde83,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x32,%rdx
add    %esi,%edx
imul   $0xffff8889,%edx,%esi
shr    $0x10,%esi
add    %edx,%esi
movzwl %si,%esi
movswl %si,%edi
shr    $0xf,%esi
sar    $0x5,%edi
add    %esi,%edi
imul   $0x3c,%edi,%esi
sub    %esi,%edx
movswl %dx,%r9d
imul   $0x4795319d,%rcx,%r8
mov    %r8,%rcx
shr    $0x3f,%rcx
sar    $0x38,%r8
add    %ecx,%r8d
mov    %eax,(%rsp)
lea    0xe47(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"[%02u:%02u:%02u.%03u]\00"
define i8* @ctime1(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = call i32 (...) @av_gettime_relative()
%11 = sdiv i32 %10, 1000
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = srem i32 %12, 1000
store i32 %13, i32* %9
%14 = load i32, i32* %5
%15 = sdiv i32 %14, 1000
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = srem i32 %16, 60
store i32 %17, i32* %8
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 60
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = srem i32 %20, 60
store i32 %21, i32* %7
%22 = load i32, i32* %5
%23 = sdiv i32 %22, 60
store i32 %23, i32* %5
%24 = load i32, i32* %5
store i32 %24, i32* %6
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i32 @snprintf(i8* %25, i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30)
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
@.str = [22 x i8] c"[%02u:%02u:%02u.%03u]\00"
define i8* @ctime1(i8* returned %0, i32 %1) {
%3 = tail call i32 (...) @av_gettime_relative()
%4 = sdiv i32 %3, 1000
%5 = srem i32 %4, 1000
%6 = sdiv i32 %3, 1000000
%7 = trunc i32 %6 to i16
%8 = srem i16 %7, 60
%9 = sext i16 %8 to i32
%10 = sdiv i32 %3, 60000000
%11 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 0, i32 %10, i32 %9, i32 %5)
ret i8* %0
}