#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 /*<<< orphan*/ fabs(double);
double log(int /*<<< orphan*/);
double sin(double);
void oszfunc(double *x, double *xosz, int nx) {
  int i, sx;
  double c1, c2, xx = 0;
  for (i = 0; i < nx; i++) {
    if (i == 0 || i == nx - 1) {
      if (x[i] != 0)
        xx = log(fabs(x[i]));
      if (x[i] > 0) {
        c1 = 10;
        c2 = 7.9;
      } else {
        c1 = 5.5;
        c2 = 3.1;
      }
      if (x[i] > 0)
        sx = 1;
      else if (x[i] == 0)
        sx = 0;
      else
        sx = -1;
      xosz[i] = sx * exp(xx + 0.049 * (sin(c1 * xx) + sin(c2 * xx)));
    } else
      xosz[i] = x[i];
  }
}


x86 assembly (clang, -O0):
<oszfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1321 <oszfunc+0x1e1>
cmpl   $0x0,-0x18(%rbp)
je     1189 <oszfunc+0x49>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12f4 <oszfunc+0x1b4>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ae <oszfunc+0x6e>
jp     11ae <oszfunc+0x6e>
jmp    11cc <oszfunc+0x8c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1060 <log@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1205 <oszfunc+0xc5>
movsd  0xe2a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe15(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    121f <oszfunc+0xdf>
movsd  0xdfb(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xde6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1245 <oszfunc+0x105>
movl   $0x1,-0x1c(%rbp)
jmp    127d <oszfunc+0x13d>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1271 <oszfunc+0x131>
jp     1271 <oszfunc+0x131>
movl   $0x0,-0x1c(%rbp)
jmp    1278 <oszfunc+0x138>
movl   $0xffffffff,-0x1c(%rbp)
jmp    127d <oszfunc+0x13d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
addsd  %xmm2,%xmm0
movsd  0xd57(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <exp@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    130e <oszfunc+0x1ce>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1313 <oszfunc+0x1d3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1162 <oszfunc+0x22>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oszfunc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    124e <oszfunc+0x10e>
mov    %rsi,%r14
mov    %rdi,%r13
lea    -0x1(%rdx),%eax
mov    %rax,0x8(%rsp)
mov    %edx,%r12d
xor    %ebx,%ebx
xorpd  %xmm2,%xmm2
jmp    120f <oszfunc+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm2,(%rsp)
xor    %r15d,%r15d
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
cmpneqsd %xmm1,%xmm0
movq   %xmm0,%rbp
mov    $0x1,%eax
cmova  %eax,%ebp
seta   %r15b
lea    0xe53(%rip),%rax
movsd  (%rax,%r15,8),%xmm0
mulsd  %xmm2,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
lea    0xe47(%rip),%rax
movsd  (%rax,%r15,8),%xmm0
mulsd  (%rsp),%xmm0
call   1040 <sin@plt>
addsd  0x10(%rsp),%xmm0
mulsd  0xe39(%rip),%xmm0
addsd  (%rsp),%xmm0
call   1050 <exp@plt>
movsd  (%rsp),%xmm2
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     124e <oszfunc+0x10e>
movsd  0x0(%r13,%rbx,8),%xmm0
test   %rbx,%rbx
je     1222 <oszfunc+0xe2>
cmp    %rbx,0x8(%rsp)
jne    1200 <oszfunc+0xc0>
ucomisd 0xdfe(%rip),%xmm0
jne    1232 <oszfunc+0xf2>
jnp    1180 <oszfunc+0x40>
call   1030 <fabs@plt>
mov    %eax,%edi
call   1060 <log@plt>
movapd %xmm0,%xmm2
movsd  0x0(%r13,%rbx,8),%xmm0
jmp    1180 <oszfunc+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @oszfunc(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %11
store i32 0, i32* %7
br label %12
12: ; preds = %97, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %100
16: ; preds = %12
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %86
24: ; preds = %19, %16
%25 = load double*, double** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fcmp une double %29, 0.000000e+00
br i1 %30, label %31, label %39
31: ; preds = %24
%32 = load double*, double** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = call i32 @fabs(double %36)
%38 = call double @log(i32 %37)
store double %38, double* %11
br label %39
39: ; preds = %31, %24
%40 = load double*, double** %4
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fcmp ogt double %44, 0.000000e+00
br i1 %45, label %46, label %47
46: ; preds = %39
store double 1.000000e+01, double* %9
store double 7.900000e+00, double* %10
br label %48
47: ; preds = %39
store double 5.500000e+00, double* %9
store double 3.100000e+00, double* %10
br label %48
48: ; preds = %47, %46
%49 = load double*, double** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = fcmp ogt double %53, 0.000000e+00
br i1 %54, label %55, label %56
55: ; preds = %48
store i32 1, i32* %8
br label %66
56: ; preds = %48
%57 = load double*, double** %4
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = fcmp oeq double %61, 0.000000e+00
br i1 %62, label %63, label %64
63: ; preds = %56
store i32 0, i32* %8
br label %65
64: ; preds = %56
store i32 -1, i32* %8
br label %65
65: ; preds = %64, %63
br label %66
66: ; preds = %65, %55
%67 = load i32, i32* %8
%68 = load double, double* %11
%69 = load double, double* %9
%70 = load double, double* %11
%71 = fmul double %69, %70
%72 = call double @sin(double %71)
%73 = load double, double* %10
%74 = load double, double* %11
%75 = fmul double %73, %74
%76 = call double @sin(double %75)
%77 = fadd double %72, %76
%78 = call double @llvm.fmuladd.f64(double 4.900000e-02, double %77, double %68)
%79 = call i32 @exp(double %78)
%80 = mul nsw i32 %67, %79
%81 = sitofp i32 %80 to double
%82 = load double*, double** %5
%83 = load i32, i32* %7
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %82, i64 %84
store double %81, double* %85
br label %96
86: ; preds = %19
%87 = load double*, double** %4
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
%91 = load double, double* %90
%92 = load double*, double** %5
%93 = load i32, i32* %7
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
store double %91, double* %95
br label %96
96: ; preds = %86, %66
br label %97
97: ; preds = %96
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %12
100: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @oszfunc(double* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %47
5: ; preds = %3
%6 = add nsw i32 %2, -1
%7 = zext i32 %6 to i64
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %5, %41
%10 = phi i64 [ 0, %5 ], [ %45, %41 ]
%11 = phi double [ 0.000000e+00, %5 ], [ %43, %41 ]
%12 = icmp eq i64 %10, 0
%13 = icmp eq i64 %10, %7
%14 = select i1 %12, i1 true, i1 %13
%15 = getelementptr inbounds double, double* %0, i64 %10
%16 = load double, double* %15
br i1 %14, label %17, label %41
17: ; preds = %9
%18 = fcmp une double %16, 0.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = tail call i32 @fabs(double %16)
%21 = tail call double @log(i32 %20)
%22 = load double, double* %15
br label %23
23: ; preds = %19, %17
%24 = phi double [ %22, %19 ], [ %16, %17 ]
%25 = phi double [ %21, %19 ], [ %11, %17 ]
%26 = fcmp ogt double %24, 0.000000e+00
%27 = select i1 %26, double 1.000000e+01, double 5.500000e+00
%28 = select i1 %26, double 7.900000e+00, double 3.100000e+00
%29 = fcmp une double %24, 0.000000e+00
%30 = sext i1 %29 to i32
%31 = select i1 %26, i32 1, i32 %30
%32 = fmul double %25, %27
%33 = tail call double @sin(double %32)
%34 = fmul double %25, %28
%35 = tail call double @sin(double %34)
%36 = fadd double %33, %35
%37 = tail call double @llvm.fmuladd.f64(double %36, double 4.900000e-02, double %25)
%38 = tail call i32 @exp(double %37)
%39 = mul nsw i32 %31, %38
%40 = sitofp i32 %39 to double
br label %41
41: ; preds = %9, %23
%42 = phi double [ %40, %23 ], [ %16, %9 ]
%43 = phi double [ %25, %23 ], [ %11, %9 ]
%44 = getelementptr inbounds double, double* %1, i64 %10
store double %42, double* %44
%45 = add nuw nsw i64 %10, 1
%46 = icmp eq i64 %45, %8
br i1 %46, label %47, label %9
47: ; preds = %41, %3
ret void
}