#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 *, ...);
int quaddobl_scale_system(int, double *);
int syscon_number_of_quaddobl_polynomials(int *);
int syscon_read_quaddobl_system();
int syscon_write_quaddobl_system();
int quaddobl_scaler(void) {
  int fail, dim, i;
  fail = syscon_read_quaddobl_system();
  if (fail == 0) {
    printf("\nThe system in the container : \n");
    fail = syscon_write_quaddobl_system();
    fail = syscon_number_of_quaddobl_polynomials(&dim);
    if (fail == 0) {
      double c[16 * dim + 8];
      fail = quaddobl_scale_system(2, c);
      printf("The estimated inverse condition number : %.3e\n", c[16 * dim]);
      printf("The scaling coefficients : \n");
      for (i = 0; i < 16 * dim; i = i + 4)
        printf("%2d : %.15e %.15e %.15e %.15e  %.15e %.15e %.15e %.15e\n",
               i / 8, c[i], c[i + 1], c[i + 2], c[i + 3], c[i + 4], c[i + 5],
               c[i + 6], c[i + 7]);
      printf("\nThe system in the container : \n");
      fail = syscon_write_quaddobl_system();
    }
  }
  return fail;
}


x86 assembly (clang, -O0):
<quaddobl_scaler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <syscon_read_quaddobl_system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12d3 <quaddobl_scaler+0x183>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <syscon_write_quaddobl_system@plt>
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <syscon_number_of_quaddobl_polynomials@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    12ce <quaddobl_scaler+0x17e>
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
or     $0x8,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
shl    $0x3,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1070 <quaddobl_scale_system@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,-0x4(%rbp)
mov    -0x8(%rbp),%ecx
shl    $0x4,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x4,%ecx
cmp    %ecx,%eax
jge    12af <quaddobl_scaler+0x15f>
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0xc(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm4
mov    -0xc(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm5
mov    -0xc(%rbp),%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm6
mov    -0xc(%rbp),%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm7
lea    0xdd3(%rip),%rdi
mov    $0x8,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1206 <quaddobl_scaler+0xb6>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <syscon_write_quaddobl_system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    12d3 <quaddobl_scaler+0x183>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quaddobl_scaler>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <syscon_read_quaddobl_system@plt>
test   %eax,%eax
jne    1268 <quaddobl_scaler+0x108>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <syscon_write_quaddobl_system@plt>
lea    -0x24(%rbp),%rdi
call   1060 <syscon_number_of_quaddobl_polynomials@plt>
test   %eax,%eax
jne    1268 <quaddobl_scaler+0x108>
mov    %rsp,%r15
mov    -0x24(%rbp),%eax
shl    $0x4,%eax
or     $0x8,%eax
mov    %rsp,%rbx
shl    $0x3,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    $0x2,%edi
mov    %rbx,%rsi
call   1080 <quaddobl_scale_system@plt>
movslq -0x24(%rbp),%rax
shl    $0x7,%rax
movsd  (%rax,%rbx,1),%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x24(%rbp)
jle    1252 <quaddobl_scaler+0xf2>
xor    %eax,%eax
lea    0xe31(%rip),%r14
xchg   %ax,%ax
mov    %eax,%esi
shr    $0x3,%esi
movsd  (%rbx,%rax,8),%xmm0
movsd  0x8(%rbx,%rax,8),%xmm1
movsd  0x10(%rbx,%rax,8),%xmm2
movsd  0x18(%rbx,%rax,8),%xmm3
lea    0x4(%rax),%r12
movsd  0x20(%rbx,%rax,8),%xmm4
movsd  0x28(%rbx,%rax,8),%xmm5
movsd  0x30(%rbx,%rax,8),%xmm6
movsd  0x38(%rbx,%rax,8),%xmm7
mov    %r14,%rdi
mov    $0x8,%al
call   1050 <printf@plt>
movslq -0x24(%rbp),%rcx
shl    $0x4,%rcx
mov    %r12,%rax
cmp    %rcx,%r12
jl     1200 <quaddobl_scaler+0xa0>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <syscon_write_quaddobl_system@plt>
mov    %r15,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0AThe system in the container : \0A\00"
@.str.1 = [47 x i8] c"The estimated inverse condition number : %.3e\0A\00"
@.str.2 = [29 x i8] c"The scaling coefficients : \0A\00"
@.str.3 = [56 x i8] c"%2d : %.15e %.15e %.15e %.15e %.15e %.15e %.15e %.15e\0A\00"
define i32 @quaddobl_scaler() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = call i32 (...) @syscon_read_quaddobl_system()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %86
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (...) @syscon_write_quaddobl_system()
store i32 %11, i32* %1
%12 = call i32 @syscon_number_of_quaddobl_polynomials(i32* %2)
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %85
15: ; preds = %9
%16 = load i32, i32* %2
%17 = mul nsw i32 16, %16
%18 = add nsw i32 %17, 8
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %4
%21 = alloca double, i64 %19
store i64 %19, i64* %5
%22 = call i32 @quaddobl_scale_system(i32 2, double* %21)
store i32 %22, i32* %1
%23 = load i32, i32* %2
%24 = mul nsw i32 16, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %21, i64 %25
%27 = load double, double* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %78, %15
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = mul nsw i32 16, %32
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %81
35: ; preds = %30
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 8
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %21, i64 %39
%41 = load double, double* %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %21, i64 %44
%46 = load double, double* %45
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %21, i64 %49
%51 = load double, double* %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %21, i64 %54
%56 = load double, double* %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %21, i64 %59
%61 = load double, double* %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %21, i64 %64
%66 = load double, double* %65
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %21, i64 %69
%71 = load double, double* %70
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %21, i64 %74
%76 = load double, double* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %37, double %41, double %46, double %51, double %56, double %61, double %66, double %71, double %76)
br label %78
78: ; preds = %35
%79 = load i32, i32* %3
%80 = add nsw i32 %79, 4
store i32 %80, i32* %3
br label %30
81: ; preds = %30
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%83 = call i32 (...) @syscon_write_quaddobl_system()
store i32 %83, i32* %1
%84 = load i8*, i8** %4
br label %85
85: ; preds = %81, %9
br label %86
86: ; preds = %85, %0
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
@.str.1 = [47 x i8] c"The estimated inverse condition number : %.3e\0A\00"
@.str.3 = [56 x i8] c"%2d : %.15e %.15e %.15e %.15e %.15e %.15e %.15e %.15e\0A\00"
@str.4 = [28 x i8] c"The scaling coefficients : \00"
@str.5 = [32 x i8] c"\0AThe system in the container : \00"
define i32 @quaddobl_scaler() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @syscon_read_quaddobl_system()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %62
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 (...) @syscon_write_quaddobl_system()
%8 = call i32 @syscon_number_of_quaddobl_polynomials(i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %62
10: ; preds = %5
%11 = load i32, i32* %1
%12 = shl nsw i32 %11, 4
%13 = or i32 %12, 8
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca double, i64 %14
%17 = call i32 @quaddobl_scale_system(i32 2, double* %16)
%18 = load i32, i32* %1
%19 = shl nsw i32 %18, 4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %16, i64 %20
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%25 = load i32, i32* %1
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %59
27: ; preds = %10, %27
%28 = phi i64 [ %42, %27 ], [ 0, %10 ]
%29 = trunc i64 %28 to i32
%30 = lshr i32 %29, 3
%31 = getelementptr inbounds double, double* %16, i64 %28
%32 = load double, double* %31
%33 = or i64 %28, 1
%34 = getelementptr inbounds double, double* %16, i64 %33
%35 = load double, double* %34
%36 = or i64 %28, 2
%37 = getelementptr inbounds double, double* %16, i64 %36
%38 = load double, double* %37
%39 = or i64 %28, 3
%40 = getelementptr inbounds double, double* %16, i64 %39
%41 = load double, double* %40
%42 = add nuw nsw i64 %28, 4
%43 = getelementptr inbounds double, double* %16, i64 %42
%44 = load double, double* %43
%45 = add nuw nsw i64 %28, 5
%46 = getelementptr inbounds double, double* %16, i64 %45
%47 = load double, double* %46
%48 = add nuw nsw i64 %28, 6
%49 = getelementptr inbounds double, double* %16, i64 %48
%50 = load double, double* %49
%51 = add nuw nsw i64 %28, 7
%52 = getelementptr inbounds double, double* %16, i64 %51
%53 = load double, double* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %30, double %32, double %35, double %38, double %41, double %44, double %47, double %50, double %53)
%55 = load i32, i32* %1
%56 = shl nsw i32 %55, 4
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %42, %57
br i1 %58, label %27, label %59
59: ; preds = %27, %10
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%61 = call i32 (...) @syscon_write_quaddobl_system()
br label %62
62: ; preds = %5, %59, %0
%63 = phi i32 [ %61, %59 ], [ %8, %5 ], [ %3, %0 ]
ret i32 %63
}