#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 exp(double);
double pow(double, double);
void initial_condition(double *u, int n_x, double delta_x) {
  int i;
  for (i = 0; i < n_x; i++) {
    double x = i * delta_x;
    u[i] = exp(-pow((x - 0.3), 2.0) / 0.01);
  }
}


x86 assembly (clang, -O0):
<initial_condition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    11b7 <initial_condition+0x97>
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe99(%rip),%xmm1
call   1040 <pow@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
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    113b <initial_condition+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_condition>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1169 <initial_condition+0x59>
movapd %xmm0,%xmm1
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xebd(%rip),%xmm0
mulsd  %xmm0,%xmm0
divsd  0xeb9(%rip),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <initial_condition+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 = %28, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %31
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 = fsub double %18, 3.000000e-01
%20 = call double @pow(double %19, double 2.000000e+00)
%21 = fneg double %20
%22 = fdiv double %21, 1.000000e-02
%23 = call double @exp(double %22)
%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 %23, double* %27
br label %28
28: ; preds = %13
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %9
31: ; 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 %20
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %18, %7 ]
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, %2
%12 = fadd double %11, -3.000000e-01
%13 = fneg double %12
%14 = fmul double %12, %13
%15 = fdiv double %14, 1.000000e-02
%16 = tail call double @exp(double %15)
%17 = getelementptr inbounds double, double* %0, i64 %8
store double %16, double* %17
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %7, %3
ret void
}