#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 */
double sqrt(double);
void project_soc(double *x, const int n) {
  double nx = 0;
  int i;
#pragma omp parallel for
  for (i = 1; i < n; i++) {
    nx += x[i] * x[i];
  }
  nx = sqrt(nx);
  if (nx <= x[0]) {
  } else if (nx <= -x[0]) {
#pragma omp parallel for
    for (i = 0; i < n; i++)
      x[i] = 0;
  } else {
    double alpha = 0.5 * (1 + x[0] / nx);
    x[0] = alpha * nx;
#pragma omp parallel for
    for (i = 1; i < n; i++)
      x[i] = alpha * x[i];
  }
}


x86 assembly (clang, -O0):
<project_soc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1174 <project_soc+0x64>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <project_soc+0x1e>
movsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     119f <project_soc+0x8f>
jmp    1289 <project_soc+0x179>
movsd  -0x18(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     1203 <project_soc+0xf3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <project_soc+0xee>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d4 <project_soc+0xc4>
jmp    1284 <project_soc+0x174>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xddc(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127f <project_soc+0x16f>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1246 <project_soc+0x136>
jmp    1284 <project_soc+0x174>
jmp    1289 <project_soc+0x179>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_soc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
cmp    $0x2,%esi
jl     11d6 <project_soc+0xb6>
mov    %ebp,%ecx
lea    -0x1(%rcx),%rdx
add    $0xfffffffffffffffe,%rcx
mov    %edx,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    115e <project_soc+0x3e>
xorpd  %xmm0,%xmm0
mov    $0x1,%ecx
test   %rax,%rax
jne    11ba <project_soc+0x9a>
jmp    11d6 <project_soc+0xb6>
and    $0xfffffffffffffffc,%rdx
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rbx,%rcx,8),%xmm2
movsd  0x10(%rbx,%rcx,8),%xmm3
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm3
addsd  %xmm2,%xmm3
movsd  0x18(%rbx,%rcx,8),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
movsd  0x20(%rbx,%rcx,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    1170 <project_soc+0x50>
add    $0x1,%rcx
test   %rax,%rax
je     11d6 <project_soc+0xb6>
lea    (%rbx,%rcx,8),%rcx
xor    %edx,%edx
movsd  (%rcx,%rdx,8),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
jne    11c0 <project_soc+0xa0>
ucomisd %xmm1,%xmm0
jb     11e2 <project_soc+0xc2>
sqrtsd %xmm0,%xmm0
jmp    11e7 <project_soc+0xc7>
call   1040 <sqrt@plt>
movsd  (%rbx),%xmm1
ucomisd %xmm0,%xmm1
jae    132d <project_soc+0x20d>
movapd 0xe03(%rip),%xmm2
xorpd  %xmm1,%xmm2
ucomisd %xmm0,%xmm2
jae    1319 <project_soc+0x1f9>
divsd  %xmm0,%xmm1
addsd  0xdf9(%rip),%xmm1
mulsd  0xdf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
cmp    $0x2,%ebp
jl     132d <project_soc+0x20d>
mov    %ebp,%eax
lea    -0x1(%rax),%rdx
mov    $0x1,%ecx
cmp    $0x4,%rdx
jb     1300 <project_soc+0x1e0>
mov    %rdx,%rcx
and    $0xfffffffffffffffc,%rcx
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
lea    -0x4(%rcx),%rsi
mov    %rsi,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     1334 <project_soc+0x214>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
mov    $0x1,%esi
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rsi,8),%xmm2
movupd 0x10(%rbx,%rsi,8),%xmm3
movupd 0x20(%rbx,%rsi,8),%xmm4
movupd 0x30(%rbx,%rsi,8),%xmm5
mulpd  %xmm0,%xmm2
mulpd  %xmm0,%xmm3
movupd %xmm2,(%rbx,%rsi,8)
movupd %xmm3,0x10(%rbx,%rsi,8)
mulpd  %xmm0,%xmm4
mulpd  %xmm0,%xmm5
movupd %xmm4,0x20(%rbx,%rsi,8)
movupd %xmm5,0x30(%rbx,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1280 <project_soc+0x160>
test   $0x1,%bpl
je     12ec <project_soc+0x1cc>
movupd (%rbx,%rsi,8),%xmm2
movupd 0x10(%rbx,%rsi,8),%xmm3
mulpd  %xmm0,%xmm2
mulpd  %xmm0,%xmm3
movupd %xmm2,(%rbx,%rsi,8)
movupd %xmm3,0x10(%rbx,%rsi,8)
cmp    %rcx,%rdx
je     132d <project_soc+0x20d>
or     $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1300 <project_soc+0x1e0>
jmp    132d <project_soc+0x20d>
test   %ebp,%ebp
jle    132d <project_soc+0x20d>
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%esi
test   $0x1,%bpl
jne    12ce <project_soc+0x1ae>
jmp    12ec <project_soc+0x1cc>

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

LLVM IR (-O2):
define void @project_soc(double* nocapture %0, i32 %1) {
%3 = bitcast double* %0 to i8*
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %50
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = add nsw i64 %6, -1
%8 = add nsw i64 %6, -2
%9 = and i64 %7, 3
%10 = icmp ult i64 %8, 3
br i1 %10, label %35, label %11
11: ; preds = %5
%12 = and i64 %7, -4
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 1, %11 ], [ %32, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %31, %13 ]
%16 = phi i64 [ 0, %11 ], [ %33, %13 ]
%17 = getelementptr inbounds double, double* %0, i64 %14
%18 = load double, double* %17
%19 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %15)
%20 = add nuw nsw i64 %14, 1
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %19)
%24 = add nuw nsw i64 %14, 2
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %23)
%28 = add nuw nsw i64 %14, 3
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %27)
%32 = add nuw nsw i64 %14, 4
%33 = add i64 %16, 4
%34 = icmp eq i64 %33, %12
br i1 %34, label %35, label %13
35: ; preds = %13, %5
%36 = phi double [ undef, %5 ], [ %31, %13 ]
%37 = phi i64 [ 1, %5 ], [ %32, %13 ]
%38 = phi double [ 0.000000e+00, %5 ], [ %31, %13 ]
%39 = icmp eq i64 %9, 0
br i1 %39, label %50, label %40
40: ; preds = %35, %40
%41 = phi i64 [ %47, %40 ], [ %37, %35 ]
%42 = phi double [ %46, %40 ], [ %38, %35 ]
%43 = phi i64 [ %48, %40 ], [ 0, %35 ]
%44 = getelementptr inbounds double, double* %0, i64 %41
%45 = load double, double* %44
%46 = tail call double @llvm.fmuladd.f64(double %45, double %45, double %42)
%47 = add nuw nsw i64 %41, 1
%48 = add i64 %43, 1
%49 = icmp eq i64 %48, %9
br i1 %49, label %50, label %40
50: ; preds = %35, %40, %2
%51 = phi double [ 0.000000e+00, %2 ], [ %36, %35 ], [ %46, %40 ]
%52 = tail call double @sqrt(double %51)
%53 = load double, double* %0
%54 = fcmp ugt double %52, %53
br i1 %54, label %55, label %141
55: ; preds = %50
%56 = fneg double %53
%57 = fcmp ugt double %52, %56
br i1 %57, label %63, label %58
58: ; preds = %55
%59 = icmp sgt i32 %1, 0
br i1 %59, label %60, label %141
60: ; preds = %58
%61 = zext i32 %1 to i64
%62 = shl nuw nsw i64 %61, 3
br label %141
63: ; preds = %55
%64 = fdiv double %53, %52
%65 = fadd double %64, 1.000000e+00
%66 = fmul double %65, 5.000000e-01
%67 = fmul double %52, %66
store double %67, double* %0
br i1 %4, label %68, label %141
68: ; preds = %63
%69 = zext i32 %1 to i64
%70 = add nsw i64 %69, -1
%71 = icmp ult i64 %70, 4
br i1 %71, label %132, label %72
72: ; preds = %68
%73 = and i64 %70, -4
%74 = or i64 %73, 1
%75 = insertelement <2 x double> poison, double %66, i64 0
%76 = shufflevector <2 x double> %75, <2 x double> poison, <2 x i32> zeroinitializer
%77 = insertelement <2 x double> poison, double %66, i64 0
%78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
%79 = add nsw i64 %73, -4
%80 = lshr exact i64 %79, 2
%81 = add nuw nsw i64 %80, 1
%82 = and i64 %81, 1
%83 = icmp eq i64 %79, 0
br i1 %83, label %116, label %84
84: ; preds = %72
%85 = and i64 %81, 9223372036854775806
br label %86
86: ; preds = %86, %84
%87 = phi i64 [ 0, %84 ], [ %111, %86 ]
%88 = phi i64 [ 0, %84 ], [ %112, %86 ]
%89 = or i64 %87, 1
%90 = getelementptr inbounds double, double* %0, i64 %89
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %90, i64 2
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = fmul <2 x double> %76, %92
%97 = fmul <2 x double> %78, %95
%98 = bitcast double* %90 to <2 x double>*
store <2 x double> %96, <2 x double>* %98
%99 = bitcast double* %93 to <2 x double>*
store <2 x double> %97, <2 x double>* %99
%100 = or i64 %87, 5
%101 = getelementptr inbounds double, double* %0, i64 %100
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = getelementptr inbounds double, double* %101, i64 2
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = fmul <2 x double> %76, %103
%108 = fmul <2 x double> %78, %106
%109 = bitcast double* %101 to <2 x double>*
store <2 x double> %107, <2 x double>* %109
%110 = bitcast double* %104 to <2 x double>*
store <2 x double> %108, <2 x double>* %110
%111 = add nuw i64 %87, 8
%112 = add i64 %88, 2
%113 = icmp eq i64 %112, %85
br i1 %113, label %114, label %86
114: ; preds = %86
%115 = or i64 %111, 1
br label %116
116: ; preds = %114, %72
%117 = phi i64 [ 1, %72 ], [ %115, %114 ]
%118 = icmp eq i64 %82, 0
br i1 %118, label %130, label %119
119: ; preds = %116
%120 = getelementptr inbounds double, double* %0, i64 %117
%121 = bitcast double* %120 to <2 x double>*
%122 = load <2 x double>, <2 x double>* %121
%123 = getelementptr inbounds double, double* %120, i64 2
%124 = bitcast double* %123 to <2 x double>*
%125 = load <2 x double>, <2 x double>* %124
%126 = fmul <2 x double> %76, %122
%127 = fmul <2 x double> %78, %125
%128 = bitcast double* %120 to <2 x double>*
store <2 x double> %126, <2 x double>* %128
%129 = bitcast double* %123 to <2 x double>*
store <2 x double> %127, <2 x double>* %129
br label %130
130: ; preds = %116, %119
%131 = icmp eq i64 %70, %73
br i1 %131, label %141, label %132
132: ; preds = %68, %130
%133 = phi i64 [ 1, %68 ], [ %74, %130 ]
br label %134
134: ; preds = %132, %134
%135 = phi i64 [ %139, %134 ], [ %133, %132 ]
%136 = getelementptr inbounds double, double* %0, i64 %135
%137 = load double, double* %136
%138 = fmul double %66, %137
store double %138, double* %136
%139 = add nuw nsw i64 %135, 1
%140 = icmp eq i64 %139, %69
br i1 %140, label %141, label %134
141: ; preds = %134, %130, %60, %58, %63, %50
ret void
}