#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 */
double cos(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
double sin(float);
char tolower(char);
int main() {
  float t;
  char a = 'a';
  printf("Enter the Vaule of Radian: ");
  scanf("%f", &t);
  printf("Enter the Trignometric Function to be performed: ");
  scanf("%s", &a);
  a = tolower(a);
  printf("Part 1: \n");
  if (a == 's')
    printf("sin(%.2f) = %.2f \n", t, sin(t));
  else if (a == 'c')
    printf("cos(%.2f) = %.2f \n", t, cos(t));
  else
    printf("Wrong Input \n");
  printf("Part 2: \n");
  switch (a) {
  case 's':
    printf("sin(%.2f) = %.2f \n", t, sin(t));
    break;
  case 'c':
    printf("cos(%.2f) = %.2f \n", t, cos(t));
    break;
  default:
    printf("Wrong Input \n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x61,-0x9(%rbp)
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x9(%rbp),%edi
call   1050 <tolower@plt>
mov    %al,-0x9(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x73,%eax
jne    11fd <main+0xad>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1250 <main+0x100>
movsbl -0x9(%rbp),%eax
cmp    $0x63,%eax
jne    123d <main+0xed>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    124b <main+0xfb>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1250 <main+0x100>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl -0x9(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x63,%eax
je     12b7 <main+0x167>
jmp    1273 <main+0x123>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
jne    12ea <main+0x19a>
jmp    1284 <main+0x134>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12f8 <main+0x1a8>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x8(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
lea    0xd93(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12f8 <main+0x1a8>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movb   $0x61,0xb(%rsp)
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsbl 0xb(%rsp),%edi
call   1060 <tolower@plt>
mov    %al,0xb(%rsp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
mov    0xb(%rsp),%al
cmp    $0x63,%al
je     11f2 <main+0x92>
cmp    $0x73,%al
jne    1220 <main+0xc0>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1050 <sin@plt>
movaps %xmm0,%xmm1
lea    0xe64(%rip),%rdi
jmp    1211 <main+0xb1>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1080 <cos@plt>
movaps %xmm0,%xmm1
lea    0xe56(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
jmp    122c <main+0xcc>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
movsbl 0xb(%rsp),%eax
cmp    $0x63,%eax
je     126b <main+0x10b>
cmp    $0x73,%eax
jne    129c <main+0x13c>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1050 <sin@plt>
movaps %xmm0,%xmm1
lea    0xdeb(%rip),%rdi
jmp    128d <main+0x12d>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1080 <cos@plt>
movaps %xmm0,%xmm1
lea    0xdda(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
jmp    12a8 <main+0x148>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the Vaule of Radian: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [50 x i8] c"Enter the Trignometric Function to be performed: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [10 x i8] c"Part 1: \0A\00"
@.str.5 = [19 x i8] c"sin(%.2f) = %.2f \0A\00"
@.str.6 = [19 x i8] c"cos(%.2f) = %.2f \0A\00"
@.str.7 = [14 x i8] c"Wrong Input \0A\00"
@.str.8 = [10 x i8] c"Part 2: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i8
store i32 0, i32* %1
store i8 97, i8* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%8 = load i8, i8* %3
%9 = call signext i8 @tolower(i8 signext %8)
store i8 %9, i8* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 115
br i1 %13, label %14, label %20
14: ; preds = %0
%15 = load float, float* %2
%16 = fpext float %15 to double
%17 = load float, float* %2
%18 = call double @sin(float %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %16, double %18)
br label %33
20: ; preds = %0
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 99
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load float, float* %2
%26 = fpext float %25 to double
%27 = load float, float* %2
%28 = call double @cos(float %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %26, double %28)
br label %32
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
br label %33
33: ; preds = %32, %14
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%35 = load i8, i8* %3
%36 = sext i8 %35 to i32
switch i32 %36, label %49 [
i32 115, label %37
i32 99, label %43
]
37: ; preds = %33
%38 = load float, float* %2
%39 = fpext float %38 to double
%40 = load float, float* %2
%41 = call double @sin(float %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %39, double %41)
br label %51
43: ; preds = %33
%44 = load float, float* %2
%45 = fpext float %44 to double
%46 = load float, float* %2
%47 = call double @cos(float %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %45, double %47)
br label %51
49: ; preds = %33
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %49, %43, %37
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the Vaule of Radian: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [50 x i8] c"Enter the Trignometric Function to be performed: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.5 = [19 x i8] c"sin(%.2f) = %.2f \0A\00"
@.str.6 = [19 x i8] c"cos(%.2f) = %.2f \0A\00"
@str = [9 x i8] c"Part 1: \00"
@str.10 = [9 x i8] c"Part 2: \00"
@str.11 = [13 x i8] c"Wrong Input \00"
define i32 @main() {
%1 = alloca float
%2 = alloca i8
%3 = bitcast float* %1 to i8*
store i8 97, i8* %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = call signext i8 @tolower(i8 signext %8)
store i8 %9, i8* %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%11 = load i8, i8* %2
switch i8 %11, label %22 [
i8 115, label %12
i8 99, label %17
]
12: ; preds = %0
%13 = load float, float* %1
%14 = fpext float %13 to double
%15 = call double @sin(float %13)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %14, double %15)
br label %24
17: ; preds = %0
%18 = load float, float* %1
%19 = fpext float %18 to double
%20 = call double @cos(float %18)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %19, double %20)
br label %24
22: ; preds = %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %24
24: ; preds = %17, %22, %12
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.10, i64 0, i64 0))
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
switch i32 %27, label %38 [
i32 115, label %28
i32 99, label %33
]
28: ; preds = %24
%29 = load float, float* %1
%30 = fpext float %29 to double
%31 = call double @sin(float %29)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %30, double %31)
br label %40
33: ; preds = %24
%34 = load float, float* %1
%35 = fpext float %34 to double
%36 = call double @cos(float %34)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %35, double %36)
br label %40
38: ; preds = %24
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %40
40: ; preds = %38, %33, %28
ret i32 0
}