#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 */
float CConvertToF(float);
float FConvertToC(float);
float addition(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float valueA, valueB;
  char unit;
  float resultC, resultF, resultTemp;
  printf("Please insert value A: ");
  scanf("%f", &valueA);
  printf("Please insert value B: ");
  scanf("%f", &valueB);
  printf("C=Celius, F=Fahrenheit\n");
  printf("Please insert the unit: ");
  scanf("%s", &unit);
  resultTemp = addition(valueA, valueB);
  if (unit == 'F') {
    resultF = resultTemp;
    resultC = FConvertToC(resultTemp);
  } else {
    resultC = resultTemp;
    resultF = CConvertToF(resultTemp);
  }
  printf("The addition in Celsius is %.2f\n", resultC);
  printf("The addition in Fahrenheit is %.2f\n", resultF);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <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   1050 <printf@plt>
lea    0xe84(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1040 <addition@plt>
movss  %xmm0,-0x1c(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x46,%eax
jne    120c <main+0xbc>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1070 <FConvertToC@plt>
movss  %xmm0,-0x14(%rbp)
jmp    1225 <main+0xd5>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <CConvertToF@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9e(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xee7(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe85(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <addition@plt>
cmpb   $0x46,0x3(%rsp)
movss  %xmm0,0x4(%rsp)
jne    11f8 <main+0x98>
call   1080 <FConvertToC@plt>
jmp    120c <main+0xac>
call   1030 <CConvertToF@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
movss  %xmm1,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Please insert value A: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [24 x i8] c"Please insert value B: \00"
@.str.3 = [24 x i8] c"C=Celius, F=Fahrenheit\0A\00"
@.str.4 = [25 x i8] c"Please insert the unit: \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [33 x i8] c"The addition in Celsius is %.2f\0A\00"
@.str.7 = [36 x i8] c"The addition in Fahrenheit is %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i8
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%15 = load float, float* %2
%16 = load float, float* %3
%17 = call float @addition(float %15, float %16)
store float %17, float* %7
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 70
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = load float, float* %7
store float %22, float* %6
%23 = load float, float* %7
%24 = call float @FConvertToC(float %23)
store float %24, float* %5
br label %29
25: ; preds = %0
%26 = load float, float* %7
store float %26, float* %5
%27 = load float, float* %7
%28 = call float @CConvertToF(float %27)
store float %28, float* %6
br label %29
29: ; preds = %25, %21
%30 = load float, float* %5
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %31)
%33 = load float, float* %6
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), double %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please insert value A: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [24 x i8] c"Please insert value B: \00"
@.str.4 = [25 x i8] c"Please insert the unit: \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [33 x i8] c"The addition in Celsius is %.2f\0A\00"
@.str.7 = [36 x i8] c"The addition in Fahrenheit is %.2f\0A\00"
@str = [23 x i8] c"C=Celius, F=Fahrenheit\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%13 = load float, float* %1
%14 = load float, float* %2
%15 = call float @addition(float %13, float %14)
%16 = load i8, i8* %3
%17 = icmp eq i8 %16, 70
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call float @FConvertToC(float %15)
br label %22
20: ; preds = %0
%21 = call float @CConvertToF(float %15)
br label %22
22: ; preds = %20, %18
%23 = phi float [ %19, %18 ], [ %15, %20 ]
%24 = phi float [ %15, %18 ], [ %21, %20 ]
%25 = fpext float %23 to double
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %25)
%27 = fpext float %24 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), double %27)
ret i32 0
}