#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);
float func(float);
float logf(float);
float sqrtf(float);
void blackscholes_sc(const int width, const int height, float *input,
                     float *output1, float *output2) {
  int y;
  for (y = 0; y < (width * height * 4); ++y) {
    float d, dd;
    float sig;
    float minus;
    float s = 10.0f * input[y] + 100.0f * (1.0f - input[y]);
    float t = 1.0f * input[y] + 10.0f * (1.0f - input[y]);
    float r = 0.01f * input[y] + 0.05f * (1.0f - input[y]);
    float sig2 = 0.01f * input[y] + 0.10f * (1.0f - input[y]);
    sig = sig2 * sqrtf(t);
    d = (logf(s / s) + (r + sig2 * sig2 / 2.0f) * t) / sig;
    dd = d - sig;
    minus = s * expf(-r * t);
    output1[y] = s * func(d) - minus * func(dd);
    output2[y] = minus * func(-dd) - s * func(-d);
  }
}


x86 assembly (clang, -O0):
<blackscholes_sc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    141b <blackscholes_sc+0x2db>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  0xe79(%rip),%xmm2
subss  (%rax,%rcx,4),%xmm2
movss  0xe78(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xe68(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  0xe36(%rip),%xmm2
subss  (%rax,%rcx,4),%xmm2
movss  0xe31(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  0xdff(%rip),%xmm2
subss  (%rax,%rcx,4),%xmm2
movss  0xdf6(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xdde(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  0xdbc(%rip),%xmm2
subss  (%rax,%rcx,4),%xmm2
movss  0xdab(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xd9b(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1060 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  -0x64(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x38(%rbp),%xmm0
divss  -0x38(%rbp),%xmm0
call   1030 <logf@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
movss  -0x44(%rbp),%xmm2
mulss  -0x44(%rbp),%xmm2
movss  0xd3c(%rip),%xmm3
divss  %xmm3,%xmm2
addss  %xmm2,%xmm0
movss  -0x3c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
divss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
subss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x40(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x3c(%rbp),%xmm0
call   1040 <expf@plt>
movaps %xmm0,%xmm1
movss  -0x60(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x28(%rbp),%xmm0
call   1050 <func@plt>
movss  %xmm0,-0x58(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x2c(%rbp),%xmm0
call   1050 <func@plt>
movss  -0x5c(%rbp),%xmm1
movss  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x54(%rbp),%xmm0
mulss  %xmm3,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x2c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <func@plt>
movss  %xmm0,-0x4c(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <func@plt>
movss  -0x50(%rbp),%xmm1
movss  -0x4c(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x48(%rbp),%xmm0
mulss  %xmm3,%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <blackscholes_sc+0x21>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackscholes_sc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
imul   %esi,%edi
shl    $0x2,%edi
test   %edi,%edi
jle    134e <blackscholes_sc+0x20e>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %edi,%r13d
xor    %ebx,%ebx
movss  0xe97(%rip),%xmm1
jmp    12ec <blackscholes_sc+0x1ac>
cs nopw 0x0(%rax,%rax,1)
movss  %xmm2,0x8(%rsp)
movaps %xmm3,0x30(%rsp)
movss  %xmm4,0x40(%rsp)
movss  %xmm5,0x10(%rsp)
movss  %xmm6,0x2c(%rsp)
call   1060 <sqrtf@plt>
movss  0x2c(%rsp),%xmm6
movss  0x10(%rsp),%xmm5
movss  0x40(%rsp),%xmm4
movaps 0x30(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
movss  0xe41(%rip),%xmm1
mulss  %xmm1,%xmm2
addss  %xmm5,%xmm2
movss  %xmm2,0x8(%rsp)
addss  %xmm6,%xmm3
movaps %xmm3,0x30(%rsp)
addss  %xmm6,%xmm4
movss  %xmm4,0x40(%rsp)
mulss  %xmm4,%xmm0
movss  %xmm0,0x10(%rsp)
movaps %xmm2,%xmm0
divss  %xmm2,%xmm0
call   1030 <logf@plt>
movss  0x40(%rsp),%xmm3
mulss  %xmm3,%xmm3
mulss  0xe08(%rip),%xmm3
movaps 0x30(%rsp),%xmm2
addss  %xmm2,%xmm3
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm3
addss  %xmm3,%xmm0
movss  0x10(%rsp),%xmm3
divss  %xmm3,%xmm0
movaps %xmm0,0x40(%rsp)
subss  %xmm3,%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdda(%rip),%xmm0
xorps  %xmm0,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm2,%xmm0
call   1040 <expf@plt>
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x30(%rsp)
movaps 0x40(%rsp),%xmm0
call   1050 <func@plt>
movss  %xmm0,0xc(%rsp)
movaps 0x10(%rsp),%xmm0
call   1050 <func@plt>
mulss  0x30(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mulss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,(%r15,%rbx,4)
movaps 0x10(%rsp),%xmm0
xorps  0xd7d(%rip),%xmm0
call   1050 <func@plt>
movss  %xmm0,0x10(%rsp)
movaps 0x40(%rsp),%xmm0
xorps  0xd66(%rip),%xmm0
call   1050 <func@plt>
movss  0xd41(%rip),%xmm1
mulss  0x8(%rsp),%xmm0
movss  0x10(%rsp),%xmm2
mulss  0x30(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  %xmm2,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
je     134e <blackscholes_sc+0x20e>
movss  (%r12,%rbx,4),%xmm2
movss  0xd06(%rip),%xmm4
subss  %xmm2,%xmm4
movaps %xmm4,%xmm5
mulss  0xcfb(%rip),%xmm5
movaps %xmm4,%xmm0
mulss  %xmm1,%xmm0
addss  %xmm2,%xmm0
movaps %xmm4,%xmm3
mulss  0xced(%rip),%xmm3
movaps %xmm2,%xmm6
mulss  0xce6(%rip),%xmm6
mulss  0xce2(%rip),%xmm4
ucomiss 0xce3(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
jb     1180 <blackscholes_sc+0x40>
sqrtss %xmm0,%xmm0
jmp    11c7 <blackscholes_sc+0x87>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @blackscholes_sc(i32 %0, i32 %1, float* %2, float* %3, float* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%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
store i32 %0, i32* %6
store i32 %1, i32* %7
store float* %2, float** %8
store float* %3, float** %9
store float* %4, float** %10
store i32 0, i32* %11
br label %20
20: ; preds = %136, %5
%21 = load i32, i32* %11
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = mul nsw i32 %22, %23
%25 = mul nsw i32 %24, 4
%26 = icmp slt i32 %21, %25
br i1 %26, label %27, label %139
27: ; preds = %20
%28 = load float*, float** %8
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = load float*, float** %8
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = fsub float 1.000000e+00, %37
%39 = fmul float 1.000000e+02, %38
%40 = call float @llvm.fmuladd.f32(float 1.000000e+01, float %32, float %39)
store float %40, float* %16
%41 = load float*, float** %8
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds float, float* %41, i64 %43
%45 = load float, float* %44
%46 = load float*, float** %8
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
%50 = load float, float* %49
%51 = fsub float 1.000000e+00, %50
%52 = fmul float 1.000000e+01, %51
%53 = call float @llvm.fmuladd.f32(float 1.000000e+00, float %45, float %52)
store float %53, float* %17
%54 = load float*, float** %8
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds float, float* %54, i64 %56
%58 = load float, float* %57
%59 = load float*, float** %8
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds float, float* %59, i64 %61
%63 = load float, float* %62
%64 = fsub float 1.000000e+00, %63
%65 = fmul float 0x3FA99999A0000000, %64
%66 = call float @llvm.fmuladd.f32(float 0x3F847AE140000000, float %58, float %65)
store float %66, float* %18
%67 = load float*, float** %8
%68 = load i32, i32* %11
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds float, float* %67, i64 %69
%71 = load float, float* %70
%72 = load float*, float** %8
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds float, float* %72, i64 %74
%76 = load float, float* %75
%77 = fsub float 1.000000e+00, %76
%78 = fmul float 0x3FB99999A0000000, %77
%79 = call float @llvm.fmuladd.f32(float 0x3F847AE140000000, float %71, float %78)
store float %79, float* %19
%80 = load float, float* %19
%81 = load float, float* %17
%82 = call float @sqrtf(float %81)
%83 = fmul float %80, %82
store float %83, float* %14
%84 = load float, float* %16
%85 = load float, float* %16
%86 = fdiv float %84, %85
%87 = call float @logf(float %86)
%88 = load float, float* %18
%89 = load float, float* %19
%90 = load float, float* %19
%91 = fmul float %89, %90
%92 = fdiv float %91, 2.000000e+00
%93 = fadd float %88, %92
%94 = load float, float* %17
%95 = call float @llvm.fmuladd.f32(float %93, float %94, float %87)
%96 = load float, float* %14
%97 = fdiv float %95, %96
store float %97, float* %12
%98 = load float, float* %12
%99 = load float, float* %14
%100 = fsub float %98, %99
store float %100, float* %13
%101 = load float, float* %16
%102 = load float, float* %18
%103 = fneg float %102
%104 = load float, float* %17
%105 = fmul float %103, %104
%106 = call float @expf(float %105)
%107 = fmul float %101, %106
store float %107, float* %15
%108 = load float, float* %16
%109 = load float, float* %12
%110 = call float @func(float %109)
%111 = load float, float* %15
%112 = load float, float* %13
%113 = call float @func(float %112)
%114 = fmul float %111, %113
%115 = fneg float %114
%116 = call float @llvm.fmuladd.f32(float %108, float %110, float %115)
%117 = load float*, float** %9
%118 = load i32, i32* %11
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds float, float* %117, i64 %119
store float %116, float* %120
%121 = load float, float* %15
%122 = load float, float* %13
%123 = fneg float %122
%124 = call float @func(float %123)
%125 = load float, float* %16
%126 = load float, float* %12
%127 = fneg float %126
%128 = call float @func(float %127)
%129 = fmul float %125, %128
%130 = fneg float %129
%131 = call float @llvm.fmuladd.f32(float %121, float %124, float %130)
%132 = load float*, float** %10
%133 = load i32, i32* %11
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds float, float* %132, i64 %134
store float %131, float* %135
br label %136
136: ; preds = %27
%137 = load i32, i32* %11
%138 = add nsw i32 %137, 1
store i32 %138, i32* %11
br label %20
139: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @blackscholes_sc(i32 %0, i32 %1, float* nocapture %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = shl i32 %0, 2
%7 = mul i32 %6, %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %54
9: ; preds = %5
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %52, %11 ]
%13 = getelementptr inbounds float, float* %2, i64 %12
%14 = load float, float* %13
%15 = fsub float 1.000000e+00, %14
%16 = fmul float %15, 1.000000e+02
%17 = tail call float @llvm.fmuladd.f32(float %14, float 1.000000e+01, float %16)
%18 = fmul float %15, 1.000000e+01
%19 = fadd float %14, %18
%20 = fmul float %15, 0x3FA99999A0000000
%21 = tail call float @llvm.fmuladd.f32(float %14, float 0x3F847AE140000000, float %20)
%22 = fmul float %15, 0x3FB99999A0000000
%23 = tail call float @llvm.fmuladd.f32(float %14, float 0x3F847AE140000000, float %22)
%24 = tail call float @sqrtf(float %19)
%25 = fmul float %24, %23
%26 = fdiv float %17, %17
%27 = tail call float @logf(float %26)
%28 = fmul float %23, %23
%29 = fmul float %28, 5.000000e-01
%30 = fadd float %21, %29
%31 = tail call float @llvm.fmuladd.f32(float %30, float %19, float %27)
%32 = fdiv float %31, %25
%33 = fsub float %32, %25
%34 = fneg float %21
%35 = fmul float %19, %34
%36 = tail call float @expf(float %35)
%37 = fmul float %17, %36
%38 = tail call float @func(float %32)
%39 = tail call float @func(float %33)
%40 = fneg float %37
%41 = fmul float %39, %40
%42 = tail call float @llvm.fmuladd.f32(float %17, float %38, float %41)
%43 = getelementptr inbounds float, float* %3, i64 %12
store float %42, float* %43
%44 = fneg float %33
%45 = tail call float @func(float %44)
%46 = fneg float %32
%47 = tail call float @func(float %46)
%48 = fneg float %17
%49 = fmul float %47, %48
%50 = tail call float @llvm.fmuladd.f32(float %37, float %45, float %49)
%51 = getelementptr inbounds float, float* %4, i64 %12
store float %50, float* %51
%52 = add nuw nsw i64 %12, 1
%53 = icmp eq i64 %52, %10
br i1 %53, label %54, label %11
54: ; preds = %11, %5
ret void
}