#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 *, ...);
void itermsg(double tol, int maxit, int flag, int iter, double relres) {
  if (flag != 0) {
    printf("PCG stopped at iteration %d without converging to the desired "
           "tolerance %0.2g",
           iter, tol);
  }
  switch (flag) {
  case 0:
    if (iter == 0)
      printf(
          "The initial guess has relative residual %0.2g which is within\nthe "
          "desired tolerance %0.2g so PCG returned it without iterating.",
          relres, tol);
    else
      printf("PCG converged at iteration %d to a solution with relative "
             "residual %0.2g",
             iter, relres);
    break;
  case 1:
    printf("\nbecause the maximum number of iterations was reached.");
    break;
  case 2:
    printf("\nbecause the system involving the preconditioner was ill "
           "conditioned.");
    break;
  case 3:
    printf("\nbecause the method stagnated.");
    break;
  case 4:
    printf("\nbecause a scalar quantity became too small or too large to "
           "continue computing.");
    break;
  }
  if (flag != 0)
    printf("\nThe iterate returned (number %d) has relative residual %0.2g",
           iter, relres);
  printf("\n");
}


x86 assembly (clang, -O0):
<itermsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     114b <itermsg+0x3b>
mov    -0x14(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
lea    0xed0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x4,%rax
ja     11f9 <itermsg+0xe9>
mov    -0x28(%rbp),%rax
lea    0xe99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x14(%rbp)
jne    1197 <itermsg+0x87>
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    0xed7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11ad <itermsg+0x9d>
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xf3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11f9 <itermsg+0xe9>
lea    0xf72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <itermsg+0xe9>
lea    0xf96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <itermsg+0xe9>
lea    0xfc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <itermsg+0xe9>
lea    0xfd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     1219 <itermsg+0x109>
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0x1005(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x1035(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itermsg>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
movaps %xmm0,%xmm2
test   %esi,%esi
je     1176 <itermsg+0x56>
mov    %esi,%ebp
movsd  %xmm1,(%rsp)
lea    0xec6(%rip),%rdi
mov    %ebx,%esi
movaps %xmm2,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%ebp
cmp    $0x4,%ebp
jae    1166 <itermsg+0x46>
movslq %ebp,%rax
lea    0x10ec(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1096(%rip),%rdi
mov    %ebx,%esi
movsd  (%rsp),%xmm0
jmp    1186 <itermsg+0x66>
test   %ebx,%ebx
je     119d <itermsg+0x7d>
lea    0xf4d(%rip),%rdi
mov    %ebx,%esi
movaps %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>
lea    0xeaa(%rip),%rdi
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
jmp    118d <itermsg+0x6d>

LLVM IR (-O0):
@.str = [78 x i8] c"PCG stopped at iteration %d without converging to the desired tolerance %0.2g\00"
@.str.1 = [128 x i8] c"The initial guess has relative residual %0.2g which is within\0Athe desired tolerance %0.2g so PCG returned it without iterating.\00"
@.str.2 = [73 x i8] c"PCG converged at iteration %d to a solution with relative residual %0.2g\00"
@.str.3 = [55 x i8] c"\0Abecause the maximum number of iterations was reached.\00"
@.str.4 = [70 x i8] c"\0Abecause the system involving the preconditioner was ill conditioned.\00"
@.str.5 = [31 x i8] c"\0Abecause the method stagnated.\00"
@.str.6 = [80 x i8] c"\0Abecause a scalar quantity became too small or too large to continue computing.\00"
@.str.7 = [62 x i8] c"\0AThe iterate returned (number %d) has relative residual %0.2g\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @itermsg(double %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double %0, double* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double %4, double* %10
%11 = load i32, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %5
%14 = load i32, i32* %9
%15 = load double, double* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %14, double %15)
br label %17
17: ; preds = %13, %5
%18 = load i32, i32* %8
switch i32 %18, label %39 [
i32 0, label %19
i32 1, label %31
i32 2, label %33
i32 3, label %35
i32 4, label %37
]
19: ; preds = %17
%20 = load i32, i32* %9
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load double, double* %10
%24 = load double, double* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str.1, i64 0, i64 0), double %23, double %24)
br label %30
26: ; preds = %19
%27 = load i32, i32* %9
%28 = load double, double* %10
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i32 %27, double %28)
br label %30
30: ; preds = %26, %22
br label %39
31: ; preds = %17
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
br label %39
33: ; preds = %17
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0))
br label %39
35: ; preds = %17
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %39
37: ; preds = %17
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %17, %37, %35, %33, %31, %30
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* %9
%44 = load double, double* %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), i32 %43, double %44)
br label %46
46: ; preds = %42, %39
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [78 x i8] c"PCG stopped at iteration %d without converging to the desired tolerance %0.2g\00"
@.str.1 = [128 x i8] c"The initial guess has relative residual %0.2g which is within\0Athe desired tolerance %0.2g so PCG returned it without iterating.\00"
@.str.2 = [73 x i8] c"PCG converged at iteration %d to a solution with relative residual %0.2g\00"
@.str.3 = [55 x i8] c"\0Abecause the maximum number of iterations was reached.\00"
@.str.4 = [70 x i8] c"\0Abecause the system involving the preconditioner was ill conditioned.\00"
@.str.5 = [31 x i8] c"\0Abecause the method stagnated.\00"
@.str.6 = [80 x i8] c"\0Abecause a scalar quantity became too small or too large to continue computing.\00"
@.str.7 = [62 x i8] c"\0AThe iterate returned (number %d) has relative residual %0.2g\00"
@reltable.itermsg = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([55 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.itermsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([70 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.itermsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.itermsg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([80 x i8]* @.str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.itermsg to i64)) to i32)]
define void @itermsg(double %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = icmp eq i32 %2, 0
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0), i32 %3, double %0)
%9 = add i32 %2, -1
%10 = icmp ult i32 %9, 4
br i1 %10, label %17, label %22
11: ; preds = %5
%12 = icmp eq i32 %3, 0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @.str.1, i64 0, i64 0), double %4, double %0)
br label %24
15: ; preds = %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i32 %3, double %4)
br label %24
17: ; preds = %7
%18 = sext i32 %9 to i64
%19 = shl i64 %18, 2
%20 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.itermsg to i8*), i64 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %20)
br label %22
22: ; preds = %7, %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), i32 %3, double %4)
br label %24
24: ; preds = %15, %13, %22
%25 = tail call i32 @putchar(i32 10)
ret void
}