#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 *create_1D_array(unsigned int);
int /*<<< orphan*/ free(double *);
void solveTXeqB(double *diag, double *updiag, double *dndiag, double *X,
                double *B, unsigned N) {
  int i;
  double denom;
  double *alpha = create_1D_array(N);
  double *gamma = create_1D_array(N);
  alpha[0] = updiag[0] / diag[0];
  gamma[0] = B[0] / diag[0];
  for (i = 1; i < N; i++) {
    denom = diag[i] - dndiag[i] * alpha[i - 1];
    alpha[i] = updiag[i] / denom;
    gamma[i] = (B[i] - dndiag[i] * gamma[i - 1]) / denom;
  }
  X[N - 1] = gamma[N - 1];
  for (i = N - 2; i >= 0; i--)
    X[i] = gamma[i] - alpha[i] * X[i + 1];
  free(alpha);
  free(gamma);
}


x86 assembly (clang, -O0):
<solveTXeqB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <create_1D_array@plt>
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <create_1D_array@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    1275 <solveTXeqB+0x155>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    118f <solveTXeqB+0x6f>
mov    -0x48(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     1310 <solveTXeqB+0x1f0>
mov    -0x48(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    12a0 <solveTXeqB+0x180>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveTXeqB>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8,%r13
mov    %rcx,(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,%r14
mov    %r9d,%edi
call   1040 <create_1D_array@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1040 <create_1D_array@plt>
mov    %rbx,%rsi
mov    %rax,%rbx
movsd  (%r12),%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,(%r15)
movsd  0x0(%r13),%xmm0
divsd  (%r14),%xmm0
movsd  %xmm0,(%rax)
cmp    $0x1,%esi
jbe    11f4 <solveTXeqB+0xd4>
mov    (%rsp),%rdx
mov    %esi,%eax
lea    (%rbx,%rax,8),%rcx
cmp    %rcx,%r15
jae    120a <solveTXeqB+0xea>
lea    (%r15,%rax,8),%rcx
cmp    %rcx,%rbx
jae    120a <solveTXeqB+0xea>
lea    -0x8(,%rax,8),%rax
ff
xor    %ecx,%ecx
movsd  0x8(%r14,%rcx,1),%xmm0
movsd  0x8(%rbp,%rcx,1),%xmm1
mulsd  (%r15,%rcx,1),%xmm1
subsd  %xmm1,%xmm0
movsd  0x8(%r12,%rcx,1),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r15,%rcx,1)
movsd  0x8(%r13,%rcx,1),%xmm1
movsd  0x8(%rbp,%rcx,1),%xmm2
mulsd  (%rbx,%rcx,1),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx,%rcx,1)
add    $0x8,%rcx
cmp    %rcx,%rax
jne    11a0 <solveTXeqB+0x80>
jmp    126b <solveTXeqB+0x14b>
add    $0xffffffff,%esi
movsd  (%rbx,%rsi,8),%xmm0
mov    (%rsp),%rax
movsd  %xmm0,(%rax,%rsi,8)
jmp    12eb <solveTXeqB+0x1cb>
movsd  (%r15),%xmm0
movsd  (%rbx),%xmm1
lea    -0x8(,%rax,8),%rax
ff
xor    %ecx,%ecx
nopl   (%rax)
movsd  0x8(%r14,%rcx,1),%xmm2
mulsd  0x8(%rbp,%rcx,1),%xmm0
subsd  %xmm0,%xmm2
movsd  0x8(%r12,%rcx,1),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%r15,%rcx,1)
movsd  0x8(%r13,%rcx,1),%xmm3
mulsd  0x8(%rbp,%rcx,1),%xmm1
subsd  %xmm1,%xmm3
divsd  %xmm2,%xmm3
movsd  %xmm3,0x8(%rbx,%rcx,1)
add    $0x8,%rcx
movapd %xmm3,%xmm1
cmp    %rcx,%rax
jne    1220 <solveTXeqB+0x100>
lea    -0x1(%rsi),%eax
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
add    $0xfffffffe,%esi
js     12eb <solveTXeqB+0x1cb>
mov    %esi,%eax
test   $0x1,%sil
jne    12a3 <solveTXeqB+0x183>
movsd  (%r15,%rax,8),%xmm0
mulsd  0x8(%rdx,%rax,8),%xmm0
movsd  (%rbx,%rax,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rax,8)
add    $0xffffffffffffffff,%rax
test   %esi,%esi
je     12eb <solveTXeqB+0x1cb>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
movsd  (%r15,%rax,8),%xmm1
mulsd  0x8(%rdx,%rax,8),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rax,8)
movsd  -0x8(%rbx,%rax,8),%xmm1
mulsd  -0x8(%r15,%rax,8),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,-0x8(%rdx,%rax,8)
add    $0xfffffffffffffffe,%rax
cmp    $0xffffffffffffffff,%rax
jne    12b0 <solveTXeqB+0x190>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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