#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 *, ...);
void main() {
  int r, l, b, a, j, k, ch, area;
  printf("\n\n ----MENU---- \n\n");
  printf(" AREA OF:\n 1.CIRCLE\n 2.RECTANGLE\n 3.SQUARE\n 4.TRIANGLE\n");
  printf("\n\n ENTER YOUR CHOICE \n\n");
  scanf("%d", &ch);
  switch (ch) {
  case 1:
    printf("\n\n ENTER RADIUS: \n");
    scanf("%d", &r);
    area = 3.14 * r * r;
    printf("\n\n AREA: %d", area);
    break;
  case 2:
    printf("\n\n ENTER LENGTH AND BREADTH : \n");
    scanf("%d %d", &l, &b);
    area = l * b;
    printf("\n\n AREA: %d", area);
    break;
  case 3:
    printf("\n\n ENTER SIDE : \n");
    scanf("%d", &a);
    area = a * a;
    printf("\n\n AREA: %d", area);
    break;
  case 4:
    printf("\n\n ENTER BASE AND HEIGHT : \n");
    scanf("%d %d", &j, &k);
    area = 0.5 * j * k;
    printf("\n\n AREA: %d", area);
    break;
  default:
    printf("\n\n ----WRONG INPUT---- \n\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xef1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xef0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xf3e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     12c9 <main+0x1a9>
mov    -0x28(%rbp),%rax
lea    0xe86(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe48(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x1b7>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x1b7>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x1b7>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xd61(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d7 <main+0x1b7>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xeca(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11bd <main+0x8d>
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf50(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2sdl 0xc(%rsp),%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm0,%xmm1
jmp    125d <main+0x12d>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4b(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%esi
imul   0xc(%rsp),%esi
jmp    1265 <main+0x135>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xe19(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
imul   %esi,%esi
jmp    1265 <main+0x135>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf4(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2sdl 0xc(%rsp),%xmm0
mulsd  0xda9(%rip),%xmm0
cvtsi2sdl 0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
lea    0xdb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0A\0A ----MENU---- \0A\0A\00"
@.str.1 = [56 x i8] c" AREA OF:\0A 1.CIRCLE\0A 2.RECTANGLE\0A 3.SQUARE\0A 4.TRIANGLE\0A\00"
@.str.2 = [24 x i8] c"\0A\0A ENTER YOUR CHOICE \0A\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [19 x i8] c"\0A\0A ENTER RADIUS: \0A\00"
@.str.5 = [12 x i8] c"\0A\0A AREA: %d\00"
@.str.6 = [32 x i8] c"\0A\0A ENTER LENGTH AND BREADTH : \0A\00"
@.str.7 = [6 x i8] c"%d %d\00"
@.str.8 = [18 x i8] c"\0A\0A ENTER SIDE : \0A\00"
@.str.9 = [29 x i8] c"\0A\0A ENTER BASE AND HEIGHT : \0A\00"
@.str.10 = [26 x i8] c"\0A\0A ----WRONG INPUT---- \0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%13 = load i32, i32* %7
switch i32 %13, label %54 [
i32 1, label %14
i32 2, label %26
i32 3, label %34
i32 4, label %42
]
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%17 = load i32, i32* %1
%18 = sitofp i32 %17 to double
%19 = fmul double 3.140000e+00, %18
%20 = load i32, i32* %1
%21 = sitofp i32 %20 to double
%22 = fmul double %19, %21
%23 = fptosi double %22 to i32
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %24)
br label %56
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32* %2, i32* %3)
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = mul nsw i32 %29, %30
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %56
34: ; preds = %0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%37 = load i32, i32* %4
%38 = load i32, i32* %4
%39 = mul nsw i32 %37, %38
store i32 %39, i32* %8
%40 = load i32, i32* %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %56
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%44 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32* %5, i32* %6)
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to double
%47 = fmul double 5.000000e-01, %46
%48 = load i32, i32* %6
%49 = sitofp i32 %48 to double
%50 = fmul double %47, %49
%51 = fptosi double %50 to i32
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %56
56: ; preds = %54, %42, %34, %26, %14
ret void
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [12 x i8] c"\0A\0A AREA: %d\00"
@.str.7 = [6 x i8] c"%d %d\00"
@str = [18 x i8] c"\0A\0A ----MENU---- \0A\00"
@str.11 = [55 x i8] c" AREA OF:\0A 1.CIRCLE\0A 2.RECTANGLE\0A 3.SQUARE\0A 4.TRIANGLE\00"
@str.12 = [23 x i8] c"\0A\0A ENTER YOUR CHOICE \0A\00"
@str.13 = [28 x i8] c"\0A\0A ENTER BASE AND HEIGHT : \00"
@str.14 = [17 x i8] c"\0A\0A ENTER SIDE : \00"
@str.15 = [31 x i8] c"\0A\0A ENTER LENGTH AND BREADTH : \00"
@str.16 = [18 x i8] c"\0A\0A ENTER RADIUS: \00"
@str.17 = [25 x i8] c"\0A\0A ----WRONG INPUT---- \0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.11, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%19 = load i32, i32* %7
switch i32 %19, label %53 [
i32 1, label %20
i32 2, label %29
i32 3, label %36
i32 4, label %42
]
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 3.140000e+00
%26 = fmul double %25, %24
%27 = fptosi double %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %55
29: ; preds = %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32* %2, i32* %3)
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = mul nsw i32 %33, %32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %55
36: ; preds = %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
%38 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%39 = load i32, i32* %4
%40 = mul nsw i32 %39, %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %55
42: ; preds = %0
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
%44 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32* %5, i32* %6)
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to double
%47 = fmul double %46, 5.000000e-01
%48 = load i32, i32* %6
%49 = sitofp i32 %48 to double
%50 = fmul double %47, %49
%51 = fptosi double %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %51)
br label %55
53: ; preds = %0
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
br label %55
55: ; preds = %53, %42, %36, %29, %20
ret void
}