#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*/ printf(char *, ...);
double read_number();
scalar_t__ secant(double *, double, int);
int main() {
  double x[] = {0, 0};
  double prec = 0.e-10;
  int itermax = 10000;
  printf("x_0 = ");
  x[0] = read_number();
  printf("x_1 = ");
  x[1] = read_number();
  secant(x, prec, itermax) ? printf("Ha convergit!\n")
                           : printf("No ha convergit :(\n");
  printf("x = %.8e\n", x[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x2710,-0x2c(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <read_number@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <read_number@plt>
movsd  %xmm0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    -0x2c(%rbp),%esi
call   1050 <secant@plt>
cmp    $0x0,%rax
je     11d0 <main+0x90>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0x9e>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <read_number@plt>
movsd  %xmm0,(%rsp)
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <read_number@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rsp,%rdi
xorps  %xmm0,%xmm0
mov    $0x2710,%esi
call   1050 <secant@plt>
test   %rax,%rax
lea    0xe85(%rip),%rax
lea    0xe91(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"x_0 = \00"
@.str.1 = [7 x i8] c"x_1 = \00"
@.str.2 = [15 x i8] c"Ha convergit!\0A\00"
@.str.3 = [20 x i8] c"No ha convergit :(\0A\00"
@.str.4 = [10 x i8] c"x = %.8e\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x double]
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [2 x double]* %2 to i8*
store double 0.000000e+00, double* %3
store i32 10000, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = call double (...) @read_number()
%8 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
store double %7, double* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call double (...) @read_number()
%11 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 1
store double %10, double* %11
%12 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%13 = load double, double* %3
%14 = load i32, i32* %4
%15 = call i64 @secant(double* %12, double %13, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
%23 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 1
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"x_0 = \00"
@.str.1 = [7 x i8] c"x_1 = \00"
@.str.4 = [10 x i8] c"x = %.8e\0A\00"
@str = [19 x i8] c"No ha convergit :(\00"
@str.5 = [14 x i8] c"Ha convergit!\00"
define i32 @main() {
%1 = alloca [2 x double]
%2 = bitcast [2 x double]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = tail call double (...) @read_number()
%5 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 0
store double %4, double* %5
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call double (...) @read_number()
%8 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 1
store double %7, double* %8
%9 = call i64 @secant(double* %5, double 0.000000e+00, i32 10000)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0)
%12 = call i32 @puts(i8* dereferenceable(1) %11)
%13 = load double, double* %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %13)
ret i32 0
}