#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 main() {
  unsigned int width, height;
  float cost, tile_size;
  printf("Please input the floor width: ");
  scanf("%d", &width);
  printf("Please input the floor height: ");
  scanf("%d", &height);
  printf("Please input the tile width and height: ");
  scanf("%f", &tile_size);
  printf("Please input a single tile's cost: ");
  scanf("%f", &cost);
  unsigned int floor_area = width * height;
  float tile_area = tile_size * tile_size;
  float total_cost = cost * (float)(floor_area / tile_area);
  printf("The cost to cover %d square units of floor area using a tile with "
         "area %.2f is: %.2f\n",
         floor_area, tile_area, total_cost);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xed5(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xedc(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%eax
cvtsi2ss %rax,%xmm1
divss  -0x1c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%esi
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe86(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef0(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
movss  (%rsp),%xmm0
mulss  %xmm0,%xmm0
cvtsi2ss %rsi,%xmm1
divss  %xmm0,%xmm1
mulss  0x4(%rsp),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xebd(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Please input the floor width: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Please input the floor height: \00"
@.str.3 = [41 x i8] c"Please input the tile width and height: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [36 x i8] c"Please input a single tile's cost: \00"
@.str.6 = [86 x i8] c"The cost to cover %d square units of floor area using a tile with area %.2f is: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = mul i32 %17, %18
store i32 %19, i32* %6
%20 = load float, float* %5
%21 = load float, float* %5
%22 = fmul float %20, %21
store float %22, float* %7
%23 = load float, float* %4
%24 = load i32, i32* %6
%25 = uitofp i32 %24 to float
%26 = load float, float* %7
%27 = fdiv float %25, %26
%28 = fmul float %23, %27
store float %28, float* %8
%29 = load i32, i32* %6
%30 = load float, float* %7
%31 = fpext float %30 to double
%32 = load float, float* %8
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.6, i64 0, i64 0), i32 %29, double %31, double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Please input the floor width: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Please input the floor height: \00"
@.str.3 = [41 x i8] c"Please input the tile width and height: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [36 x i8] c"Please input a single tile's cost: \00"
@.str.6 = [86 x i8] c"The cost to cover %d square units of floor area using a tile with area %.2f is: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = mul i32 %18, %17
%20 = load float, float* %4
%21 = fmul float %20, %20
%22 = load float, float* %3
%23 = uitofp i32 %19 to float
%24 = fdiv float %23, %21
%25 = fmul float %22, %24
%26 = fpext float %21 to double
%27 = fpext float %25 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.6, i64 0, i64 0), i32 %19, double %26, double %27)
ret i32 0
}