#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sqrt(int);
int main() {
  int a, b, c;
  float r1, r2;
  unsigned int intentos = 0;
  while (intentos < 2) {
    printf("\n\nIngrese los coeficientes de la cuadratica ax^2+bx+c\n");
    printf("a = ");
    scanf("%d", &a);
    printf("b = ");
    scanf("%d", &b);
    printf("c = ");
    scanf("%d", &c);
    int deter = b * b - 4 * a * c;
    if (deter < 0) {
      printf("sus dos raices son imaginarias!\n");
      intentos++;
    } else {
      r1 = (-b + sqrt(deter)) / 2 * a;
      r2 = (-b - sqrt(deter)) / 2 * a;
      printf("Raices: x1=%f x2=%f\n", r1, r2);
      intentos = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jae    1278 <main+0x148>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    11f4 <main+0xc4>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1273 <main+0x143>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
imul   -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe05(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb0(%rip),%rbx
lea    0xeb1(%rip),%r14
lea    0x14(%rsp),%r15
xor    %r13d,%r13d
jmp    11e3 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1060 <sqrt@plt>
sub    %ebp,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
imul   0x8(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
movss  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%ebp
mov    %r12d,%edi
call   1060 <sqrt@plt>
add    %ebp,%eax
mov    %eax,%ecx
neg    %ecx
shr    $0x1f,%ecx
sub    %eax,%ecx
sar    %ecx
imul   0x8(%rsp),%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xe43(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %r13d,%r13d
cmp    $0x2,%r13d
jae    1274 <main+0x134>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%r12d
imul   %ebp,%r12d
mov    0x8(%rsp),%eax
imul   0x14(%rsp),%eax
shl    $0x2,%eax
sub    %eax,%r12d
jns    1170 <main+0x30>
lea    0xdfc(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r13d
cmp    $0x2,%r13d
jb     11e3 <main+0xa3>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"\0A\0AIngrese los coeficientes de la cuadratica ax^2+bx+c\0A\00"
@.str.1 = [5 x i8] c"a = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"b = \00"
@.str.4 = [5 x i8] c"c = \00"
@.str.5 = [33 x i8] c"sus dos raices son imaginarias!\0A\00"
@.str.6 = [21 x i8] c"Raices: x1=%f x2=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
br label %9
9: ; preds = %58, %0
%10 = load i32, i32* %7
%11 = icmp ult i32 %10, 2
br i1 %11, label %12, label %59
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%20 = load i32, i32* %3
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %2
%24 = mul nsw i32 4, %23
%25 = load i32, i32* %4
%26 = mul nsw i32 %24, %25
%27 = sub nsw i32 %22, %26
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %12
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32, i32* %7
%33 = add i32 %32, 1
store i32 %33, i32* %7
br label %58
34: ; preds = %12
%35 = load i32, i32* %3
%36 = sub nsw i32 0, %35
%37 = load i32, i32* %8
%38 = call i32 @sqrt(i32 %37)
%39 = add nsw i32 %36, %38
%40 = sdiv i32 %39, 2
%41 = load i32, i32* %2
%42 = mul nsw i32 %40, %41
%43 = sitofp i32 %42 to float
store float %43, float* %5
%44 = load i32, i32* %3
%45 = sub nsw i32 0, %44
%46 = load i32, i32* %8
%47 = call i32 @sqrt(i32 %46)
%48 = sub nsw i32 %45, %47
%49 = sdiv i32 %48, 2
%50 = load i32, i32* %2
%51 = mul nsw i32 %49, %50
%52 = sitofp i32 %51 to float
store float %52, float* %6
%53 = load float, float* %5
%54 = fpext float %53 to double
%55 = load float, float* %6
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %54, double %56)
store i32 0, i32* %7
br label %58
58: ; preds = %34, %30
br label %9
59: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"a = \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"b = \00"
@.str.4 = [5 x i8] c"c = \00"
@.str.6 = [21 x i8] c"Raices: x1=%f x2=%f\0A\00"
@str = [54 x i8] c"\0A\0AIngrese los coeficientes de la cuadratica ax^2+bx+c\00"
@str.7 = [32 x i8] c"sus dos raices son imaginarias!\00"
define i32 @main() {
%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*
br label %7
7: ; preds = %0, %45
%8 = phi i32 [ 0, %0 ], [ %46, %45 ]
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, %16
%18 = load i32, i32* %1
%19 = mul i32 %18, -4
%20 = load i32, i32* %3
%21 = mul i32 %19, %20
%22 = add i32 %21, %17
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %7
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%26 = add nuw nsw i32 %8, 1
br label %45
27: ; preds = %7
%28 = call i32 @sqrt(i32 %22)
%29 = sub i32 %28, %16
%30 = sdiv i32 %29, 2
%31 = load i32, i32* %1
%32 = mul nsw i32 %30, %31
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %2
%35 = call i32 @sqrt(i32 %22)
%36 = add i32 %34, %35
%37 = sub i32 0, %36
%38 = sdiv i32 %37, 2
%39 = load i32, i32* %1
%40 = mul nsw i32 %38, %39
%41 = sitofp i32 %40 to float
%42 = fpext float %33 to double
%43 = fpext float %41 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %42, double %43)
br label %45
45: ; preds = %27, %24
%46 = phi i32 [ %26, %24 ], [ 0, %27 ]
%47 = icmp ult i32 %46, 2
br i1 %47, label %7, label %48
48: ; preds = %45
ret i32 0
}