#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 fabs(double);
int /*<<< orphan*/ relax_ab(double *, int, int, int, double *, double *);
double relax_maxres(double *A, int m, int n, int stride, double *x, double *b,
                    double *tmp) {
  double res, maxres;
  int i;
  relax_ab(A, m, n, stride, x, tmp);
  tmp[0] = b[0] - tmp[0];
  maxres = fabs(tmp[0]);
  for (i = 1; i < m; i++) {
    tmp[i] = b[i] - tmp[i];
    res = fabs(tmp[i]);
    maxres = maxres > res ? maxres : res;
  }
  return maxres;
}


x86 assembly (clang, -O0):
<relax_maxres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    0x10(%rbp),%r9
call   1030 <relax_ab@plt>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x10(%rbp),%rax
subsd  (%rax),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe8e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1213 <relax_maxres+0x103>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe37(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11f1 <relax_maxres+0xe1>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11fb <relax_maxres+0xeb>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1182 <relax_maxres+0x72>
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<relax_maxres>:
push   %rbp
push   %r14
push   %rbx
mov    %r9,%r14
mov    %esi,%ebp
mov    0x20(%rsp),%rbx
mov    %rbx,%r9
call   1030 <relax_ab@plt>
movsd  (%r14),%xmm0
subsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
andpd  0xec5(%rip),%xmm0
cmp    $0x2,%ebp
jl     11d5 <relax_maxres+0xc5>
mov    %ebp,%eax
add    $0xffffffffffffffff,%rax
cmp    $0x2,%ebp
jne    1156 <relax_maxres+0x46>
mov    $0x1,%ecx
jmp    11b5 <relax_maxres+0xa5>
mov    %rax,%rdx
and    $0xfffffffffffffffe,%rdx
neg    %rdx
mov    $0x1,%ecx
movapd 0xe93(%rip),%xmm1
nopl   (%rax)
movsd  (%r14,%rcx,8),%xmm2
subsd  (%rbx,%rcx,8),%xmm2
movsd  %xmm2,(%rbx,%rcx,8)
andpd  %xmm1,%xmm2
maxsd  %xmm2,%xmm0
movsd  0x8(%r14,%rcx,8),%xmm2
subsd  0x8(%rbx,%rcx,8),%xmm2
movsd  %xmm2,0x8(%rbx,%rcx,8)
andpd  %xmm1,%xmm2
maxsd  %xmm2,%xmm0
lea    (%rdx,%rcx,1),%rsi
add    $0x2,%rsi
add    $0x2,%rcx
cmp    $0x1,%rsi
jne    1170 <relax_maxres+0x60>
test   $0x1,%al
je     11d5 <relax_maxres+0xc5>
movsd  (%r14,%rcx,8),%xmm1
subsd  (%rbx,%rcx,8),%xmm1
movsd  %xmm1,(%rbx,%rcx,8)
andpd  0xe2f(%rip),%xmm1
maxsd  %xmm1,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define double @relax_maxres(double* %0, i32 %1, i32 %2, i32 %3, double* %4, double* nocapture %5, double* %6) {
%8 = tail call i32 @relax_ab(double* %0, i32 %1, i32 %2, i32 %3, double* %4, double* %6)
%9 = load double, double* %5
%10 = load double, double* %6
%11 = fsub double %9, %10
store double %11, double* %6
%12 = tail call double @llvm.fabs.f64(double %11)
%13 = icmp sgt i32 %1, 1
br i1 %13, label %14, label %59
14: ; preds = %7
%15 = zext i32 %1 to i64
%16 = add nsw i64 %15, -1
%17 = and i64 %16, 1
%18 = icmp eq i32 %1, 2
br i1 %18, label %45, label %19
19: ; preds = %14
%20 = and i64 %16, -2
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 1, %19 ], [ %42, %21 ]
%23 = phi double [ %12, %19 ], [ %41, %21 ]
%24 = phi i64 [ 0, %19 ], [ %43, %21 ]
%25 = getelementptr inbounds double, double* %5, i64 %22
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %6, i64 %22
%28 = load double, double* %27
%29 = fsub double %26, %28
store double %29, double* %27
%30 = tail call double @llvm.fabs.f64(double %29)
%31 = fcmp ogt double %23, %30
%32 = select i1 %31, double %23, double %30
%33 = add nuw nsw i64 %22, 1
%34 = getelementptr inbounds double, double* %5, i64 %33
%35 = load double, double* %34
%36 = getelementptr inbounds double, double* %6, i64 %33
%37 = load double, double* %36
%38 = fsub double %35, %37
store double %38, double* %36
%39 = tail call double @llvm.fabs.f64(double %38)
%40 = fcmp ogt double %32, %39
%41 = select i1 %40, double %32, double %39
%42 = add nuw nsw i64 %22, 2
%43 = add i64 %24, 2
%44 = icmp eq i64 %43, %20
br i1 %44, label %45, label %21
45: ; preds = %21, %14
%46 = phi double [ undef, %14 ], [ %41, %21 ]
%47 = phi i64 [ 1, %14 ], [ %42, %21 ]
%48 = phi double [ %12, %14 ], [ %41, %21 ]
%49 = icmp eq i64 %17, 0
br i1 %49, label %59, label %50
50: ; preds = %45
%51 = getelementptr inbounds double, double* %5, i64 %47
%52 = load double, double* %51
%53 = getelementptr inbounds double, double* %6, i64 %47
%54 = load double, double* %53
%55 = fsub double %52, %54
store double %55, double* %53
%56 = tail call double @llvm.fabs.f64(double %55)
%57 = fcmp ogt double %48, %56
%58 = select i1 %57, double %48, double %56
br label %59
59: ; preds = %50, %45, %7
%60 = phi double [ %12, %7 ], [ %46, %45 ], [ %58, %50 ]
ret double %60
}