#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*/ daxpy_seq(int, double, double *, double *, int);
int /*<<< orphan*/ dcopy_seq(int, double *, double *);
int /*<<< orphan*/ dgemv_seq(int, int, double, double *, double *, double,
                             double *, int);
int /*<<< orphan*/ dnrm2_seq(int, double *, double *, int);
double __jaciter_kernel_sequential(double *A, double *b, double *R, double *C,
                                   double *Dinv, double *xk, double *xkp1,
                                   double *xconv, int n) {
  double e = 1.0;
  int i;
  dgemv_seq(n, n, 1.0, R, xk, 0.0, xkp1, 1);
  for (i = 0; i < n; i++) {
    xkp1[i] *= -Dinv[i];
    xkp1[i] += C[i];
  }
  dcopy_seq(n, xkp1, xk);
  dgemv_seq(n, n, 1.0, A, xk, 0.0, xconv, 1);
  daxpy_seq(n, -1.0, b, xconv, 1);
  dnrm2_seq(n, xconv, &e, 1);
  return e;
}


x86 assembly (clang, -O0):
<__jaciter_kernel_sequential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  0xe8d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x20(%rbp),%edi
mov    0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
movsd  0xe6e(%rip),%xmm0
xorps  %xmm1,%xmm1
mov    $0x1,%r9d
call   1060 <dgemv_seq@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1216 <__jaciter_kernel_sequential+0xd6>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a7 <__jaciter_kernel_sequential+0x67>
mov    0x20(%rbp),%edi
mov    0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <dcopy_seq@plt>
mov    0x20(%rbp),%edi
mov    0x20(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x18(%rbp),%r8
movsd  0xdc0(%rip),%xmm0
xorps  %xmm1,%xmm1
mov    $0x1,%r9d
call   1060 <dgemv_seq@plt>
mov    0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x18(%rbp),%rdx
movsd  0xda7(%rip),%xmm0
mov    $0x1,%ecx
call   1050 <daxpy_seq@plt>
mov    0x20(%rbp),%edi
mov    0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x1,%ecx
call   1030 <dnrm2_seq@plt>
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__jaciter_kernel_sequential>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
mov    0x60(%rsp),%ebp
mov    0x50(%rsp),%r15
movabs $0x3ff0000000000000,%rax
mov    %rax,0x8(%rsp)
movsd  0xe81(%rip),%xmm0
xorpd  %xmm1,%xmm1
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r9,%rcx
mov    %r15,%r8
mov    $0x1,%r9d
call   1060 <dgemv_seq@plt>
test   %ebp,%ebp
jle    135d <__jaciter_kernel_sequential+0x21d>
mov    %ebp,%eax
cmp    $0x1,%ebp
jne    1255 <__jaciter_kernel_sequential+0x115>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
test   $0x1,%al
je     11e0 <__jaciter_kernel_sequential+0xa0>
movsd  (%rbx,%rcx,8),%xmm0
xorpd  0xe4c(%rip),%xmm0
mulsd  (%r15,%rcx,8),%xmm0
movsd  %xmm0,(%r15,%rcx,8)
addsd  (%r14,%rcx,8),%xmm0
movsd  %xmm0,(%r15,%rcx,8)
or     $0x1,%rcx
add    %rax,%rdx
je     135d <__jaciter_kernel_sequential+0x21d>
movapd 0xe1f(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm1
xorpd  %xmm0,%xmm1
mulsd  (%r15,%rcx,8),%xmm1
movsd  %xmm1,(%r15,%rcx,8)
addsd  (%r14,%rcx,8),%xmm1
movsd  %xmm1,(%r15,%rcx,8)
movsd  0x8(%rbx,%rcx,8),%xmm1
xorpd  %xmm0,%xmm1
mulsd  0x8(%r15,%rcx,8),%xmm1
movsd  %xmm1,0x8(%r15,%rcx,8)
addsd  0x8(%r14,%rcx,8),%xmm1
movsd  %xmm1,0x8(%r15,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    1200 <__jaciter_kernel_sequential+0xc0>
jmp    135d <__jaciter_kernel_sequential+0x21d>
lea    (%r15,%rax,8),%rcx
lea    (%rbx,%rax,8),%rdx
cmp    %r15,%rdx
seta   %dil
lea    (%r14,%rax,8),%rdx
cmp    %rbx,%rcx
seta   %r8b
cmp    %r15,%rdx
seta   %dl
cmp    %r14,%rcx
seta   %sil
xor    %ecx,%ecx
test   %r8b,%dil
jne    11ad <__jaciter_kernel_sequential+0x6d>
and    %sil,%dl
jne    11ad <__jaciter_kernel_sequential+0x6d>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     13d8 <__jaciter_kernel_sequential+0x298>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
movapd 0xd53(%rip),%xmm0
nopl   (%rax)
movupd (%rbx,%rdx,8),%xmm1
xorpd  %xmm0,%xmm1
movupd (%r15,%rdx,8),%xmm2
mulpd  %xmm1,%xmm2
movupd 0x10(%r15,%rdx,8),%xmm1
movupd %xmm2,(%r15,%rdx,8)
movupd (%r14,%rdx,8),%xmm3
addpd  %xmm2,%xmm3
movupd %xmm3,(%r15,%rdx,8)
movupd 0x10(%rbx,%rdx,8),%xmm2
xorpd  %xmm0,%xmm2
mulpd  %xmm1,%xmm2
movupd %xmm2,0x10(%r15,%rdx,8)
movupd 0x10(%r14,%rdx,8),%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x10(%r15,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rdi
jne    12c0 <__jaciter_kernel_sequential+0x180>
test   $0x1,%sil
je     1354 <__jaciter_kernel_sequential+0x214>
movupd (%rbx,%rdx,8),%xmm0
xorpd  0xcdc(%rip),%xmm0
movupd (%r15,%rdx,8),%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%r15,%rdx,8)
movupd (%r14,%rdx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm0,(%r15,%rdx,8)
cmp    %rax,%rcx
jne    11ad <__jaciter_kernel_sequential+0x6d>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r13,%rdx
call   1040 <dcopy_seq@plt>
movsd  0xc8e(%rip),%xmm0
xorpd  %xmm1,%xmm1
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x58(%rsp),%rbx
mov    %rbx,%r8
mov    $0x1,%r9d
call   1060 <dgemv_seq@plt>
movsd  0xc6d(%rip),%xmm0
mov    %ebp,%edi
mov    0x10(%rsp),%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1050 <daxpy_seq@plt>
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%ecx
call   1030 <dnrm2_seq@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    1327 <__jaciter_kernel_sequential+0x1e7>
jmp    1354 <__jaciter_kernel_sequential+0x214>

LLVM IR (-O0):
define double @__jaciter_kernel_sequential(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32 %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i32
%19 = alloca double
%20 = alloca i32
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store double* %4, double** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store i32 %8, i32* %18
store double 1.000000e+00, double* %19
%21 = load i32, i32* %18
%22 = load i32, i32* %18
%23 = load double*, double** %12
%24 = load double*, double** %15
%25 = load double*, double** %16
%26 = call i32 @dgemv_seq(i32 %21, i32 %22, double 1.000000e+00, double* %23, double* %24, double 0.000000e+00, double* %25, i32 1)
store i32 0, i32* %20
br label %27
27: ; preds = %55, %9
%28 = load i32, i32* %20
%29 = load i32, i32* %18
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %58
31: ; preds = %27
%32 = load double*, double** %14
%33 = load i32, i32* %20
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = fneg double %36
%38 = load double*, double** %16
%39 = load i32, i32* %20
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = fmul double %42, %37
store double %43, double* %41
%44 = load double*, double** %13
%45 = load i32, i32* %20
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %16
%50 = load i32, i32* %20
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = fadd double %53, %48
store double %54, double* %52
br label %55
55: ; preds = %31
%56 = load i32, i32* %20
%57 = add nsw i32 %56, 1
store i32 %57, i32* %20
br label %27
58: ; preds = %27
%59 = load i32, i32* %18
%60 = load double*, double** %16
%61 = load double*, double** %15
%62 = call i32 @dcopy_seq(i32 %59, double* %60, double* %61)
%63 = load i32, i32* %18
%64 = load i32, i32* %18
%65 = load double*, double** %10
%66 = load double*, double** %15
%67 = load double*, double** %17
%68 = call i32 @dgemv_seq(i32 %63, i32 %64, double 1.000000e+00, double* %65, double* %66, double 0.000000e+00, double* %67, i32 1)
%69 = load i32, i32* %18
%70 = load double*, double** %11
%71 = load double*, double** %17
%72 = call i32 @daxpy_seq(i32 %69, double -1.000000e+00, double* %70, double* %71, i32 1)
%73 = load i32, i32* %18
%74 = load double*, double** %17
%75 = call i32 @dnrm2_seq(i32 %73, double* %74, double* %19, i32 1)
%76 = load double, double* %19
ret double %76
}

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