#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 *);
int main() {
  float selling_price, cost_price;
  float profit, loss;
  float profit_pr, loss_pr;
  printf("Enter cost price: ");
  scanf("%f", &cost_price);
  printf("Enter selling price: ");
  scanf("%f", &selling_price);
  if (selling_price > cost_price) {
    profit = selling_price - cost_price;
    profit_pr = (profit / cost_price) * 100;
    printf("Profit: %0.2f Profit Precentage: %0.2f\n", profit, profit_pr);
  } else {
    loss = cost_price - selling_price;
    loss_pr = (loss / cost_price) * 100;
    printf("Loss: %0.2f Loss Percentage: %0.2f\n", loss, loss_pr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11c9 <main+0xa9>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  0xe65(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe73(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1213 <main+0xf3>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  0xe16(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe4c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
ucomiss %xmm2,%xmm1
ja     117f <main+0x5f>
movaps %xmm2,%xmm0
subss  %xmm1,%xmm0
movaps %xmm0,%xmm1
jmp    1183 <main+0x63>
subss  %xmm2,%xmm1
lea    0xea6(%rip),%rax
lea    0xec7(%rip),%rdi
cmova  %rax,%rdi
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divss  %xmm2,%xmm1
mulss  0xe58(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter cost price: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter selling price: \00"
@.str.3 = [40 x i8] c"Profit: %0.2f Profit Precentage: %0.2f\0A\00"
@.str.4 = [36 x i8] c"Loss: %0.2f Loss Percentage: %0.2f\0A\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 ([19 x i8], [19 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* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %2)
%12 = load float, float* %2
%13 = load float, float* %3
%14 = fcmp ogt float %12, %13
br i1 %14, label %15, label %28
15: ; preds = %0
%16 = load float, float* %2
%17 = load float, float* %3
%18 = fsub float %16, %17
store float %18, float* %4
%19 = load float, float* %4
%20 = load float, float* %3
%21 = fdiv float %19, %20
%22 = fmul float %21, 1.000000e+02
store float %22, float* %6
%23 = load float, float* %4
%24 = fpext float %23 to double
%25 = load float, float* %6
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), double %24, double %26)
br label %41
28: ; preds = %0
%29 = load float, float* %3
%30 = load float, float* %2
%31 = fsub float %29, %30
store float %31, float* %5
%32 = load float, float* %5
%33 = load float, float* %3
%34 = fdiv float %32, %33
%35 = fmul float %34, 1.000000e+02
store float %35, float* %7
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = load float, float* %7
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), double %37, double %39)
br label %41
41: ; preds = %28, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter cost price: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter selling price: \00"
@.str.3 = [40 x i8] c"Profit: %0.2f Profit Precentage: %0.2f\0A\00"
@.str.4 = [36 x i8] c"Loss: %0.2f Loss Percentage: %0.2f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, 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 = load float, float* %1
%10 = load float, float* %2
%11 = fcmp ogt float %9, %10
%12 = fsub float %10, %9
%13 = fsub float %9, %10
%14 = select i1 %11, float %13, float %12
%15 = select i1 %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0)
%16 = fdiv float %14, %10
%17 = fmul float %16, 1.000000e+02
%18 = fpext float %14 to double
%19 = fpext float %17 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, double %18, double %19)
ret i32 0
}