#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 */
float *arange(int /*<<< orphan*/, int, double, int *);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ printf(char *, ...);
double r1(float, float);
double r2(float, float, float);
double r4(float, float, float);
double r5(float, float, float);
double sr3(int, float, float);
float *tinti(float *, int, float, float, float, float);
int main() {
  float t0 = 1.0;
  float slip = 1.0;
  int i;
  float *t;
  float *stf;
  int nt;
  float test;
  t = arange(0, 10, 0.001, &nt);
  float Ts = 1.0;
  float Tr = 2.0;
  stf = tinti(t, nt, Tr, Ts, t0, slip);
  for (i = 0; i < nt; i++) {
    printf("(%f) %f\n", t[i], stf[i]);
  }
  free(stf);
  Ts = 1.0;
  Tr = 2.0;
  stf = tinti(t, nt, Tr, Ts, t0, slip);
  printf("Case 2: Ts < Tr < 2*Ts\n");
  printf("r1: %f\n", r1(0, Tr));
  printf("r1: %f\n", r1(Ts, Tr));
  printf("r2: %f\n", r2(Tr, Tr, Ts));
  printf("r2: %f\n", r2(Tr, Tr, Ts));
  printf("sr3: %f\n", sr3(Tr, Tr, Ts));
  printf("sr3: %f\n", sr3(2 * Ts, Tr, Ts));
  printf("r4: %f\n", r4(2 * Ts, Tr, Ts));
  printf("r4: %f\n", r4(Tr + Ts, Tr, Ts));
  printf("r5: %f\n", r5(Tr + Ts, Tr, Ts));
  printf("r5: %f\n", r5(Tr + 2 * Ts, Tr, Ts));
  free(stf);
  free(t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe5d(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe50(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xor    %edi,%edi
mov    $0xa,%esi
movsd  0xe40(%rip),%xmm0
lea    -0x24(%rbp),%rdx
call   10a0 <arange@plt>
mov    %rax,-0x18(%rbp)
movss  0xe27(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xe16(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
movss  -0x30(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x8(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
call   1050 <tinti@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1264 <main+0xd4>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc1(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    121a <main+0x8a>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movss  0xd8f(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  0xd7e(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
movss  -0x30(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x8(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
call   1050 <tinti@plt>
mov    %rax,-0x20(%rbp)
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm1
xorps  %xmm0,%xmm0
call   10b0 <r1@plt>
lea    0xd64(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
call   10b0 <r1@plt>
lea    0xd47(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1080 <r2@plt>
lea    0xd2d(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1080 <r2@plt>
lea    0xd0b(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
cvttss2si -0x30(%rbp),%edi
movss  -0x30(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
call   1060 <sr3@plt>
lea    0xcf1(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  0xca1(%rip),%xmm0
mulss  -0x2c(%rbp),%xmm0
cvttss2si %xmm0,%edi
movss  -0x30(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
call   1060 <sr3@plt>
lea    0xcc3(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  0xc73(%rip),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1090 <r4@plt>
lea    0xca2(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1090 <r4@plt>
lea    0xc7b(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1030 <r5@plt>
lea    0xc5c(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm0
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1030 <r5@plt>
lea    0xc2d(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movsd  0xe50(%rip),%xmm0
lea    0x4(%rsp),%rdx
xor    %edi,%edi
mov    $0xa,%esi
call   10b0 <arange@plt>
mov    %rax,%r15
mov    0x4(%rsp),%esi
movss  0xe38(%rip),%xmm0
movss  0xe34(%rip),%xmm1
mov    %rax,%rdi
movaps %xmm1,%xmm2
movaps %xmm1,%xmm3
call   1060 <tinti@plt>
mov    %rax,%r12
cmpl   $0x0,0x4(%rsp)
jle    122c <main+0x8c>
xor    %ebx,%ebx
lea    0xe1f(%rip),%r14
nopl   0x0(%rax)
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%r12,%rbx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
mov    $0x2,%al
call   1080 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0x60>
mov    %r12,%rdi
call   1040 <free@plt>
mov    0x4(%rsp),%esi
movss  0xdc8(%rip),%xmm0
movss  0xdc4(%rip),%xmm1
mov    %r15,%rdi
movaps %xmm1,%xmm2
movaps %xmm1,%xmm3
call   1060 <tinti@plt>
mov    %rax,%r14
lea    0xdea(%rip),%rdi
call   1050 <puts@plt>
xorps  %xmm0,%xmm0
movss  0xd98(%rip),%xmm1
call   10c0 <r1@plt>
lea    0xda5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xd7e(%rip),%xmm0
movss  0xd72(%rip),%xmm1
call   10c0 <r1@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xd5b(%rip),%xmm0
movaps %xmm0,%xmm1
movss  0xd54(%rip),%xmm2
call   1090 <r2@plt>
lea    0xd65(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xd32(%rip),%xmm0
movaps %xmm0,%xmm1
movss  0xd2b(%rip),%xmm2
call   1090 <r2@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    $0x2,%edi
movss  0xd0b(%rip),%xmm0
movss  0xd07(%rip),%xmm1
call   1070 <sr3@plt>
lea    0xd20(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    $0x2,%edi
movss  0xce0(%rip),%xmm0
movss  0xcdc(%rip),%xmm1
call   1070 <sr3@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xcc1(%rip),%xmm0
movaps %xmm0,%xmm1
movss  0xcba(%rip),%xmm2
call   10a0 <r4@plt>
lea    0xcdc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xca0(%rip),%xmm0
movss  0xc90(%rip),%xmm1
movss  0xc8c(%rip),%xmm2
call   10a0 <r4@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xc79(%rip),%xmm0
movss  0xc69(%rip),%xmm1
movss  0xc65(%rip),%xmm2
call   1030 <r5@plt>
lea    0xc8f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movss  0xc4f(%rip),%xmm0
movss  0xc3b(%rip),%xmm1
movss  0xc37(%rip),%xmm2
call   1030 <r5@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"(%f) %f\0A\00"
@.str.1 = [24 x i8] c"Case 2: Ts < Tr < 2*Ts\0A\00"
@.str.2 = [8 x i8] c"r1: %f\0A\00"
@.str.3 = [8 x i8] c"r2: %f\0A\00"
@.str.4 = [9 x i8] c"sr3: %f\0A\00"
@.str.5 = [8 x i8] c"r4: %f\0A\00"
@.str.6 = [8 x i8] c"r5: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %2
store float 1.000000e+00, float* %3
%11 = call float* @arange(i32 0, i32 10, double 1.000000e-03, i32* %7)
store float* %11, float** %5
store float 1.000000e+00, float* %9
store float 2.000000e+00, float* %10
%12 = load float*, float** %5
%13 = load i32, i32* %7
%14 = load float, float* %10
%15 = load float, float* %9
%16 = load float, float* %2
%17 = load float, float* %3
%18 = call float* @tinti(float* %12, i32 %13, float %14, float %15, float %16, float %17)
store float* %18, float** %6
store i32 0, i32* %4
br label %19
19: ; preds = %37, %0
%20 = load i32, i32* %4
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load float*, float** %5
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = load float, float* %27
%29 = fpext float %28 to double
%30 = load float*, float** %6
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
%34 = load float, float* %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %29, double %35)
br label %37
37: ; preds = %23
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %19
40: ; preds = %19
%41 = load float*, float** %6
%42 = call i32 @free(float* %41)
store float 1.000000e+00, float* %9
store float 2.000000e+00, float* %10
%43 = load float*, float** %5
%44 = load i32, i32* %7
%45 = load float, float* %10
%46 = load float, float* %9
%47 = load float, float* %2
%48 = load float, float* %3
%49 = call float* @tinti(float* %43, i32 %44, float %45, float %46, float %47, float %48)
store float* %49, float** %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%51 = load float, float* %10
%52 = call double @r1(float 0.000000e+00, float %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %52)
%54 = load float, float* %9
%55 = load float, float* %10
%56 = call double @r1(float %54, float %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %56)
%58 = load float, float* %10
%59 = load float, float* %10
%60 = load float, float* %9
%61 = call double @r2(float %58, float %59, float %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %61)
%63 = load float, float* %10
%64 = load float, float* %10
%65 = load float, float* %9
%66 = call double @r2(float %63, float %64, float %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %66)
%68 = load float, float* %10
%69 = fptosi float %68 to i32
%70 = load float, float* %10
%71 = load float, float* %9
%72 = call double @sr3(i32 %69, float %70, float %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), double %72)
%74 = load float, float* %9
%75 = fmul float 2.000000e+00, %74
%76 = fptosi float %75 to i32
%77 = load float, float* %10
%78 = load float, float* %9
%79 = call double @sr3(i32 %76, float %77, float %78)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), double %79)
%81 = load float, float* %9
%82 = fmul float 2.000000e+00, %81
%83 = load float, float* %10
%84 = load float, float* %9
%85 = call double @r4(float %82, float %83, float %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %85)
%87 = load float, float* %10
%88 = load float, float* %9
%89 = fadd float %87, %88
%90 = load float, float* %10
%91 = load float, float* %9
%92 = call double @r4(float %89, float %90, float %91)
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %92)
%94 = load float, float* %10
%95 = load float, float* %9
%96 = fadd float %94, %95
%97 = load float, float* %10
%98 = load float, float* %9
%99 = call double @r5(float %96, float %97, float %98)
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %99)
%101 = load float, float* %10
%102 = load float, float* %9
%103 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %102, float %101)
%104 = load float, float* %10
%105 = load float, float* %9
%106 = call double @r5(float %103, float %104, float %105)
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %106)
%108 = load float*, float** %6
%109 = call i32 @free(float* %108)
%110 = load float*, float** %5
%111 = call i32 @free(float* %110)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"(%f) %f\0A\00"
@.str.2 = [8 x i8] c"r1: %f\0A\00"
@.str.3 = [8 x i8] c"r2: %f\0A\00"
@.str.4 = [9 x i8] c"sr3: %f\0A\00"
@.str.5 = [8 x i8] c"r4: %f\0A\00"
@.str.6 = [8 x i8] c"r5: %f\0A\00"
@str = [23 x i8] c"Case 2: Ts < Tr < 2*Ts\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call float* @arange(i32 0, i32 10, double 1.000000e-03, i32* %1)
%4 = load i32, i32* %1
%5 = call float* @tinti(float* %3, i32 %4, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %0, %8
%9 = phi i64 [ %17, %8 ], [ 0, %0 ]
%10 = getelementptr inbounds float, float* %3, i64 %9
%11 = load float, float* %10
%12 = fpext float %11 to double
%13 = getelementptr inbounds float, float* %5, i64 %9
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %12, double %15)
%17 = add nuw nsw i64 %9, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %8, label %21
21: ; preds = %8, %0
%22 = call i32 @free(float* %5)
%23 = load i32, i32* %1
%24 = call float* @tinti(float* %3, i32 %23, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%26 = call double @r1(float 0.000000e+00, float 2.000000e+00)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = call double @r1(float 1.000000e+00, float 2.000000e+00)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = call double @r2(float 2.000000e+00, float 2.000000e+00, float 1.000000e+00)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = call double @r2(float 2.000000e+00, float 2.000000e+00, float 1.000000e+00)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %32)
%34 = call double @sr3(i32 2, float 2.000000e+00, float 1.000000e+00)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), double %34)
%36 = call double @sr3(i32 2, float 2.000000e+00, float 1.000000e+00)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), double %36)
%38 = call double @r4(float 2.000000e+00, float 2.000000e+00, float 1.000000e+00)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %38)
%40 = call double @r4(float 3.000000e+00, float 2.000000e+00, float 1.000000e+00)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %40)
%42 = call double @r5(float 3.000000e+00, float 2.000000e+00, float 1.000000e+00)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %42)
%44 = call double @r5(float 4.000000e+00, float 2.000000e+00, float 1.000000e+00)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), double %44)
%46 = call i32 @free(float* %24)
%47 = call i32 @free(float* %3)
ret i32 0
}