void initial_condition(double *u, int n_points, double delta_x) {
  int i;
  for (i = 0; i < n_points; i++) {
    double x = i * delta_x;
    if (x < 1.25 && x > 0.75) {
      u[i] = 2.0;
    } else {
      u[i] = 0.0;
    }
  }
}


x86 assembly (clang, -O0):
<initial_condition>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1199 <initial_condition+0x99>
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec6(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1176 <initial_condition+0x76>
movsd  -0x28(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1176 <initial_condition+0x76>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1186 <initial_condition+0x86>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    118b <initial_condition+0x8b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <initial_condition+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_condition>:
test   %esi,%esi
jle    121f <initial_condition+0x11f>
mov    %esi,%eax
cmp    $0x4,%esi
jae    1116 <initial_condition+0x16>
xor    %ecx,%ecx
jmp    11d5 <initial_condition+0xd5>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    0x0(,%rax,8),%rdx
and    $0xffffffffffffffe0,%rdx
movdqa 0xec9(%rip),%xmm3
xor    %esi,%esi
movdqa 0xece(%rip),%xmm8
movapd 0xed5(%rip),%xmm10
movapd 0xedd(%rip),%xmm4
movapd 0xee5(%rip),%xmm6
movdqa 0xeec(%rip),%xmm9
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm3,%xmm2
paddd  %xmm8,%xmm2
cvtdq2pd %xmm3,%xmm7
cvtdq2pd %xmm2,%xmm2
mulpd  %xmm1,%xmm7
mulpd  %xmm1,%xmm2
movapd %xmm4,%xmm5
cmpltpd %xmm7,%xmm5
cmpltpd %xmm10,%xmm7
andpd  %xmm5,%xmm7
movapd %xmm4,%xmm5
cmpltpd %xmm2,%xmm5
cmpltpd %xmm10,%xmm2
andpd  %xmm5,%xmm2
andpd  %xmm6,%xmm7
andpd  %xmm6,%xmm2
movupd %xmm7,(%rdi,%rsi,1)
movupd %xmm2,0x10(%rdi,%rsi,1)
paddd  %xmm9,%xmm3
add    $0x20,%rsi
cmp    %rsi,%rdx
jne    1170 <initial_condition+0x70>
cmp    %rax,%rcx
je     121f <initial_condition+0x11f>
movsd  0xe83(%rip),%xmm1
movsd  0xe83(%rip),%xmm2
movsd  0xe83(%rip),%xmm3
nopl   (%rax)
xorps  %xmm4,%xmm4
cvtsi2sd %ecx,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm2,%xmm5
cmpltsd %xmm4,%xmm5
cmpltsd %xmm1,%xmm4
andpd  %xmm3,%xmm5
andpd  %xmm4,%xmm5
movlpd %xmm5,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11f0 <initial_condition+0xf0>
ret

LLVM IR (-O0):
define void @initial_condition(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
store i32 0, i32* %7
br label %9
9: ; preds = %34, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load i32, i32* %7
%15 = sitofp i32 %14 to double
%16 = load double, double* %6
%17 = fmul double %15, %16
store double %17, double* %8
%18 = load double, double* %8
%19 = fcmp olt double %18, 1.250000e+00
br i1 %19, label %20, label %28
20: ; preds = %13
%21 = load double, double* %8
%22 = fcmp ogt double %21, 7.500000e-01
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load double*, double** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double 2.000000e+00, double* %27
br label %33
28: ; preds = %20, %13
%29 = load double*, double** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double 0.000000e+00, double* %32
br label %33
33: ; preds = %28, %23
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %9
37: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @initial_condition(double* nocapture writeonly %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %53
5: ; preds = %3
%6 = zext i32 %1 to i64
%7 = icmp ult i32 %1, 4
br i1 %7, label %39, label %8
8: ; preds = %5
%9 = and i64 %6, 4294967292
%10 = insertelement <2 x double> poison, double %2, i64 0
%11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
%12 = insertelement <2 x double> poison, double %2, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
br label %14
14: ; preds = %14, %8
%15 = phi i64 [ 0, %8 ], [ %34, %14 ]
%16 = phi <2 x i32> [ <i32 0, i32 1>, %8 ], [ %35, %14 ]
%17 = add <2 x i32> %16, <i32 2, i32 2>
%18 = sitofp <2 x i32> %16 to <2 x double>
%19 = sitofp <2 x i32> %17 to <2 x double>
%20 = fmul <2 x double> %11, %18
%21 = fmul <2 x double> %13, %19
%22 = fcmp olt <2 x double> %20, <double 1.250000e+00, double 1.250000e+00>
%23 = fcmp olt <2 x double> %21, <double 1.250000e+00, double 1.250000e+00>
%24 = fcmp ogt <2 x double> %20, <double 7.500000e-01, double 7.500000e-01>
%25 = fcmp ogt <2 x double> %21, <double 7.500000e-01, double 7.500000e-01>
%26 = and <2 x i1> %22, %24
%27 = and <2 x i1> %23, %25
%28 = select <2 x i1> %26, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> zeroinitializer
%29 = select <2 x i1> %27, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> zeroinitializer
%30 = getelementptr inbounds double, double* %0, i64 %15
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %28, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> %29, <2 x double>* %33
%34 = add nuw i64 %15, 4
%35 = add <2 x i32> %16, <i32 4, i32 4>
%36 = icmp eq i64 %34, %9
br i1 %36, label %37, label %14
37: ; preds = %14
%38 = icmp eq i64 %9, %6
br i1 %38, label %53, label %39
39: ; preds = %5, %37
%40 = phi i64 [ 0, %5 ], [ %9, %37 ]
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ %51, %41 ], [ %40, %39 ]
%43 = trunc i64 %42 to i32
%44 = sitofp i32 %43 to double
%45 = fmul double %44, %2
%46 = fcmp olt double %45, 1.250000e+00
%47 = fcmp ogt double %45, 7.500000e-01
%48 = and i1 %46, %47
%49 = select i1 %48, double 2.000000e+00, double 0.000000e+00
%50 = getelementptr inbounds double, double* %0, i64 %42
store double %49, double* %50
%51 = add nuw nsw i64 %42, 1
%52 = icmp eq i64 %51, %6
br i1 %52, label %53, label %41
53: ; preds = %41, %37, %3
ret void
}