#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 /*<<< orphan*/ free(double *);
int /*<<< orphan*/ laplace1D_rhs(long, double *, double *);
double *malloc(long);
void driver(double alpha, long iter, long N, double a, double b,
            double *u_out) {
  long i;
  double *f = malloc((N - 2) * sizeof(double));
  for (i = 0; i < N - 2; i++) {
    f[i] = 0.0;
  }
  i = 0;
  f[i] = a;
  i = N - 3;
  f[i] = b;
  double *u = malloc((N - 2) * sizeof(double));
  double *out = malloc((N - 2) * sizeof(double));
  for (i = 0; i < N - 2; i++) {
    u[i] = 0.0;
    out[i] = 0.0;
  }
  long it = 0;
  while (it < iter) {
    laplace1D_rhs(N, u, out);
    for (i = 0; i < N - 2; i++) {
      u[i] = u[i] + alpha * (f[i] - out[i]);
    }
    it++;
  }
  u_out[0] = a;
  u_out[N - 1] = b;
  for (i = 1; i < N - 1; i++)
    u_out[i] = u[i - 1];
  free(f);
  free(out);
  free(u);
}


x86 assembly (clang, -O0):
<driver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
sub    $0x2,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    11a6 <driver+0x76>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1170 <driver+0x40>
movq   $0x0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
sub    $0x3,%rax
mov    %rax,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
sub    $0x2,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
sub    $0x2,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    1256 <driver+0x126>
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1210 <driver+0xe0>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    12fd <driver+0x1cd>
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rdx
call   1050 <laplace1D_rhs@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jge    12ec <driver+0x1bc>
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x8(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1285 <driver+0x155>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    125e <driver+0x12e>
movsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movq   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jge    136c <driver+0x23c>
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1328 <driver+0x1f8>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,0x30(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    %rsi,%rbp
mov    %rdi,0x20(%rsp)
movaps %xmm0,0x40(%rsp)
lea    -0x10(,%rsi,8),%r15
ff
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
cmp    $0x3,%rbp
jl     11a7 <driver+0x57>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x18(%rsp),%xmm0
mov    0x8(%rsp),%r12
movsd  %xmm0,-0x18(%rbx,%r12,8)
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
cmp    $0x3,%r12
jl     11f9 <driver+0xa9>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
mov    %r15,0x28(%rsp)
cmpq   $0x0,0x20(%rsp)
movapd 0x40(%rsp),%xmm0
jle    1319 <driver+0x1c9>
mov    0x8(%rsp),%rax
lea    -0x2(%rax),%r15
mov    %r15,%r13
and    $0xfffffffffffffffc,%r13
movapd %xmm0,%xmm6
unpcklpd %xmm0,%xmm6
xor    %eax,%eax
movapd %xmm6,0x50(%rsp)
mov    0x8(%rsp),%r12
jmp    1254 <driver+0x104>
nopw   0x0(%rax,%rax,1)
mov    0x38(%rsp),%rax
add    $0x1,%rax
cmp    0x20(%rsp),%rax
je     1319 <driver+0x1c9>
mov    %rax,0x38(%rsp)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1070 <laplace1D_rhs@plt>
movapd 0x50(%rsp),%xmm6
movapd 0x40(%rsp),%xmm5
cmp    $0x3,%r12
jl     1240 <driver+0xf0>
xor    %eax,%eax
cmp    $0x4,%r15
jb     12f0 <driver+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd 0x0(%rbp,%rax,8),%xmm0
movupd 0x10(%rbp,%rax,8),%xmm1
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
movupd (%r14,%rax,8),%xmm4
subpd  %xmm4,%xmm2
movupd 0x10(%r14,%rax,8),%xmm4
subpd  %xmm4,%xmm3
mulpd  %xmm6,%xmm2
addpd  %xmm0,%xmm2
mulpd  %xmm6,%xmm3
addpd  %xmm1,%xmm3
movupd %xmm2,0x0(%rbp,%rax,8)
movupd %xmm3,0x10(%rbp,%rax,8)
add    $0x4,%rax
cmp    %rax,%r13
jne    1290 <driver+0x140>
mov    %r13,%rax
cmp    %r13,%r15
je     1240 <driver+0xf0>
nopl   (%rax)
movsd  (%rbx,%rax,8),%xmm0
subsd  (%r14,%rax,8),%xmm0
mulsd  %xmm5,%xmm0
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%rax
cmp    %rax,%r15
jne    12f0 <driver+0x1a0>
jmp    1240 <driver+0xf0>
mov    0x30(%rsp),%rdi
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rdi)
movsd  0x18(%rsp),%xmm0
mov    0x8(%rsp),%rax
movsd  %xmm0,-0x8(%rdi,%rax,8)
cmp    $0x3,%rax
jl     1350 <driver+0x200>
add    $0x8,%rdi
mov    %rbp,%rsi
mov    0x28(%rsp),%rdx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @driver(double %0, i64 %1, i64 %2, double %3, double %4, double* nocapture writeonly %5) {
%7 = add nsw i64 %2, -2
%8 = shl i64 %7, 3
%9 = tail call double* @malloc(i64 %8)
%10 = icmp sgt i64 %2, 2
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = bitcast double* %9 to i8*
%13 = shl i64 %2, 3
%14 = add i64 %13, -16
br label %15
15: ; preds = %11, %6
store double %3, double* %9
%16 = add nsw i64 %2, -3
%17 = getelementptr inbounds double, double* %9, i64 %16
store double %4, double* %17
%18 = tail call double* @malloc(i64 %8)
%19 = bitcast double* %18 to i8*
%20 = tail call double* @malloc(i64 %8)
br i1 %10, label %21, label %25
21: ; preds = %15
%22 = bitcast double* %20 to i8*
%23 = shl i64 %2, 3
%24 = add i64 %23, -16
br label %25
25: ; preds = %21, %15
%26 = icmp sgt i64 %1, 0
br i1 %26, label %27, label %85
27: ; preds = %25
%28 = icmp ult i64 %7, 4
%29 = and i64 %7, -4
%30 = insertelement <2 x double> poison, double %0, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %0, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = icmp eq i64 %7, %29
br label %35
35: ; preds = %27, %82
%36 = phi i64 [ %83, %82 ], [ 0, %27 ]
%37 = tail call i32 @laplace1D_rhs(i64 %2, double* %18, double* %20)
br i1 %10, label %38, label %82
38: ; preds = %35
br i1 %28, label %68, label %39
39: ; preds = %38, %39
%40 = phi i64 [ %65, %39 ], [ 0, %38 ]
%41 = getelementptr inbounds double, double* %18, i64 %40
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %41, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %9, i64 %40
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %47, i64 2
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %20, i64 %40
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fsub <2 x double> %49, %55
%60 = fsub <2 x double> %52, %58
%61 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %59, <2 x double> %43)
%62 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %60, <2 x double> %46)
%63 = bitcast double* %41 to <2 x double>*
store <2 x double> %61, <2 x double>* %63
%64 = bitcast double* %44 to <2 x double>*
store <2 x double> %62, <2 x double>* %64
%65 = add nuw i64 %40, 4
%66 = icmp eq i64 %65, %29
br i1 %66, label %67, label %39
67: ; preds = %39
br i1 %34, label %82, label %68
68: ; preds = %38, %67
%69 = phi i64 [ 0, %38 ], [ %29, %67 ]
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ %80, %70 ], [ %69, %68 ]
%72 = getelementptr inbounds double, double* %18, i64 %71
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %9, i64 %71
%75 = load double, double* %74
%76 = getelementptr inbounds double, double* %20, i64 %71
%77 = load double, double* %76
%78 = fsub double %75, %77
%79 = tail call double @llvm.fmuladd.f64(double %0, double %78, double %73)
store double %79, double* %72
%80 = add nuw nsw i64 %71, 1
%81 = icmp eq i64 %80, %7
br i1 %81, label %82, label %70
82: ; preds = %70, %67, %35
%83 = add nuw nsw i64 %36, 1
%84 = icmp eq i64 %83, %1
br i1 %84, label %85, label %35
85: ; preds = %82, %25
store double %3, double* %5
%86 = add nsw i64 %2, -1
%87 = getelementptr inbounds double, double* %5, i64 %86
store double %4, double* %87
br i1 %10, label %88, label %93
88: ; preds = %85
%89 = getelementptr double, double* %5, i64 1
%90 = bitcast double* %89 to i8*
%91 = shl i64 %2, 3
%92 = add i64 %91, -16
br label %93
93: ; preds = %88, %85
%94 = tail call i32 @free(double* %9)
%95 = tail call i32 @free(double* %20)
%96 = tail call i32 @free(double* %18)
ret void
}