#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 expf(float);
void Terminal_condition(int M, float *X, float *YT, float S0, float T, float K,
                        float sigma, float mu, float r, float d) {
  float St;
  int i;
  for (i = 0; i <= M; i++) {
    St = S0 * expf(sigma * X[i] + (mu - 0.5 * sigma * sigma) * T);
    if (1 == 1) {
      YT[i] = (St - K) > (0.0) ? (St - K) : (0.0);
    } else {
      YT[i] = (K - St) > (0.0) ? (K - St) : (0.0);
    }
  }
}


x86 assembly (clang, -O0):
<Terminal_condition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
movss  %xmm2,-0x24(%rbp)
movss  %xmm3,-0x28(%rbp)
movss  %xmm4,-0x2c(%rbp)
movss  %xmm5,-0x30(%rbp)
movss  %xmm6,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     124e <Terminal_condition+0x13e>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm3
movsd  0xe6d(%rip),%xmm0
mulsd  %xmm3,%xmm0
movss  -0x28(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movss  -0x20(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <expf@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    121d <Terminal_condition+0x10d>
movss  -0x38(%rbp),%xmm0
subss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    122a <Terminal_condition+0x11a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    122a <Terminal_condition+0x11a>
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    114d <Terminal_condition+0x3d>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Terminal_condition>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movss  %xmm3,0x4(%rsp)
test   %edi,%edi
js     11ca <Terminal_condition+0xba>
movaps %xmm2,%xmm5
movaps %xmm0,%xmm6
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
movss  0x4(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
movsd  0xeaf(%rip),%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%r12d
xor    %ebx,%ebx
movss  %xmm5,0xc(%rsp)
movss  %xmm6,0x8(%rsp)
movss  (%r15,%rbx,4),%xmm0
mulss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <expf@plt>
movss  0x8(%rsp),%xmm6
movss  0xc(%rsp),%xmm5
mulss  %xmm6,%xmm0
subss  %xmm5,%xmm0
maxss  0xe4d(%rip),%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1180 <Terminal_condition+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Terminal_condition(i32 %0, float* %1, float* %2, float %3, float %4, float %5, float %6, float %7, float %8, float %9) {
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca i32
store i32 %0, i32* %11
store float* %1, float** %12
store float* %2, float** %13
store float %3, float* %14
store float %4, float* %15
store float %5, float* %16
store float %6, float* %17
store float %7, float* %18
store float %8, float* %19
store float %9, float* %20
store i32 0, i32* %22
br label %23
23: ; preds = %70, %10
%24 = load i32, i32* %22
%25 = load i32, i32* %11
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %73
27: ; preds = %23
%28 = load float, float* %14
%29 = load float, float* %17
%30 = load float*, float** %12
%31 = load i32, i32* %22
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
%34 = load float, float* %33
%35 = fmul float %29, %34
%36 = fpext float %35 to double
%37 = load float, float* %18
%38 = fpext float %37 to double
%39 = load float, float* %17
%40 = fpext float %39 to double
%41 = fmul double 5.000000e-01, %40
%42 = load float, float* %17
%43 = fpext float %42 to double
%44 = fneg double %41
%45 = call double @llvm.fmuladd.f64(double %44, double %43, double %38)
%46 = load float, float* %15
%47 = fpext float %46 to double
%48 = call double @llvm.fmuladd.f64(double %45, double %47, double %36)
%49 = fptrunc double %48 to float
%50 = call float @expf(float %49)
%51 = fmul float %28, %50
store float %51, float* %21
%52 = load float, float* %21
%53 = load float, float* %16
%54 = fsub float %52, %53
%55 = fpext float %54 to double
%56 = fcmp ogt double %55, 0.000000e+00
br i1 %56, label %57, label %62
57: ; preds = %27
%58 = load float, float* %21
%59 = load float, float* %16
%60 = fsub float %58, %59
%61 = fpext float %60 to double
br label %63
62: ; preds = %27
br label %63
63: ; preds = %62, %57
%64 = phi double [ %61, %57 ], [ 0.000000e+00, %62 ]
%65 = fptrunc double %64 to float
%66 = load float*, float** %13
%67 = load i32, i32* %22
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds float, float* %66, i64 %68
store float %65, float* %69
br label %70
70: ; preds = %63
%71 = load i32, i32* %22
%72 = add nsw i32 %71, 1
store i32 %72, i32* %22
br label %23
73: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @Terminal_condition(i32 %0, float* nocapture %1, float* nocapture writeonly %2, float %3, float %4, float %5, float %6, float %7, float %8, float %9) {
%11 = icmp slt i32 %0, 0
br i1 %11, label %36, label %12
12: ; preds = %10
%13 = fpext float %7 to double
%14 = fpext float %6 to double
%15 = fmul double %14, -5.000000e-01
%16 = tail call double @llvm.fmuladd.f64(double %15, double %14, double %13)
%17 = fpext float %4 to double
%18 = add nuw i32 %0, 1
%19 = zext i32 %18 to i64
br label %20
20: ; preds = %12, %20
%21 = phi i64 [ 0, %12 ], [ %34, %20 ]
%22 = getelementptr inbounds float, float* %1, i64 %21
%23 = load float, float* %22
%24 = fmul float %23, %6
%25 = fpext float %24 to double
%26 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %25)
%27 = fptrunc double %26 to float
%28 = tail call float @expf(float %27)
%29 = fmul float %28, %3
%30 = fsub float %29, %5
%31 = fcmp ogt float %30, 0.000000e+00
%32 = select i1 %31, float %30, float 0.000000e+00
%33 = getelementptr inbounds float, float* %2, i64 %21
store float %32, float* %33
%34 = add nuw nsw i64 %21, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %36, label %20
36: ; preds = %20, %10
ret void
}