#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 convertCurrency(float, int, int);
int /*<<< orphan*/ initCurrencies();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int selectCurrencyFromList();
int /*<<< orphan*/ system(char *);
int main() {
  int selectedFromCurrency, selectedToCurrency;
  float value, answer;
  initCurrencies();
  printf("Please select a currency: \n");
  selectedFromCurrency = selectCurrencyFromList();
  printf("Please input the value you want to convert:\n");
  scanf("%f", &value);
  printf("Please select a currency to convert to: \n");
  selectedToCurrency = selectCurrencyFromList();
  answer = convertCurrency(value, selectedFromCurrency, selectedToCurrency);
  printf("Answer is: %8.2f\n", answer);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <initCurrencies@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <selectCurrencyFromList@plt>
mov    %eax,-0x8(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <selectCurrencyFromList@plt>
mov    %eax,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <convertCurrency@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe91(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <initCurrencies@plt>
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <selectCurrencyFromList@plt>
mov    %eax,%ebx
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <selectCurrencyFromList@plt>
movss  0xc(%rsp),%xmm0
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <convertCurrency@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe2c(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please select a currency: \0A\00"
@.str.1 = [45 x i8] c"Please input the value you want to convert:\0A\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [42 x i8] c"Please select a currency to convert to: \0A\00"
@.str.4 = [18 x i8] c"Answer is: %8.2f\0A\00"
@.str.5 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (...) @initCurrencies()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @selectCurrencyFromList()
store i32 %8, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (...) @selectCurrencyFromList()
store i32 %12, i32* %3
%13 = load float, float* %4
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call float @convertCurrency(float %13, i32 %14, i32 %15)
store float %16, float* %5
%17 = load float, float* %5
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %18)
%20 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%f\00"
@.str.4 = [18 x i8] c"Answer is: %8.2f\0A\00"
@.str.5 = [6 x i8] c"PAUSE\00"
@str = [27 x i8] c"Please select a currency: \00"
@str.6 = [44 x i8] c"Please input the value you want to convert:\00"
@str.7 = [41 x i8] c"Please select a currency to convert to: \00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (...) @initCurrencies()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @selectCurrencyFromList()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
%9 = call i32 (...) @selectCurrencyFromList()
%10 = load float, float* %1
%11 = call float @convertCurrency(float %10, i32 %5, i32 %9)
%12 = fpext float %11 to double
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %12)
%14 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}