#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 */
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int solcon_write_multprec_solutions();
int solve_with_multiprecision(int, int, double, int *);
int syscon_read_multprec_system(int);
int syscon_write_multprec_system();
void multprec_test(void) {
  int fail, max, nit, dcp;
  double eps;
  printf("\nGive the number of decimal places in the precision : ");
  scanf("%d", &dcp);
  fail = syscon_read_multprec_system(dcp);
  fail = syscon_write_multprec_system();
  eps = pow(10.0, -(double)dcp * 0.75);
  printf("accuracy requirement : %.3e\n", eps);
  printf("\nGive the maximum number of iterations : ");
  scanf("%d", &max);
  fail = solve_with_multiprecision(dcp, max, eps, &nit);
  printf("\nNumber of iterations : %d\n", nit);
  fail = solcon_write_multprec_solutions();
}


x86 assembly (clang, -O0):
<multprec_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1030 <syscon_read_multprec_system@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <syscon_write_multprec_system@plt>
mov    %eax,-0x4(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe39(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe25(%rip),%xmm0
call   1090 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
lea    -0xc(%rbp),%rdx
call   1070 <solve_with_multiprecision@plt>
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <solcon_write_multprec_solutions@plt>
mov    %eax,-0x4(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multprec_test>:
push   %rbx
sub    $0x20,%rsp
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <syscon_read_multprec_system@plt>
xor    %eax,%eax
call   1050 <syscon_write_multprec_system@plt>
cvtsi2sdl 0xc(%rsp),%xmm1
mulsd  0xe4b(%rip),%xmm1
movsd  0xe4b(%rip),%xmm0
call   1090 <pow@plt>
movsd  %xmm0,0x18(%rsp)
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x14(%rsp),%esi
lea    0x10(%rsp),%rdx
movsd  0x18(%rsp),%xmm0
call   1070 <solve_with_multiprecision@plt>
mov    0x10(%rsp),%esi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <solcon_write_multprec_solutions@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [55 x i8] c"\0AGive the number of decimal places in the precision : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"accuracy requirement : %.3e\0A\00"
@.str.3 = [42 x i8] c"\0AGive the maximum number of iterations : \00"
@.str.4 = [28 x i8] c"\0ANumber of iterations : %d\0A\00"
define void @multprec_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = call i32 @syscon_read_multprec_system(i32 %8)
store i32 %9, i32* %1
%10 = call i32 (...) @syscon_write_multprec_system()
store i32 %10, i32* %1
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to double
%13 = fneg double %12
%14 = fmul double %13, 7.500000e-01
%15 = call double @pow(double 1.000000e+01, double %14)
store double %15, double* %5
%16 = load double, double* %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = load double, double* %5
%23 = call i32 @solve_with_multiprecision(i32 %20, i32 %21, double %22, i32* %3)
store i32 %23, i32* %1
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = call i32 (...) @solcon_write_multprec_solutions()
store i32 %26, i32* %1
ret void
}

LLVM IR (-O2):
@.str = [55 x i8] c"\0AGive the number of decimal places in the precision : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"accuracy requirement : %.3e\0A\00"
@.str.3 = [42 x i8] c"\0AGive the maximum number of iterations : \00"
@.str.4 = [28 x i8] c"\0ANumber of iterations : %d\0A\00"
define void @multprec_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = call i32 @syscon_read_multprec_system(i32 %9)
%11 = call i32 (...) @syscon_write_multprec_system()
%12 = load i32, i32* %3
%13 = sitofp i32 %12 to double
%14 = fmul double %13, -7.500000e-01
%15 = call double @pow(double 1.000000e+01, double %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %3
%20 = load i32, i32* %1
%21 = call i32 @solve_with_multiprecision(i32 %19, i32 %20, double %15, i32* %2)
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = call i32 (...) @solcon_write_multprec_solutions()
ret void
}