#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 logn(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ system(char *);
int main(int argc, char const *argv[]) {
  int n;
  double x, y1, y2;
  printf("Calculadora de ln(x):\n");
  printf("Insira um x maior que 0.5: ");
  scanf("%lf", &x);
  printf("Insira o numero de termos da serie: ");
  scanf("%d", &n);
  y1 = logn(x, n);
  y2 = log(x);
  printf("Funcao desenvolvida pelo aluno: ln(x) = %lf\n\nFuncao da biblioteca "
         "math.h: ln(x) = %lf \n\n",
         y1, y2);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <logn@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xe79(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xec4(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf3c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    0x4(%rsp),%edi
call   1040 <logn@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
lea    0xe6c(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1060 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Calculadora de ln(x):\0A\00"
@.str.1 = [28 x i8] c"Insira um x maior que 0.5: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [37 x i8] c"Insira o numero de termos da serie: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [89 x i8] c"Funcao desenvolvida pelo aluno: ln(x) = %lf\0A\0AFuncao da biblioteca math.h: ln(x) = %lf \0A\0A\00"
@.str.6 = [6 x i8] c"pause\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%15 = load double, double* %7
%16 = load i32, i32* %6
%17 = call double @logn(double %15, i32 %16)
store double %17, double* %8
%18 = load double, double* %7
%19 = call double @log(double %18)
store double %19, double* %9
%20 = load double, double* %8
%21 = load double, double* %9
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), double %20, double %21)
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"Insira um x maior que 0.5: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [37 x i8] c"Insira o numero de termos da serie: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [89 x i8] c"Funcao desenvolvida pelo aluno: ln(x) = %lf\0A\0AFuncao da biblioteca math.h: ln(x) = %lf \0A\0A\00"
@.str.6 = [6 x i8] c"pause\00"
@str = [22 x i8] c"Calculadora de ln(x):\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca double
%5 = bitcast i32* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = load double, double* %4
%13 = load i32, i32* %3
%14 = call double @logn(double %12, i32 %13)
%15 = load double, double* %4
%16 = call double @log(double %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), double %14, double %16)
%18 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}