#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 relax_dot(double *, int, double *, int, int);
int relax_kacz(double *A, int m, int n, int stride, double *b, double *x0,
               int rowi, double lambda) {
  double rowres, fact;
  int ioff, j;
  if (rowi < 0 || rowi >= m)
    return -1;
  ioff = rowi * stride;
  rowres = relax_dot(A + ioff, 1, x0, 1, n) - b[rowi];
  fact = lambda * rowres / relax_dot(A + ioff, 1, A + ioff, 1, n);
  for (j = 0; j < n; j++)
    x0[j] -= fact * A[ioff + j];
  return 0;
}


x86 assembly (clang, -O0):
<relax_kacz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x0,0x10(%rbp)
jl     114b <relax_kacz+0x3b>
mov    0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1157 <relax_kacz+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <relax_kacz+0x144>
mov    0x10(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%r8d
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <relax_dot@plt>
mov    -0x28(%rbp),%rax
movslq 0x10(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%r8d
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <relax_dot@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124d <relax_kacz+0x13d>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x30(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11eb <relax_kacz+0xdb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<relax_kacz>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x70(%rsp),%r13d
mov    $0xffffffff,%eax
test   %r13d,%r13d
js     1362 <relax_kacz+0x252>
cmp    %esi,%r13d
jge    1362 <relax_kacz+0x252>
mov    %r9,%rbx
mov    %r8,%r12
mov    %edx,%ebp
movsd  %xmm0,0x18(%rsp)
imul   %r13d,%ecx
movslq %ecx,%rax
mov    %rax,%r14
mov    %rdi,0x8(%rsp)
lea    (%rdi,%rax,8),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r9,%rdx
mov    $0x1,%ecx
mov    %ebp,%r8d
call   1030 <relax_dot@plt>
movaps %xmm0,0x20(%rsp)
mov    %r13d,%eax
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
mov    %ebp,%r8d
call   1030 <relax_dot@plt>
test   %ebp,%ebp
jle    11d4 <relax_kacz+0xc4>
movapd 0x20(%rsp),%xmm6
subsd  0x10(%rsp),%xmm6
xorpd  0xe49(%rip),%xmm6
mulsd  0x18(%rsp),%xmm6
divsd  %xmm0,%xmm6
mov    %ebp,%ecx
cmp    $0x4,%ebp
jae    11db <relax_kacz+0xcb>
xor    %edx,%edx
mov    0x8(%rsp),%r9
jmp    12f4 <relax_kacz+0x1e4>
xor    %eax,%eax
jmp    1362 <relax_kacz+0x252>
lea    (%r14,%rcx,1),%rax
mov    0x8(%rsp),%r9
lea    (%r9,%rax,8),%rax
cmp    %rbx,%rax
jbe    11fd <relax_kacz+0xed>
lea    (%rbx,%rcx,8),%rax
cmp    %rax,%r15
jae    11fd <relax_kacz+0xed>
xor    %edx,%edx
jmp    12f4 <relax_kacz+0x1e4>
mov    %ecx,%edx
and    $0xfffffffc,%edx
movapd %xmm6,%xmm0
unpcklpd %xmm6,%xmm0
lea    -0x4(%rdx),%rax
mov    %rax,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
test   %rax,%rax
je     1371 <relax_kacz+0x261>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
lea    (%r9,%r14,8),%rbp
add    $0x30,%rbp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movupd -0x30(%rbp,%rax,8),%xmm1
movupd -0x20(%rbp,%rax,8),%xmm2
mulpd  %xmm0,%xmm1
movupd (%rbx,%rax,8),%xmm3
addpd  %xmm1,%xmm3
movupd 0x10(%rbx,%rax,8),%xmm1
movupd 0x20(%rbx,%rax,8),%xmm4
movupd 0x30(%rbx,%rax,8),%xmm5
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm3,(%rbx,%rax,8)
movupd %xmm2,0x10(%rbx,%rax,8)
movupd -0x10(%rbp,%rax,8),%xmm1
movupd 0x0(%rbp,%rax,8),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm4,%xmm1
mulpd  %xmm0,%xmm2
addpd  %xmm5,%xmm2
movupd %xmm1,0x20(%rbx,%rax,8)
movupd %xmm2,0x30(%rbx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rdi
jne    1240 <relax_kacz+0x130>
test   $0x1,%sil
je     12ed <relax_kacz+0x1dd>
lea    (%rax,%r14,1),%rsi
movupd (%r9,%rsi,8),%xmm1
movupd 0x10(%r9,%rsi,8),%xmm2
movupd (%rbx,%rax,8),%xmm3
movupd 0x10(%rbx,%rax,8),%xmm4
mulpd  %xmm0,%xmm1
addpd  %xmm3,%xmm1
mulpd  %xmm0,%xmm2
addpd  %xmm4,%xmm2
movupd %xmm1,(%rbx,%rax,8)
movupd %xmm2,0x10(%rbx,%rax,8)
xor    %eax,%eax
cmp    %rcx,%rdx
je     1362 <relax_kacz+0x252>
mov    %rdx,%rsi
not    %rsi
test   $0x1,%cl
je     131b <relax_kacz+0x20b>
lea    (%rdx,%r14,1),%rax
movsd  (%r9,%rax,8),%xmm0
mulsd  %xmm6,%xmm0
addsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
or     $0x1,%rdx
xor    %eax,%eax
add    %rcx,%rsi
je     1362 <relax_kacz+0x252>
lea    (%r9,%r14,8),%rsi
add    $0x8,%rsi
nopw   0x0(%rax,%rax,1)
movsd  -0x8(%rsi,%rdx,8),%xmm0
mulsd  %xmm6,%xmm0
addsd  (%rbx,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
movsd  (%rsi,%rdx,8),%xmm0
mulsd  %xmm6,%xmm0
addsd  0x8(%rbx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rdx,8)
add    $0x2,%rdx
cmp    %rdx,%rcx
jne    1330 <relax_kacz+0x220>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
test   $0x1,%sil
jne    12b6 <relax_kacz+0x1a6>
jmp    12ed <relax_kacz+0x1dd>

LLVM IR (-O0):
define i32 @relax_kacz(double* %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, i32 %6, double %7) {
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca i32
%21 = alloca i32
store double* %0, double** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store double* %4, double** %14
store double* %5, double** %15
store i32 %6, i32* %16
store double %7, double* %17
%22 = load i32, i32* %16
%23 = icmp slt i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %8
%25 = load i32, i32* %16
%26 = load i32, i32* %11
%27 = icmp sge i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24, %8
store i32 -1, i32* %9
br label %84
29: ; preds = %24
%30 = load i32, i32* %16
%31 = load i32, i32* %13
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %20
%33 = load double*, double** %10
%34 = load i32, i32* %20
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double*, double** %15
%38 = load i32, i32* %12
%39 = call double @relax_dot(double* %36, i32 1, double* %37, i32 1, i32 %38)
%40 = load double*, double** %14
%41 = load i32, i32* %16
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fsub double %39, %44
store double %45, double* %18
%46 = load double, double* %17
%47 = load double, double* %18
%48 = fmul double %46, %47
%49 = load double*, double** %10
%50 = load i32, i32* %20
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double*, double** %10
%54 = load i32, i32* %20
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load i32, i32* %12
%58 = call double @relax_dot(double* %52, i32 1, double* %56, i32 1, i32 %57)
%59 = fdiv double %48, %58
store double %59, double* %19
store i32 0, i32* %21
br label %60
60: ; preds = %80, %29
%61 = load i32, i32* %21
%62 = load i32, i32* %12
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %83
64: ; preds = %60
%65 = load double, double* %19
%66 = load double*, double** %10
%67 = load i32, i32* %20
%68 = load i32, i32* %21
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %66, i64 %70
%72 = load double, double* %71
%73 = load double*, double** %15
%74 = load i32, i32* %21
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fneg double %65
%79 = call double @llvm.fmuladd.f64(double %78, double %72, double %77)
store double %79, double* %76
br label %80
80: ; preds = %64
%81 = load i32, i32* %21
%82 = add nsw i32 %81, 1
store i32 %82, i32* %21
br label %60
83: ; preds = %60
store i32 0, i32* %9
br label %84
84: ; preds = %83, %28
%85 = load i32, i32* %9
ret i32 %85
}

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