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


x86 assembly (clang, -O0):
<dobldobl_scaler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1070 <syscon_read_dobldobl_system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    129e <dobldobl_scaler+0x14e>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <syscon_write_dobldobl_system@plt>
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <syscon_number_of_dobldobl_polynomials@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1299 <dobldobl_scaler+0x149>
mov    -0x8(%rbp),%ecx
mov    %ecx,%eax
lea    0x4(,%rax,8),%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   1060 <dobldobl_scale_system@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,-0x4(%rbp)
mov    -0x8(%rbp),%ecx
shl    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jge    127a <dobldobl_scaler+0x12a>
mov    -0xc(%rbp),%eax
mov    $0x4,%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
lea    0xe08(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1209 <dobldobl_scaler+0xb9>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <syscon_write_dobldobl_system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    129e <dobldobl_scaler+0x14e>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dobldobl_scaler>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <syscon_read_dobldobl_system@plt>
test   %eax,%eax
jne    1263 <dobldobl_scaler+0x103>
lea    0xee7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <syscon_write_dobldobl_system@plt>
lea    -0x2c(%rbp),%rdi
call   1050 <syscon_number_of_dobldobl_polynomials@plt>
test   %eax,%eax
jne    1263 <dobldobl_scaler+0x103>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
lea    0x4(,%rax,8),%eax
shl    $0x3,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    $0x2,%edi
mov    %r14,%rsi
call   1070 <dobldobl_scale_system@plt>
movslq -0x2c(%rbp),%rax
shl    $0x6,%rax
movsd  (%rax,%r14,1),%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    124d <dobldobl_scaler+0xed>
xor    %r13d,%r13d
lea    0xe2f(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
movsd  0x8(%r14,%rbx,8),%xmm1
movsd  0x10(%r14,%rbx,8),%xmm2
movsd  0x18(%r14,%rbx,8),%xmm3
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x4,%al
call   1060 <printf@plt>
add    $0x4,%rbx
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    $0x1,%r13d
cmp    %rax,%rbx
jl     1210 <dobldobl_scaler+0xb0>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <syscon_write_dobldobl_system@plt>
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [32 x i8] c"%2d : %.15e %.15e %.15e %.15e\0A\00"
define i32 @dobldobl_scaler() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = call i32 (...) @syscon_read_dobldobl_system()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %66
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_dobldobl_system()
store i32 %11, i32* %1
%12 = call i32 @syscon_number_of_dobldobl_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 %65
15: ; preds = %9
%16 = load i32, i32* %2
%17 = mul nsw i32 8, %16
%18 = add nsw i32 %17, 4
%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 @dobldobl_scale_system(i32 2, double* %21)
store i32 %22, i32* %1
%23 = load i32, i32* %2
%24 = mul nsw i32 8, %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 = %58, %15
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = mul nsw i32 8, %32
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %61
35: ; preds = %30
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 4
%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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %37, double %41, double %46, double %51, double %56)
br label %58
58: ; preds = %35
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 4
store i32 %60, i32* %3
br label %30
61: ; preds = %30
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%63 = call i32 (...) @syscon_write_dobldobl_system()
store i32 %63, i32* %1
%64 = load i8*, i8** %4
br label %65
65: ; preds = %61, %9
br label %66
66: ; preds = %65, %0
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str.1 = [47 x i8] c"The estimated inverse condition number : %.3e\0A\00"
@.str.3 = [32 x i8] c"%2d : %.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 @dobldobl_scaler() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @syscon_read_dobldobl_system()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %51
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_dobldobl_system()
%8 = call i32 @syscon_number_of_dobldobl_polynomials(i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %51
10: ; preds = %5
%11 = load i32, i32* %1
%12 = shl nsw i32 %11, 3
%13 = or i32 %12, 4
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca double, i64 %14
%17 = call i32 @dobldobl_scale_system(i32 2, double* %16)
%18 = load i32, i32* %1
%19 = shl nsw i32 %18, 3
%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 %48
27: ; preds = %10, %27
%28 = phi i64 [ %43, %27 ], [ 0, %10 ]
%29 = lshr exact i64 %28, 2
%30 = getelementptr inbounds double, double* %16, i64 %28
%31 = load double, double* %30
%32 = or i64 %28, 1
%33 = getelementptr inbounds double, double* %16, i64 %32
%34 = load double, double* %33
%35 = or i64 %28, 2
%36 = getelementptr inbounds double, double* %16, i64 %35
%37 = load double, double* %36
%38 = or i64 %28, 3
%39 = getelementptr inbounds double, double* %16, i64 %38
%40 = load double, double* %39
%41 = trunc i64 %29 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %41, double %31, double %34, double %37, double %40)
%43 = add nuw nsw i64 %28, 4
%44 = load i32, i32* %1
%45 = shl nsw i32 %44, 3
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %43, %46
br i1 %47, label %27, label %48
48: ; preds = %27, %10
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%50 = call i32 (...) @syscon_write_dobldobl_system()
br label %51
51: ; preds = %5, %48, %0
%52 = phi i32 [ %50, %48 ], [ %8, %5 ], [ %3, %0 ]
ret i32 %52
}