#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 time_t;
struct tm {
  int tm_mday;
  int tm_sec;
};

/* Variables and functions */
char *get_time(int);
struct tm *localtime(int *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int time(int /*<<< orphan*/ *);
void GetSimulatedRTValues(char *szTimestamps, int sLength, double *dVal,
                          int nArraySize, int dValOffset) {
  int idx;
  time_t tNow = time(NULL);
  struct tm *local = localtime(&tNow);
  for (idx = 0; idx < nArraySize; idx++) {
    snprintf(szTimestamps + idx * sLength, sLength, "%s",
             get_time(tNow - nArraySize + idx));
    dVal[idx] = local->tm_mday + local->tm_sec + dValOffset + 1.12 * (idx + 1);
  }
}


x86 assembly (clang, -O0):
<GetSimulatedRTValues>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120e <GetSimulatedRTValues+0xce>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%edi
sub    -0x1c(%rbp),%edi
add    -0x24(%rbp),%edi
call   1050 <get_time@plt>
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    %rax,%rcx
lea    0xe48(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%rcx
add    0x4(%rcx),%eax
add    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe15(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117a <GetSimulatedRTValues+0x3a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetSimulatedRTValues>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0xc(%rsp)
mov    %ecx,%r12d
mov    %rdx,0x10(%rsp)
mov    %esi,%ebx
mov    %rdi,%rbp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
test   %r12d,%r12d
jle    11f1 <GetSimulatedRTValues+0xb1>
mov    %rax,%r13
movslq %ebx,%rbx
mov    %r12d,%r14d
neg    %r12d
xor    %r15d,%r15d
nopl   0x0(%rax)
lea    (%r12,%r15,1),%edi
add    0x8(%rsp),%edi
call   1050 <get_time@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
lea    0xe5f(%rip),%rdx
mov    %rax,%rcx
call   1040 <snprintf@plt>
mov    0x0(%r13),%eax
add    0xc(%rsp),%eax
add    0x4(%r13),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0x1(%r15),%rax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe29(%rip),%xmm1
addsd  %xmm0,%xmm1
mov    0x10(%rsp),%rcx
movsd  %xmm1,(%rcx,%r15,8)
add    %rbx,%rbp
mov    %rax,%r15
cmp    %rax,%r14
jne    1190 <GetSimulatedRTValues+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [3 x i8] c"%s\00"
define void @GetSimulatedRTValues(i8* %0, i32 %1, double* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.tm*
store i8* %0, i8** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = call i32 @time(i32* null)
store i32 %14, i32* %12
%15 = call %struct.tm* @localtime(i32* %12)
store %struct.tm* %15, %struct.tm** %13
store i32 0, i32* %11
br label %16
16: ; preds = %53, %5
%17 = load i32, i32* %11
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %56
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = load i32, i32* %11
%23 = load i32, i32* %7
%24 = mul nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i32, i32* %7
%28 = load i32, i32* %12
%29 = load i32, i32* %9
%30 = sub nsw i32 %28, %29
%31 = load i32, i32* %11
%32 = add nsw i32 %30, %31
%33 = call i8* @get_time(i32 %32)
%34 = call i32 @snprintf(i8* %26, i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = load %struct.tm*, %struct.tm** %13
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = load %struct.tm*, %struct.tm** %13
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = add nsw i32 %37, %40
%42 = load i32, i32* %10
%43 = add nsw i32 %41, %42
%44 = sitofp i32 %43 to double
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
%47 = sitofp i32 %46 to double
%48 = call double @llvm.fmuladd.f64(double 1.120000e+00, double %47, double %44)
%49 = load double*, double** %8
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
br label %53
53: ; preds = %20
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %16
56: ; preds = %16
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
@.str = [3 x i8] c"%s\00"
define void @GetSimulatedRTValues(i8* %0, i32 %1, double* nocapture writeonly %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = tail call i32 @time(i32* null)
store i32 %8, i32* %6
%9 = call %struct.tm* @localtime(i32* %6)
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %37
11: ; preds = %5
%12 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%13 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%14 = sext i32 %1 to i64
%15 = zext i32 %3 to i64
br label %16
16: ; preds = %11, %16
%17 = phi i64 [ 0, %11 ], [ %31, %16 ]
%18 = mul nsw i64 %17, %14
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i32, i32* %6
%21 = trunc i64 %17 to i32
%22 = sub i32 %21, %3
%23 = add i32 %22, %20
%24 = call i8* @get_time(i32 %23)
%25 = call i32 @snprintf(i8* %19, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %12
%27 = load i32, i32* %13
%28 = add i32 %26, %4
%29 = add i32 %28, %27
%30 = sitofp i32 %29 to double
%31 = add nuw nsw i64 %17, 1
%32 = trunc i64 %31 to i32
%33 = sitofp i32 %32 to double
%34 = call double @llvm.fmuladd.f64(double %33, double 1.120000e+00, double %30)
%35 = getelementptr inbounds double, double* %2, i64 %17
store double %34, double* %35
%36 = icmp eq i64 %31, %15
br i1 %36, label %37, label %16
37: ; preds = %16, %5
ret void
}