#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*/ circlearea(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ trianglearea(int, int);
int main() {
  int option, r, h, b;
  float result;
  printf("select your option \n");
  printf("1. calculate area of a circle \n");
  printf("2. calculate area of a triangle \n");
  scanf("%d", &option);
  switch (option) {
  case 1:
    printf("enter the radius of the circle \n");
    scanf("%d", &r);
    circlearea(r);
    printf("the area is \n %d", result);
    break;
  case 2:
    printf("enter the height and breadth of the triangle \n");
    scanf("%d%d", &h, &b);
    trianglearea(h, b);
    printf("the area is \n %d", result);
    break;
  default:
    printf("invalid option");
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1d(%rbp)
call   1040 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xefe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11b6 <main+0x76>
jmp    11a5 <main+0x65>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11fa <main+0xba>
jmp    1245 <main+0x105>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1030 <circlearea@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1253 <main+0x113>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <trianglearea@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1253 <main+0x113>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     11c3 <main+0x73>
cmp    $0x1,%eax
jne    1204 <main+0xb4>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1040 <circlearea@plt>
jmp    11f4 <main+0xa4>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3b(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
call   1060 <trianglearea@plt>
lea    0xe05(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1212 <main+0xc2>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"select your option \0A\00"
@.str.1 = [32 x i8] c"1. calculate area of a circle \0A\00"
@.str.2 = [34 x i8] c"2. calculate area of a triangle \0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [33 x i8] c"enter the radius of the circle \0A\00"
@.str.5 = [17 x i8] c"the area is \0A %d\00"
@.str.6 = [47 x i8] c"enter the height and breadth of the triangle \0A\00"
@.str.7 = [5 x i8] c"%d%d\00"
@.str.8 = [15 x i8] c"invalid option\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
switch i32 %11, label %29 [
i32 1, label %12
i32 2, label %20
]
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = call i32 @circlearea(i32 %15)
%17 = load float, float* %6
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %18)
br label %31
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %4, i32* %5)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 @trianglearea(i32 %23, i32 %24)
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %27)
br label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %31
31: ; preds = %29, %20, %12
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [17 x i8] c"the area is \0A %d\00"
@.str.7 = [5 x i8] c"%d%d\00"
@.str.8 = [15 x i8] c"invalid option\00"
@str = [20 x i8] c"select your option \00"
@str.9 = [31 x i8] c"1. calculate area of a circle \00"
@str.10 = [33 x i8] c"2. calculate area of a triangle \00"
@str.11 = [46 x i8] c"enter the height and breadth of the triangle \00"
@str.12 = [32 x i8] c"enter the radius of the circle \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, 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* %1)
%13 = load i32, i32* %1
switch i32 %13, label %27 [
i32 1, label %14
i32 2, label %20
]
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, 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* %2)
%17 = load i32, i32* %2
%18 = call i32 @circlearea(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double undef)
br label %29
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.11, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %3, i32* %4)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @trianglearea(i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double undef)
br label %29
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %29
29: ; preds = %27, %20, %14
ret i32 0
}