#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*/ printf(char *, double, ...);
double relax(double *, double *, double *, double *, int);
int /*<<< orphan*/ write_iter(int, int, int);
void uni_solve(double *y, double *f, double *a_x, double *a_y) {
  int mesh_tracker = 0;
  int iter = 0;
  int tot_iter = 0;
  double error = 0.0, old_error;
  int count = 0;
  printf("At the level=%d\n", mesh_tracker);
  for (;;) {
    old_error = error;
    error = relax(y, f, a_x, a_y, mesh_tracker);
    iter++;
    tot_iter++;
    printf("tot_iter=%d\titer=%d\terror=%lf\n", tot_iter, iter, error);
    printf("ftoc cond=%lf\told_err=%lf\n", old_error * 0.5, old_error);
    if (iter < 4) {
      continue;
    } else if (error < 1e-6) {
      write_iter(count, iter, mesh_tracker);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<uni_solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <relax@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
mov    -0x28(%rbp),%esi
movsd  -0x38(%rbp),%xmm1
lea    0xe54(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0xe24(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xe53(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x28(%rbp)
jge    1203 <uni_solve+0xd3>
jmp    117f <uni_solve+0x4f>
movsd  0xdfd(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1229 <uni_solve+0xf9>
mov    -0x44(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <write_iter@plt>
jmp    1233 <uni_solve+0x103>
jmp    122e <uni_solve+0xfe>
jmp    117f <uni_solve+0x4f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uni_solve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
xorpd  %xmm0,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xorpd  %xmm0,%xmm0
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%ebp
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <relax@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rbp),%r13d
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
lea    0xe77(%rip),%rdi
mov    %r13d,%esi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0xe3a(%rip),%xmm0
lea    0xe73(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
cmp    $0x3,%ebp
jb     1170 <uni_solve+0x40>
movsd  0xe21(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1170 <uni_solve+0x40>
xor    %edi,%edi
mov    %r13d,%esi
xor    %edx,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <write_iter@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"At the level=%d\0A\00"
@.str.1 = [31 x i8] c"tot_iter=%d\09iter=%d\09error=%lf\0A\00"
@.str.2 = [27 x i8] c"ftoc cond=%lf\09old_err=%lf\0A\00"
define void @uni_solve(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store double 0.000000e+00, double* %12
store i32 0, i32* %14
%15 = load i32, i32* %9
%16 = sitofp i32 %15 to double
%17 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %16)
br label %18
18: ; preds = %51, %41, %4
%19 = load double, double* %12
store double %19, double* %13
%20 = load double*, double** %5
%21 = load double*, double** %6
%22 = load double*, double** %7
%23 = load double*, double** %8
%24 = load i32, i32* %9
%25 = call double @relax(double* %20, double* %21, double* %22, double* %23, i32 %24)
store double %25, double* %12
%26 = load i32, i32* %10
%27 = add nsw i32 %26, 1
store i32 %27, i32* %10
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
%30 = load i32, i32* %11
%31 = sitofp i32 %30 to double
%32 = load i32, i32* %10
%33 = load double, double* %12
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), double %31, i32 %32, double %33)
%35 = load double, double* %13
%36 = fmul double %35, 5.000000e-01
%37 = load double, double* %13
%38 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %36, double %37)
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %42
41: ; preds = %18
br label %18
42: ; preds = %18
%43 = load double, double* %12
%44 = fcmp olt double %43, 0x3EB0C6F7A0B5ED8D
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* %14
%47 = load i32, i32* %10
%48 = load i32, i32* %9
%49 = call i32 @write_iter(i32 %46, i32 %47, i32 %48)
br label %52
50: ; preds = %42
br label %51
51: ; preds = %50
br label %18
52: ; preds = %45
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"At the level=%d\0A\00"
@.str.1 = [31 x i8] c"tot_iter=%d\09iter=%d\09error=%lf\0A\00"
@.str.2 = [27 x i8] c"ftoc cond=%lf\09old_err=%lf\0A\00"
define void @uni_solve(double* %0, double* %1, double* %2, double* %3) {
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double 0.000000e+00)
br label %6
6: ; preds = %6, %4
%7 = phi double [ 0.000000e+00, %4 ], [ %9, %6 ]
%8 = phi i32 [ 0, %4 ], [ %10, %6 ]
%9 = tail call double @relax(double* %0, double* %1, double* %2, double* %3, i32 0)
%10 = add nuw nsw i32 %8, 1
%11 = sitofp i32 %10 to double
%12 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), double %11, i32 %10, double %9)
%13 = fmul double %7, 5.000000e-01
%14 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %13, double %7)
%15 = icmp ugt i32 %8, 2
%16 = fcmp olt double %9, 0x3EB0C6F7A0B5ED8D
%17 = and i1 %15, %16
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = tail call i32 @write_iter(i32 0, i32 %10, i32 0)
ret void
}