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


x86 assembly (clang, -O0):
<mult_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)
mov    -0x24(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%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   1060 <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)
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe08(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x40(%rbp),%xmm0
lea    0xe33(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x28(%rbp)
jge    1223 <mult_solve+0xd3>
jmp    119d <mult_solve+0x4d>
movsd  0xddd(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1253 <mult_solve+0x103>
cmpl   $0x0,-0x24(%rbp)
jne    1253 <mult_solve+0x103>
mov    -0x44(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1070 <write_iter@plt>
jmp    134a <mult_solve+0x1fa>
movsd  0xdad(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12b7 <mult_solve+0x167>
mov    -0x44(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1070 <write_iter@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <ctof@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%esi
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133b <mult_solve+0x1eb>
movsd  0xd41(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1336 <mult_solve+0x1e6>
cmpl   $0x3,-0x24(%rbp)
jge    1336 <mult_solve+0x1e6>
mov    -0x44(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1070 <write_iter@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <ftoc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%esi
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133b <mult_solve+0x1eb>
jmp    1340 <mult_solve+0x1f0>
jmp    1345 <mult_solve+0x1f5>
jmp    119d <mult_solve+0x4d>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_solve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    0x10(%rsp),%rbp
mov    0x8(%rsp),%r15
lea    0xe85(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm1,%xmm1
xor    %esi,%esi
mov    %ebx,(%rsp)
nopl   (%rax)
mov    %esi,%r14d
cmp    $0x4,%esi
mov    $0x3,%ecx
cmovge %esi,%ecx
lea    0x1(%rcx),%eax
mov    %eax,0x4(%rsp)
neg    %ecx
mov    %rcx,0x30(%rsp)
add    $0x1,%r14d
mov    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x40(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    0x20(%rsp),%rcx
mov    %r12d,%r8d
call   1060 <relax@plt>
movsd  %xmm0,0x38(%rsp)
add    $0x1,%r13d
lea    0xe24(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x40(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  0xde4(%rip),%xmm1
movsd  %xmm1,0x28(%rsp)
cvttsd2si %xmm1,%esi
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x38(%rsp),%xmm1
mov    0x30(%rsp),%rax
add    %r14d,%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
mov    %ecx,%r14d
cmp    $0x2,%eax
jne    11d0 <mult_solve+0x80>
mov    %r12d,%edx
movsd  0x28(%rsp),%xmm2
test   %r12d,%r12d
jne    1277 <mult_solve+0x127>
movsd  0xd9b(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     12f7 <mult_solve+0x1a7>
movsd  0xd89(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    (%rsp),%ebx
mov    0x4(%rsp),%esi
ja     12d0 <mult_solve+0x180>
cmp    $0x2,%edx
jg     11a0 <mult_solve+0x50>
ucomisd %xmm2,%xmm1
jb     11a0 <mult_solve+0x50>
mov    %ebx,%edi
mov    %edx,%r12d
call   1070 <write_iter@plt>
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    %r12d,%r8d
call   1040 <ftoc@plt>
mov    $0x1,%eax
jmp    12ec <mult_solve+0x19c>
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %edx,%r12d
call   1070 <write_iter@plt>
mov    0x8(%rsp),%rdi
mov    %r12d,%esi
call   1050 <ctof@plt>
mov    $0xffffffff,%eax
add    $0x1,%ebx
add    %eax,%r12d
jmp    1184 <mult_solve+0x34>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
xor    %edx,%edx
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <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 @mult_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 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %97, %40, %4
%18 = load double, double* %12
store double %18, double* %13
%19 = load double*, double** %5
%20 = load double*, double** %6
%21 = load double*, double** %7
%22 = load double*, double** %8
%23 = load i32, i32* %9
%24 = call double @relax(double* %19, double* %20, double* %21, double* %22, i32 %23)
store double %24, double* %12
%25 = load i32, i32* %10
%26 = add nsw i32 %25, 1
store i32 %26, i32* %10
%27 = load i32, i32* %11
%28 = add nsw i32 %27, 1
store i32 %28, i32* %11
%29 = load i32, i32* %11
%30 = load i32, i32* %10
%31 = load double, double* %12
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30, double %31)
%33 = load double, double* %13
%34 = fmul double %33, 5.000000e-01
%35 = fptosi double %34 to i32
%36 = load double, double* %13
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %35, double %36)
%38 = load i32, i32* %10
%39 = icmp slt i32 %38, 4
br i1 %39, label %40, label %41
40: ; preds = %17
br label %17
41: ; preds = %17
%42 = load double, double* %12
%43 = fcmp olt double %42, 0x3EB0C6F7A0B5ED8D
br i1 %43, label %44, label %52
44: ; preds = %41
%45 = load i32, i32* %9
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* %14
%49 = load i32, i32* %10
%50 = load i32, i32* %9
%51 = call i32 @write_iter(i32 %48, i32 %49, i32 %50)
br label %98
52: ; preds = %44, %41
%53 = load double, double* %12
%54 = fcmp olt double %53, 0x3EB0C6F7A0B5ED8D
br i1 %54, label %55, label %69
55: ; preds = %52
%56 = load i32, i32* %14
%57 = load i32, i32* %10
%58 = load i32, i32* %9
%59 = call i32 @write_iter(i32 %56, i32 %57, i32 %58)
%60 = load i32, i32* %14
%61 = add nsw i32 %60, 1
store i32 %61, i32* %14
%62 = load double*, double** %5
%63 = load i32, i32* %9
%64 = call i32 @ctof(double* %62, i32 %63)
%65 = load i32, i32* %9
%66 = add nsw i32 %65, -1
store i32 %66, i32* %9
store i32 0, i32* %10
store double 0.000000e+00, double* %12
%67 = load i32, i32* %9
%68 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %67)
br label %95
69: ; preds = %52
%70 = load double, double* %13
%71 = fmul double %70, 5.000000e-01
%72 = load double, double* %12
%73 = fcmp ole double %71, %72
br i1 %73, label %74, label %94
74: ; preds = %69
%75 = load i32, i32* %9
%76 = icmp slt i32 %75, 3
br i1 %76, label %77, label %94
77: ; preds = %74
%78 = load i32, i32* %14
%79 = load i32, i32* %10
%80 = load i32, i32* %9
%81 = call i32 @write_iter(i32 %78, i32 %79, i32 %80)
%82 = load i32, i32* %14
%83 = add nsw i32 %82, 1
store i32 %83, i32* %14
%84 = load double*, double** %5
%85 = load double*, double** %6
%86 = load double*, double** %7
%87 = load double*, double** %8
%88 = load i32, i32* %9
%89 = call i32 @ftoc(double* %84, double* %85, double* %86, double* %87, i32 %88)
%90 = load i32, i32* %9
%91 = add nsw i32 %90, 1
store i32 %91, i32* %9
store i32 0, i32* %10
store double 0.000000e+00, double* %12
%92 = load i32, i32* %9
%93 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %77, %74, %69
br label %95
95: ; preds = %94, %55
br label %96
96: ; preds = %95
br label %97
97: ; preds = %96
br label %17
98: ; preds = %47
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 @mult_solve(double* %0, double* %1, double* %2, double* %3) {
br label %5
5: ; preds = %4, %45
%6 = phi i32 [ %48, %45 ], [ 0, %4 ]
%7 = phi i32 [ %24, %45 ], [ 0, %4 ]
%8 = phi i32 [ %47, %45 ], [ 0, %4 ]
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %6)
%10 = icmp eq i32 %6, 0
%11 = icmp slt i32 %6, 3
br label %12
12: ; preds = %5, %39
%13 = phi i32 [ %17, %39 ], [ 0, %5 ]
%14 = phi i32 [ %24, %39 ], [ %7, %5 ]
%15 = phi double [ %22, %39 ], [ 0.000000e+00, %5 ]
%16 = call i32 @llvm.smax.i32(i32 %13, i32 3)
%17 = add nuw i32 %16, 1
br label %18
18: ; preds = %12, %18
%19 = phi i32 [ %23, %18 ], [ %13, %12 ]
%20 = phi i32 [ %24, %18 ], [ %14, %12 ]
%21 = phi double [ %22, %18 ], [ %15, %12 ]
%22 = tail call double @relax(double* %0, double* %1, double* %2, double* %3, i32 %6)
%23 = add i32 %19, 1
%24 = add nsw i32 %20, 1
%25 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %23, double %22)
%26 = fmul double %21, 5.000000e-01
%27 = fptosi double %26 to i32
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %27, double %21)
%29 = icmp eq i32 %19, %16
br i1 %29, label %30, label %18
30: ; preds = %18
%31 = fcmp olt double %22, 0x3EB0C6F7A0B5ED8D
%32 = and i1 %10, %31
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @write_iter(i32 %8, i32 %17, i32 0)
ret void
35: ; preds = %30
br i1 %31, label %36, label %39
36: ; preds = %35
%37 = tail call i32 @write_iter(i32 %8, i32 %17, i32 %6)
%38 = tail call i32 @ctof(double* %0, i32 %6)
br label %45
39: ; preds = %35
%40 = fcmp ole double %26, %22
%41 = and i1 %11, %40
br i1 %41, label %42, label %12
42: ; preds = %39
%43 = tail call i32 @write_iter(i32 %8, i32 %17, i32 %6)
%44 = tail call i32 @ftoc(double* %0, double* %1, double* %2, double* %3, i32 %6)
br label %45
45: ; preds = %36, %42
%46 = phi i32 [ -1, %36 ], [ 1, %42 ]
%47 = add nuw nsw i32 %8, 1
%48 = add nsw i32 %6, %46
br label %5
}