#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 */

/* Variables and functions */
int get_base_sixty(char const *);
int /*<<< orphan*/ sprintf(char *, char *, int const, int const, int const,
                           int const);
void add_half_exposure(char *obuff, const char *itime,
                       const double exposure_time) {
  const double seconds = get_base_sixty(itime) * 3600. + exposure_time / 2.;
  const int millisec = (int)(seconds * 1000. + .5);
  sprintf(obuff, "%02d:%02d:%02d.%03d", millisec / 3600000,
          (millisec / 60000) % 60, (millisec / 1000) % 60, millisec % 1000);
}


x86 assembly (clang, -O0):
<add_half_exposure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <get_base_sixty@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xec9(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xeb5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    $0x36ee80,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xea60,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x24(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0x24(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    %edx,%r9d
mov    -0x28(%rbp),%edx
lea    0xe3f(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_half_exposure>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <get_base_sixty@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xebb(%rip),%xmm1
mulsd  0xebb(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
mulsd  0xead(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movslq %eax,%r9
imul   $0x4a90be59,%r9,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x20,%rdx
sar    $0x14,%edx
add    %eax,%edx
imul   $0x45e7b273,%r9,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0xe,%eax
add    %ecx,%eax
movslq %eax,%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x5,%eax
add    %esi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%ecx
imul   $0x10624dd3,%r9,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rax
add    %esi,%eax
movslq %eax,%r8
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
imul   $0x3e8,%r8d,%esi
sub    %eax,%r8d
sub    %esi,%r9d
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"%02d:%02d:%02d.%03d\00"
define void @add_half_exposure(i8* %0, i8* %1, double %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store double %2, double* %6
%9 = load i8*, i8** %5
%10 = call i32 @get_base_sixty(i8* %9)
%11 = sitofp i32 %10 to double
%12 = load double, double* %6
%13 = fdiv double %12, 2.000000e+00
%14 = call double @llvm.fmuladd.f64(double %11, double 3.600000e+03, double %13)
store double %14, double* %7
%15 = load double, double* %7
%16 = call double @llvm.fmuladd.f64(double %15, double 1.000000e+03, double 5.000000e-01)
%17 = fptosi double %16 to i32
store i32 %17, i32* %8
%18 = load i8*, i8** %4
%19 = load i32, i32* %8
%20 = sdiv i32 %19, 3600000
%21 = load i32, i32* %8
%22 = sdiv i32 %21, 60000
%23 = srem i32 %22, 60
%24 = load i32, i32* %8
%25 = sdiv i32 %24, 1000
%26 = srem i32 %25, 60
%27 = load i32, i32* %8
%28 = srem i32 %27, 1000
%29 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %23, i32 %26, i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%02d:%02d:%02d.%03d\00"
define void @add_half_exposure(i8* nocapture writeonly %0, i8* %1, double %2) {
%4 = tail call i32 @get_base_sixty(i8* %1)
%5 = sitofp i32 %4 to double
%6 = fmul double %2, 5.000000e-01
%7 = tail call double @llvm.fmuladd.f64(double %5, double 3.600000e+03, double %6)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e+03, double 5.000000e-01)
%9 = fptosi double %8 to i32
%10 = sdiv i32 %9, 3600000
%11 = sdiv i32 %9, 60000
%12 = srem i32 %11, 60
%13 = sdiv i32 %9, 1000
%14 = srem i32 %13, 60
%15 = srem i32 %9, 1000
%16 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %14, i32 %15)
ret void
}