#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 main(void) {
  const double unit_price = 3.50;
  int quantity = 0;
  printf("Enter the number that you want to buy : ");
  scanf(" %d", &quantity);
  double total = 0.0;
  if (quantity > 10)
    total = quantity * unit_price * 0.95;
  else
    total = quantity * unit_price;
  printf("The price for %d is $%.2f\n", quantity, total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0xa,-0x14(%rbp)
jle    119a <main+0x7a>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe80(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11b0 <main+0x90>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cvtsi2sd %esi,%xmm0
mulsd  0xea8(%rip),%xmm0
cmp    $0xb,%esi
jl     1165 <main+0x45>
mulsd  0xea3(%rip),%xmm0
lea    0xed1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter the number that you want to buy : \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [27 x i8] c"The price for %d is $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store double 3.500000e+00, double* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store double 0.000000e+00, double* %4
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 10
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 3.500000e+00
%13 = fmul double %12, 0x3FEE666666666666
store double %13, double* %4
br label %18
14: ; preds = %0
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = fmul double %16, 3.500000e+00
store double %17, double* %4
br label %18
18: ; preds = %14, %9
%19 = load i32, i32* %3
%20 = load double, double* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %19, double %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter the number that you want to buy : \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [27 x i8] c"The price for %d is $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 10
%7 = sitofp i32 %5 to double
%8 = fmul double %7, 3.500000e+00
%9 = fmul double %8, 0x3FEE666666666666
%10 = select i1 %6, double %9, double %8
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %5, double %10)
ret i32 0
}