#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*/ getchar();
int log10(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
void three() {
  float x, new_x, fx, dfx, accuracy;
  printf("enter initial solution (int), accuracy (float): ");
  scanf("%f%f", &new_x, &accuracy);
  int w1 = log10(new_x) > 0 ? (int)(1 + log10(new_x)) : (int)(1 - log10(new_x)),
      w2 = log10(accuracy) > 0 ? (int)(1 + log10(accuracy))
                               : (int)(1 - log10(accuracy));
  printf("\ngenerating solution of equation x^4=81:\n%*.*f\n\n", w1, w2, new_x);
  do {
    x = new_x;
    fx = x * x * x * x - 81;
    dfx = 4 * x * x * x;
    new_x = x - fx / dfx;
    printf("%*.*f\n", w1 + w2 + 1, w2, new_x);
  } while ((x - new_x) > accuracy || (new_x - x) > accuracy);
  getchar();
  printf("\nreturning to menu. press Enter...");
  getchar();
}


x86 assembly (clang, -O0):
<three>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
call   1060 <log10@plt>
cmp    $0x0,%eax
jle    1192 <three+0x52>
movss  -0x8(%rbp),%xmm0
call   1060 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a8 <three+0x68>
movss  -0x8(%rbp),%xmm0
call   1060 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <log10@plt>
cmp    $0x0,%eax
jle    11d6 <three+0x96>
movss  -0x14(%rbp),%xmm0
call   1060 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ec <three+0xac>
movss  -0x14(%rbp),%xmm0
call   1060 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xdcb(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xdb6(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
divss  -0x10(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x18(%rbp),%esi
add    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x1c(%rbp),%edx
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddd(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
mov    $0x1,%al
ucomiss -0x14(%rbp),%xmm0
mov    %al,-0x25(%rbp)
ja     12c6 <three+0x186>
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
seta   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    120f <three+0xcf>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<three>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
call   1060 <log10@plt>
mov    %eax,%ebx
movss  0xc(%rsp),%xmm0
call   1060 <log10@plt>
mov    %eax,%r15d
neg    %r15d
test   %ebx,%ebx
cmovg  %eax,%r15d
lea    0x1(%r15),%r14d
movss  0x10(%rsp),%xmm0
call   1060 <log10@plt>
mov    %eax,%ebx
movss  0x10(%rsp),%xmm0
call   1060 <log10@plt>
mov    %eax,%ebp
neg    %ebp
test   %ebx,%ebx
cmovg  %eax,%ebp
lea    0x1(%rbp),%ebx
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe73(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <printf@plt>
add    %r15d,%ebp
add    $0x3,%ebp
movss  0xc(%rsp),%xmm0
lea    0xe85(%rip),%r14
nopw   0x0(%rax,%rax,1)
movaps %xmm0,%xmm2
movss  %xmm0,0x14(%rsp)
mulss  %xmm0,%xmm0
mulss  %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  0xdf3(%rip),%xmm0
movaps %xmm2,%xmm1
mulss  0xdec(%rip),%xmm1
mulss  %xmm2,%xmm1
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
addss  %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm3
movss  0xc(%rsp),%xmm0
movaps %xmm3,%xmm2
subss  %xmm0,%xmm2
movss  0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm2
ja     11f0 <three+0xb0>
movaps %xmm0,%xmm2
subss  %xmm3,%xmm2
ucomiss %xmm1,%xmm2
ja     11f0 <three+0xb0>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"enter initial solution (int), accuracy (float): \00"
@.str.1 = [5 x i8] c"%f%f\00"
@.str.2 = [49 x i8] c"\0Agenerating solution of equation x^4=81:\0A%*.*f\0A\0A\00"
@.str.3 = [7 x i8] c"%*.*f\0A\00"
@.str.4 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @three() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %5)
%10 = load float, float* %2
%11 = call i32 @log10(float %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = load float, float* %2
%15 = call i32 @log10(float %14)
%16 = add nsw i32 1, %15
br label %21
17: ; preds = %0
%18 = load float, float* %2
%19 = call i32 @log10(float %18)
%20 = sub nsw i32 1, %19
br label %21
21: ; preds = %17, %13
%22 = phi i32 [ %16, %13 ], [ %20, %17 ]
store i32 %22, i32* %6
%23 = load float, float* %5
%24 = call i32 @log10(float %23)
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load float, float* %5
%28 = call i32 @log10(float %27)
%29 = add nsw i32 1, %28
br label %34
30: ; preds = %21
%31 = load float, float* %5
%32 = call i32 @log10(float %31)
%33 = sub nsw i32 1, %32
br label %34
34: ; preds = %30, %26
%35 = phi i32 [ %29, %26 ], [ %33, %30 ]
store i32 %35, i32* %7
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load float, float* %2
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %37, double %39)
br label %41
41: ; preds = %81, %34
%42 = load float, float* %2
store float %42, float* %1
%43 = load float, float* %1
%44 = load float, float* %1
%45 = fmul float %43, %44
%46 = load float, float* %1
%47 = fmul float %45, %46
%48 = load float, float* %1
%49 = call float @llvm.fmuladd.f32(float %47, float %48, float -8.100000e+01)
store float %49, float* %3
%50 = load float, float* %1
%51 = fmul float 4.000000e+00, %50
%52 = load float, float* %1
%53 = fmul float %51, %52
%54 = load float, float* %1
%55 = fmul float %53, %54
store float %55, float* %4
%56 = load float, float* %1
%57 = load float, float* %3
%58 = load float, float* %4
%59 = fdiv float %57, %58
%60 = fsub float %56, %59
store float %60, float* %2
%61 = load i32, i32* %6
%62 = load i32, i32* %7
%63 = add nsw i32 %61, %62
%64 = add nsw i32 %63, 1
%65 = load i32, i32* %7
%66 = load float, float* %2
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32 %65, double %67)
br label %69
69: ; preds = %41
%70 = load float, float* %1
%71 = load float, float* %2
%72 = fsub float %70, %71
%73 = load float, float* %5
%74 = fcmp ogt float %72, %73
br i1 %74, label %81, label %75
75: ; preds = %69
%76 = load float, float* %2
%77 = load float, float* %1
%78 = fsub float %76, %77
%79 = load float, float* %5
%80 = fcmp ogt float %78, %79
br label %81
81: ; preds = %75, %69
%82 = phi i1 [ true, %69 ], [ %80, %75 ]
br i1 %82, label %41, label %83
83: ; preds = %81
%84 = call i32 (...) @getchar()
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%86 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"enter initial solution (int), accuracy (float): \00"
@.str.1 = [5 x i8] c"%f%f\00"
@.str.2 = [49 x i8] c"\0Agenerating solution of equation x^4=81:\0A%*.*f\0A\0A\00"
@.str.3 = [7 x i8] c"%*.*f\0A\00"
@.str.4 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @three() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2)
%7 = load float, float* %1
%8 = call i32 @log10(float %7)
%9 = icmp sgt i32 %8, 0
%10 = load float, float* %1
%11 = call i32 @log10(float %10)
%12 = sub i32 0, %11
%13 = select i1 %9, i32 %11, i32 %12
%14 = add i32 %13, 1
%15 = load float, float* %2
%16 = call i32 @log10(float %15)
%17 = icmp sgt i32 %16, 0
%18 = load float, float* %2
%19 = call i32 @log10(float %18)
%20 = sub i32 0, %19
%21 = select i1 %17, i32 %19, i32 %20
%22 = add i32 %21, 1
%23 = load float, float* %1
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %22, double %24)
%26 = add i32 %13, 2
%27 = add i32 %26, %22
%28 = load float, float* %1
br label %29
29: ; preds = %29, %0
%30 = phi float [ %41, %29 ], [ %28, %0 ]
%31 = fmul float %30, %30
%32 = fmul float %30, %31
%33 = call float @llvm.fmuladd.f32(float %32, float %30, float -8.100000e+01)
%34 = fmul float %30, 4.000000e+00
%35 = fmul float %30, %34
%36 = fmul float %30, %35
%37 = fdiv float %33, %36
%38 = fsub float %30, %37
store float %38, float* %1
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %22, double %39)
%41 = load float, float* %1
%42 = fsub float %30, %41
%43 = load float, float* %2
%44 = fcmp ogt float %42, %43
%45 = fsub float %41, %30
%46 = fcmp ogt float %45, %43
%47 = or i1 %44, %46
br i1 %47, label %29, label %48
48: ; preds = %29
%49 = call i32 (...) @getchar()
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 (...) @getchar()
ret void
}