#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 *, float *);
float sqrt(float);
int main() {
  float a, b, c, D, x1, x2;
  printf("Masukan angka untuk a: ");
  scanf("%f", &a);
  printf("Masukan angka untuk b: ");
  scanf("%f", &b);
  printf("Masukan angka untuk c: ");
  scanf("%f", &c);
  if (a > 0) {
    D = b * b - 4 * a * c;
    if (D > 0) {
      printf("Akar real.");
      x1 = (-b + sqrt(D)) / (2 * a);
      x2 = (-b - sqrt(D)) / (2 * a);
      printf("\nx1, x2 adalah: %f, %f", x1, x2);
    } else if (D == 0) {
      printf("Akar kembar.");
      x1 = (-b) / (2 * a);
      printf("\nx1 adalah: %f", x1);
    } else if (D < 0) {
      printf("angka imaginer.");
    }
  } else
    printf("Nilai a harus >0");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    133d <main+0x20d>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe44(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    12aa <main+0x17a>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xdd0(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  0xd8d(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdbd(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1338 <main+0x208>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1313 <main+0x1e3>
jp     1313 <main+0x1e3>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd1b(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd78(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    132e <main+0x1fe>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1333 <main+0x203>
jmp    1338 <main+0x208>
jmp    134b <main+0x21b>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf3d(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movss  0x14(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jbe    1294 <main+0x164>
movss  0x10(%rsp),%xmm2
mulss  0xe53(%rip),%xmm1
mulss  0x1c(%rsp),%xmm1
mulss  %xmm2,%xmm2
addss  %xmm1,%xmm2
ucomiss %xmm0,%xmm2
jbe    12a4 <main+0x174>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
movss  %xmm2,0xc(%rsp)
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
sqrtss %xmm1,%xmm3
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm1
movaps %xmm3,%xmm2
jae    121f <main+0xef>
movss  %xmm0,0x18(%rsp)
movaps %xmm1,%xmm0
movss  %xmm3,0x20(%rsp)
call   1050 <sqrt@plt>
xorps  %xmm4,%xmm4
movss  0x20(%rsp),%xmm3
movss  0xc(%rsp),%xmm1
movaps %xmm0,%xmm2
movss  0x18(%rsp),%xmm0
subss  %xmm0,%xmm2
movss  0x14(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm2
movss  0x10(%rsp),%xmm5
xorps  0xdd2(%rip),%xmm5
ucomiss %xmm4,%xmm1
jae    1264 <main+0x134>
movaps %xmm1,%xmm0
movss  %xmm2,0xc(%rsp)
movaps %xmm5,0x20(%rsp)
call   1050 <sqrt@plt>
movaps 0x20(%rsp),%xmm5
movss  0xc(%rsp),%xmm2
movaps %xmm0,%xmm3
subss  %xmm3,%xmm5
movss  0x14(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm5,%xmm1
lea    0xde8(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12f9 <main+0x1c9>
lea    0xe1b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    12f9 <main+0x1c9>
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jne    12eb <main+0x1bb>
jp     12eb <main+0x1bb>
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm0
xorps  0xd47(%rip),%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12f9 <main+0x1c9>
ucomiss %xmm2,%xmm0
jbe    12f9 <main+0x1c9>
lea    0xdaf(%rip),%rdi
jmp    129b <main+0x16b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Masukan angka untuk a: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [24 x i8] c"Masukan angka untuk b: \00"
@.str.3 = [24 x i8] c"Masukan angka untuk c: \00"
@.str.4 = [11 x i8] c"Akar real.\00"
@.str.5 = [23 x i8] c"\0Ax1, x2 adalah: %f, %f\00"
@.str.6 = [13 x i8] c"Akar kembar.\00"
@.str.7 = [15 x i8] c"\0Ax1 adalah: %f\00"
@.str.8 = [16 x i8] c"angka imaginer.\00"
@.str.9 = [17 x i8] c"Nilai a harus >0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%14 = load float, float* %2
%15 = fcmp ogt float %14, 0.000000e+00
br i1 %15, label %16, label %71
16: ; preds = %0
%17 = load float, float* %3
%18 = load float, float* %3
%19 = load float, float* %2
%20 = fmul float 4.000000e+00, %19
%21 = load float, float* %4
%22 = fmul float %20, %21
%23 = fneg float %22
%24 = call float @llvm.fmuladd.f32(float %17, float %18, float %23)
store float %24, float* %5
%25 = load float, float* %5
%26 = fcmp ogt float %25, 0.000000e+00
br i1 %26, label %27, label %50
27: ; preds = %16
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%29 = load float, float* %3
%30 = fneg float %29
%31 = load float, float* %5
%32 = call float @sqrt(float %31)
%33 = fadd float %30, %32
%34 = load float, float* %2
%35 = fmul float 2.000000e+00, %34
%36 = fdiv float %33, %35
store float %36, float* %6
%37 = load float, float* %3
%38 = fneg float %37
%39 = load float, float* %5
%40 = call float @sqrt(float %39)
%41 = fsub float %38, %40
%42 = load float, float* %2
%43 = fmul float 2.000000e+00, %42
%44 = fdiv float %41, %43
store float %44, float* %7
%45 = load float, float* %6
%46 = fpext float %45 to double
%47 = load float, float* %7
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), double %46, double %48)
br label %70
50: ; preds = %16
%51 = load float, float* %5
%52 = fcmp oeq float %51, 0.000000e+00
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%55 = load float, float* %3
%56 = fneg float %55
%57 = load float, float* %2
%58 = fmul float 2.000000e+00, %57
%59 = fdiv float %56, %58
store float %59, float* %6
%60 = load float, float* %6
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), double %61)
br label %69
63: ; preds = %50
%64 = load float, float* %5
%65 = fcmp olt float %64, 0.000000e+00
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
br label %69
69: ; preds = %68, %53
br label %70
70: ; preds = %69, %27
br label %73
71: ; preds = %0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %73
73: ; preds = %71, %70
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Masukan angka untuk a: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [24 x i8] c"Masukan angka untuk b: \00"
@.str.3 = [24 x i8] c"Masukan angka untuk c: \00"
@.str.4 = [11 x i8] c"Akar real.\00"
@.str.5 = [23 x i8] c"\0Ax1, x2 adalah: %f, %f\00"
@.str.6 = [13 x i8] c"Akar kembar.\00"
@.str.7 = [15 x i8] c"\0Ax1 adalah: %f\00"
@.str.8 = [16 x i8] c"angka imaginer.\00"
@.str.9 = [17 x i8] c"Nilai a harus >0\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = load float, float* %1
%14 = fcmp ogt float %13, 0.000000e+00
br i1 %14, label %15, label %55
15: ; preds = %0
%16 = load float, float* %2
%17 = load float, float* %3
%18 = fmul float %13, -4.000000e+00
%19 = fmul float %18, %17
%20 = call float @llvm.fmuladd.f32(float %16, float %16, float %19)
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %40
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%24 = load float, float* %2
%25 = call float @sqrt(float %20)
%26 = fsub float %25, %24
%27 = load float, float* %1
%28 = fmul float %27, 2.000000e+00
%29 = fdiv float %26, %28
%30 = load float, float* %2
%31 = fneg float %30
%32 = call float @sqrt(float %20)
%33 = fsub float %31, %32
%34 = load float, float* %1
%35 = fmul float %34, 2.000000e+00
%36 = fdiv float %33, %35
%37 = fpext float %29 to double
%38 = fpext float %36 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), double %37, double %38)
br label %57
40: ; preds = %15
%41 = fcmp oeq float %20, 0.000000e+00
br i1 %41, label %42, label %51
42: ; preds = %40
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%44 = load float, float* %2
%45 = fneg float %44
%46 = load float, float* %1
%47 = fmul float %46, 2.000000e+00
%48 = fdiv float %45, %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), double %49)
br label %57
51: ; preds = %40
%52 = fcmp olt float %20, 0.000000e+00
br i1 %52, label %53, label %57
53: ; preds = %51
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %57
55: ; preds = %0
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %57
57: ; preds = %22, %51, %53, %42, %55
ret i32 0
}