#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 exp(double);
int log(double);
int /*<<< orphan*/ memcpy(double *, double *, int);
void psmc_update_intv(int n, double t[], double max_t, double alpha,
                      double *inp_ti) {
  int k;
  if (inp_ti == 0) {
    double beta;
    beta = log(1.0 + max_t / alpha) / n;
    for (k = 0; k < n; ++k)
      t[k] = alpha * (exp(beta * k) - 1);
    t[n] = max_t;
    t[n + 1] = 1000.0;
  } else {
    memcpy(t, inp_ti, (n + 1) * sizeof(double));
    t[n + 1] = 1000.0;
  }
}


x86 assembly (clang, -O0):
<psmc_update_intv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120c <psmc_update_intv+0xdc>
movsd  -0x18(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xe9e(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1050 <log@plt>
cltd
idivl  -0x4(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11db <psmc_update_intv+0xab>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  -0x40(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1187 <psmc_update_intv+0x57>
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdfe(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1241 <psmc_update_intv+0x111>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdc4(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psmc_update_intv>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
test   %rdx,%rdx
je     1166 <psmc_update_intv+0x36>
mov    %r14d,%ebx
add    $0x1,%ebx
lea    0x8(,%r14,8),%eax
mov    %r15,%rdi
mov    %rdx,%rsi
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    %ebx,%r14d
jmp    11e3 <psmc_update_intv+0xb3>
movsd  %xmm0,(%rsp)
divsd  %xmm1,%xmm0
addsd  0xe89(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
call   1050 <log@plt>
cltd
idiv   %r14d
test   %r14d,%r14d
jle    11d1 <psmc_update_intv+0xa1>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <psmc_update_intv+0x70>
movslq %r14d,%rax
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rax,8)
add    $0x1,%r14d
movslq %r14d,%rax
movabs $0x408f400000000000,%rcx
40 8f 40
mov    %rcx,(%r15,%rax,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @psmc_update_intv(i32 %0, double* %1, double %2, double %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
%13 = load double*, double** %10
%14 = icmp eq double* %13, null
br i1 %14, label %15, label %56
15: ; preds = %5
%16 = load double, double* %8
%17 = load double, double* %9
%18 = fdiv double %16, %17
%19 = fadd double 1.000000e+00, %18
%20 = call i32 @log(double %19)
%21 = load i32, i32* %6
%22 = sdiv i32 %20, %21
%23 = sitofp i32 %22 to double
store double %23, double* %12
store i32 0, i32* %11
br label %24
24: ; preds = %42, %15
%25 = load i32, i32* %11
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %45
28: ; preds = %24
%29 = load double, double* %9
%30 = load double, double* %12
%31 = load i32, i32* %11
%32 = sitofp i32 %31 to double
%33 = fmul double %30, %32
%34 = call i32 @exp(double %33)
%35 = sub nsw i32 %34, 1
%36 = sitofp i32 %35 to double
%37 = fmul double %29, %36
%38 = load double*, double** %7
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %28
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %24
45: ; preds = %24
%46 = load double, double* %8
%47 = load double*, double** %7
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double %46, double* %50
%51 = load double*, double** %7
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
store double 1.000000e+03, double* %55
br label %70
56: ; preds = %5
%57 = load double*, double** %7
%58 = load double*, double** %10
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = mul i64 %61, 8
%63 = trunc i64 %62 to i32
%64 = call i32 @memcpy(double* %57, double* %58, i32 %63)
%65 = load double*, double** %7
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %65, i64 %68
store double 1.000000e+03, double* %69
br label %70
70: ; preds = %56, %45
ret void
}

LLVM IR (-O2):
define void @psmc_update_intv(i32 %0, double* %1, double %2, double %3, double* %4) {
%6 = icmp eq double* %4, null
br i1 %6, label %7, label %32
7: ; preds = %5
%8 = fdiv double %2, %3
%9 = fadd double %8, 1.000000e+00
%10 = tail call i32 @log(double %9)
%11 = sdiv i32 %10, %0
%12 = sitofp i32 %11 to double
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %28
14: ; preds = %7
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %26, %16 ]
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %18 to double
%20 = fmul double %12, %19
%21 = tail call i32 @exp(double %20)
%22 = add nsw i32 %21, -1
%23 = sitofp i32 %22 to double
%24 = fmul double %23, %3
%25 = getelementptr inbounds double, double* %1, i64 %17
store double %24, double* %25
%26 = add nuw nsw i64 %17, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %28, label %16
28: ; preds = %16, %7
%29 = sext i32 %0 to i64
%30 = getelementptr inbounds double, double* %1, i64 %29
store double %2, double* %30
%31 = add nsw i32 %0, 1
br label %36
32: ; preds = %5
%33 = add nsw i32 %0, 1
%34 = shl i32 %33, 3
%35 = tail call i32 @memcpy(double* %1, double* %4, i32 %34)
br label %36
36: ; preds = %32, %28
%37 = phi i32 [ %33, %32 ], [ %31, %28 ]
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %1, i64 %38
store double 1.000000e+03, double* %39
ret void
}