#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 log(double);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *);
int main(void) {
  double b, x, val, val2, f, g;
  printf("\nPlease input b and x values:\n");
  scanf("%lf %lf", &b, &x);
  val = log(x);
  val2 = log(b);
  f = val / val2;
  printf("\nb = %g\n", b);
  printf("x = %g\n\n", x);
  printf("\nlog_e(x) = %g\n", val);
  printf("log_e(b) = %g\n\n", val2);
  printf("log_b(x) = %g\n\n", f);
  g = pow(b, f);
  printf("g = %g\n\n", g);
  if (x == g)
    printf("Recreated x = %g\n\n", g);
  if (x != g)
    printf("NOT =\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe7d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xeb6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe60(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    124d <main+0x10d>
jp     124d <main+0x10d>
movsd  -0x38(%rbp),%xmm0
lea    0xe23(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    1268 <main+0x128>
jp     1268 <main+0x128>
jmp    1276 <main+0x136>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe33(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,(%rsp)
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1259 <main+0x109>
jp     1259 <main+0x109>
lea    0xe03(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1261 <main+0x111>
jnp    126d <main+0x11d>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0APlease input b and x values:\0A\00"
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [9 x i8] c"\0Ab = %g\0A\00"
@.str.3 = [9 x i8] c"x = %g\0A\0A\00"
@.str.4 = [16 x i8] c"\0Alog_e(x) = %g\0A\00"
@.str.5 = [16 x i8] c"log_e(b) = %g\0A\0A\00"
@.str.6 = [16 x i8] c"log_b(x) = %g\0A\0A\00"
@.str.7 = [9 x i8] c"g = %g\0A\0A\00"
@.str.8 = [19 x i8] c"Recreated x = %g\0A\0A\00"
@.str.9 = [8 x i8] c"NOT =\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
%10 = load double, double* %3
%11 = call double @log(double %10)
store double %11, double* %4
%12 = load double, double* %2
%13 = call double @log(double %12)
store double %13, double* %5
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fdiv double %14, %15
store double %16, double* %6
%17 = load double, double* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = load double, double* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %19)
%21 = load double, double* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %21)
%23 = load double, double* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %23)
%25 = load double, double* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), double %25)
%27 = load double, double* %2
%28 = load double, double* %6
%29 = call double @pow(double %27, double %28)
store double %29, double* %7
%30 = load double, double* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %30)
%32 = load double, double* %3
%33 = load double, double* %7
%34 = fcmp oeq double %32, %33
br i1 %34, label %35, label %38
35: ; preds = %0
%36 = load double, double* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %36)
br label %38
38: ; preds = %35, %0
%39 = load double, double* %3
%40 = load double, double* %7
%41 = fcmp une double %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [9 x i8] c"\0Ab = %g\0A\00"
@.str.3 = [9 x i8] c"x = %g\0A\0A\00"
@.str.4 = [16 x i8] c"\0Alog_e(x) = %g\0A\00"
@.str.5 = [16 x i8] c"log_e(b) = %g\0A\0A\00"
@.str.6 = [16 x i8] c"log_b(x) = %g\0A\0A\00"
@.str.7 = [9 x i8] c"g = %g\0A\0A\00"
@.str.8 = [19 x i8] c"Recreated x = %g\0A\0A\00"
@str = [30 x i8] c"\0APlease input b and x values:\00"
@str.10 = [7 x i8] c"NOT =\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%7 = load double, double* %2
%8 = call double @log(double %7)
%9 = load double, double* %1
%10 = call double @log(double %9)
%11 = fdiv double %8, %10
%12 = load double, double* %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %12)
%14 = load double, double* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), double %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %8)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %10)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), double %11)
%19 = load double, double* %1
%20 = call double @pow(double %19, double %11)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %20)
%22 = load double, double* %2
%23 = fcmp oeq double %22, %20
br i1 %23, label %24, label %27
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %20)
%26 = load double, double* %2
br label %27
27: ; preds = %24, %0
%28 = phi double [ %26, %24 ], [ %22, %0 ]
%29 = fcmp une double %28, %20
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.10, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret i32 0
}