#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 pow(int, int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ printf(char *, int, int, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sqrt(float);
void ex4() {
  print("\n------------------------------\n");
  print("Leia, em um algoritmo, os coeficientes de uma equacao do segundo "
        "grau. Calcule suas raizes e informe-as.");
  print("Equacao do 2o grau: [ A x^2 + B x + C = 0 ]");
  int a, b, c;
  float raiz1, raiz2, delta;
  print("Informe o valor do coeficiente A:");
  scanf("%d", &a);
  print("Informe o valor do coeficiente B:");
  scanf("%d", &b);
  print("Informe o valor do coeficiente C:");
  scanf("%d", &c);
  delta = pow(b, 2) - (4 * a * c);
  if (delta < 0) {
    printf("A equacao %dx^2 + %dx + %d nao possui raizes reais.\n", a, b, c);
  } else {
    raiz1 = (-b + sqrt(delta)) / (2 * a);
    raiz2 = (-b - sqrt(delta)) / (2 * a);
    if (raiz1 == raiz2) {
      printf("A equacao %dx^2 + %dx + %d uma raiz real.\n\tx1 = x2 = %.2f.\n",
             a, b, c, raiz1);
    } else {
      printf("A equacao %dx^2 + %dx + %d possui duas raizes reais.\n\tx1 = "
             "%.2f\n\tx2 = %.2f\n",
             a, b, c, raiz1, raiz2);
    }
  }
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1040 <print@plt>
lea    0xeb6(%rip),%rdi
call   1040 <print@plt>
lea    0xf13(%rip),%rdi
call   1040 <print@plt>
lea    0xf33(%rip),%rdi
call   1040 <print@plt>
lea    0xf49(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf3c(%rip),%rdi
call   1040 <print@plt>
lea    0xf2d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf42(%rip),%rdi
call   1040 <print@plt>
lea    0xf11(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
imul   -0xc(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    121b <ex4+0xcb>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d9 <ex4+0x189>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
call   1070 <sqrt@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
call   1070 <sqrt@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jne    12ab <ex4+0x15b>
jp     12ab <ex4+0x15b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d4 <ex4+0x184>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xec3(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12d9 <ex4+0x189>
lea    0xd20(%rip),%rdi
call   1040 <print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex4>:
push   %rbx
sub    $0x20,%rsp
lea    0xea4(%rip),%rdi
call   1040 <print@plt>
lea    0xeb9(%rip),%rdi
call   1040 <print@plt>
lea    0xf16(%rip),%rdi
call   1040 <print@plt>
lea    0xf36(%rip),%rdi
call   1040 <print@plt>
lea    0xf4c(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf3b(%rip),%rdi
call   1040 <print@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf44(%rip),%rdi
call   1040 <print@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%ecx
mov    %esi,%edx
imul   %ecx,%edx
shl    $0x2,%edx
sub    %edx,%eax
mov    0xc(%rsp),%ebx
js     1262 <ex4+0x112>
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x18(%rsp)
call   1070 <sqrt@plt>
sub    %ebx,%eax
mov    0x10(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x1c(%rsp)
mov    0xc(%rsp),%ebx
movss  0x18(%rsp),%xmm0
call   1070 <sqrt@plt>
add    %ebx,%eax
neg    %eax
mov    0x10(%rsp),%esi
lea    (%rsi,%rsi,1),%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
movss  0x1c(%rsp),%xmm0
ucomiss %xmm1,%xmm0
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
cvtss2sd %xmm0,%xmm0
jne    1274 <ex4+0x124>
jp     1274 <ex4+0x124>
lea    0xefb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1286 <ex4+0x136>
lea    0xeb6(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1286 <ex4+0x136>
cvtss2sd %xmm1,%xmm1
lea    0xf11(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xd73(%rip),%rdi
call   1040 <print@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [105 x i8] c"Leia, em um algoritmo, os coeficientes de uma equacao do segundo grau. Calcule suas raizes e informe-as.\00"
@.str.2 = [44 x i8] c"Equacao do 2o grau: [ A x^2 + B x + C = 0 ]\00"
@.str.3 = [34 x i8] c"Informe o valor do coeficiente A:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"Informe o valor do coeficiente B:\00"
@.str.6 = [34 x i8] c"Informe o valor do coeficiente C:\00"
@.str.7 = [53 x i8] c"A equacao %dx^2 + %dx + %d nao possui raizes reais.\0A\00"
@.str.8 = [60 x i8] c"A equacao %dx^2 + %dx + %d uma raiz real.\0A\09x1 = x2 = %.2f.\0A\00"
@.str.9 = [76 x i8] c"A equacao %dx^2 + %dx + %d possui duas raizes reais.\0A\09x1 = %.2f\0A\09x2 = %.2f\0A\00"
define void @ex4() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @print(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @print(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = call i32 @pow(i32 %16, i32 2)
%18 = load i32, i32* %1
%19 = mul nsw i32 4, %18
%20 = load i32, i32* %3
%21 = mul nsw i32 %19, %20
%22 = sub nsw i32 %17, %21
%23 = sitofp i32 %22 to float
store float %23, float* %6
%24 = load float, float* %6
%25 = fcmp olt float %24, 0.000000e+00
br i1 %25, label %26, label %31
26: ; preds = %0
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %70
31: ; preds = %0
%32 = load i32, i32* %2
%33 = sub nsw i32 0, %32
%34 = load float, float* %6
%35 = call i32 @sqrt(float %34)
%36 = add nsw i32 %33, %35
%37 = load i32, i32* %1
%38 = mul nsw i32 2, %37
%39 = sdiv i32 %36, %38
%40 = sitofp i32 %39 to float
store float %40, float* %4
%41 = load i32, i32* %2
%42 = sub nsw i32 0, %41
%43 = load float, float* %6
%44 = call i32 @sqrt(float %43)
%45 = sub nsw i32 %42, %44
%46 = load i32, i32* %1
%47 = mul nsw i32 2, %46
%48 = sdiv i32 %45, %47
%49 = sitofp i32 %48 to float
store float %49, float* %5
%50 = load float, float* %4
%51 = load float, float* %5
%52 = fcmp oeq float %50, %51
br i1 %52, label %53, label %60
53: ; preds = %31
%54 = load i32, i32* %1
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = load float, float* %4
%58 = fpext float %57 to double
%59 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0), i32 %54, i32 %55, i32 %56, double %58)
br label %69
60: ; preds = %31
%61 = load i32, i32* %1
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = load float, float* %4
%65 = fpext float %64 to double
%66 = load float, float* %5
%67 = fpext float %66 to double
%68 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.9, i64 0, i64 0), i32 %61, i32 %62, i32 %63, double %65, double %67)
br label %69
69: ; preds = %60, %53
br label %70
70: ; preds = %69, %26
%71 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [105 x i8] c"Leia, em um algoritmo, os coeficientes de uma equacao do segundo grau. Calcule suas raizes e informe-as.\00"
@.str.2 = [44 x i8] c"Equacao do 2o grau: [ A x^2 + B x + C = 0 ]\00"
@.str.3 = [34 x i8] c"Informe o valor do coeficiente A:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"Informe o valor do coeficiente B:\00"
@.str.6 = [34 x i8] c"Informe o valor do coeficiente C:\00"
@.str.7 = [53 x i8] c"A equacao %dx^2 + %dx + %d nao possui raizes reais.\0A\00"
@.str.8 = [60 x i8] c"A equacao %dx^2 + %dx + %d uma raiz real.\0A\09x1 = x2 = %.2f.\0A\00"
@.str.9 = [76 x i8] c"A equacao %dx^2 + %dx + %d possui duas raizes reais.\0A\09x1 = %.2f\0A\09x2 = %.2f\0A\00"
define void @ex4() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @print(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @print(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = tail call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = call i32 @print(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = call i32 @pow(i32 %16, i32 2)
%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 = sitofp i32 %22 to float
%24 = icmp slt i32 %22, 0
%25 = load i32, i32* %2
br i1 %24, label %26, label %28
26: ; preds = %0
%27 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 %25, i32 %20)
br label %52
28: ; preds = %0
%29 = call i32 @sqrt(float %23)
%30 = sub i32 %29, %25
%31 = load i32, i32* %1
%32 = shl nsw i32 %31, 1
%33 = sdiv i32 %30, %32
%34 = sitofp i32 %33 to float
%35 = load i32, i32* %2
%36 = call i32 @sqrt(float %23)
%37 = add i32 %35, %36
%38 = sub i32 0, %37
%39 = load i32, i32* %1
%40 = shl nsw i32 %39, 1
%41 = sdiv i32 %38, %40
%42 = sitofp i32 %41 to float
%43 = fcmp oeq float %34, %42
%44 = load i32, i32* %2
%45 = load i32, i32* %3
%46 = fpext float %34 to double
br i1 %43, label %47, label %49
47: ; preds = %28
%48 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0), i32 %39, i32 %44, i32 %45, double %46)
br label %52
49: ; preds = %28
%50 = fpext float %42 to double
%51 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.9, i64 0, i64 0), i32 %39, i32 %44, i32 %45, double %46, double %50)
br label %52
52: ; preds = %47, %49, %26
%53 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}