#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 *, double);
int /*<<< orphan*/ scanf(char *, double *, char *, char *);
int main(void) {
  double amount;
  char fromUnit, toUnit;
  int from = 0, to = 0;
  scanf("%lf %c %c", &amount, &fromUnit, &toUnit);
  if (fromUnit == 'i')
    from = 1;
  else if (fromUnit == 'f')
    from = 2;
  else if (fromUnit == 'y')
    from = 3;
  else if (fromUnit == 'm')
    from = 4;
  else
    from = 0;
  if (toUnit == 'i')
    to = 1;
  else if (toUnit == 'f')
    to = 2;
  else if (toUnit == 'y')
    to = 3;
  else if (toUnit == 'm')
    to = 4;
  else
    to = 0;
  while (1) {
    if (from == to) {
      printf("%.6lf\n", amount);
      return 0;
    }
    if (to > from) {
      switch (from) {
      case 1:
        amount /= 12;
        from++;
        break;
      case 2:
        amount /= 3;
        from++;
        break;
      case 3:
        amount /= 1760;
        from++;
        break;
      default:
        from = to;
        break;
      }
    } else {
      switch (from) {
      case 4:
        amount *= 1760;
        from--;
        break;
      case 3:
        amount *= 3;
        from--;
        break;
      case 2:
        amount *= 12;
        from--;
        break;
      default:
        from = to;
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xed4(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x11(%rbp),%rdx
lea    -0x12(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x69,%eax
jne    116e <main+0x4e>
movl   $0x1,-0x18(%rbp)
jmp    11cf <main+0xaf>
movsbl -0x11(%rbp),%eax
cmp    $0x66,%eax
jne    1187 <main+0x67>
movl   $0x2,-0x18(%rbp)
jmp    11ca <main+0xaa>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
jne    11a0 <main+0x80>
movl   $0x3,-0x18(%rbp)
jmp    11c5 <main+0xa5>
movsbl -0x11(%rbp),%eax
cmp    $0x6d,%eax
jne    11b9 <main+0x99>
movl   $0x4,-0x18(%rbp)
jmp    11c0 <main+0xa0>
movl   $0x0,-0x18(%rbp)
jmp    11c5 <main+0xa5>
jmp    11ca <main+0xaa>
jmp    11cf <main+0xaf>
movsbl -0x12(%rbp),%eax
cmp    $0x69,%eax
jne    11e8 <main+0xc8>
movl   $0x1,-0x1c(%rbp)
jmp    1249 <main+0x129>
movsbl -0x12(%rbp),%eax
cmp    $0x66,%eax
jne    1201 <main+0xe1>
movl   $0x2,-0x1c(%rbp)
jmp    1244 <main+0x124>
movsbl -0x12(%rbp),%eax
cmp    $0x79,%eax
jne    121a <main+0xfa>
movl   $0x3,-0x1c(%rbp)
jmp    123f <main+0x11f>
movsbl -0x12(%rbp),%eax
cmp    $0x6d,%eax
jne    1233 <main+0x113>
movl   $0x4,-0x1c(%rbp)
jmp    123a <main+0x11a>
movl   $0x0,-0x1c(%rbp)
jmp    123f <main+0x11f>
jmp    1244 <main+0x124>
jmp    1249 <main+0x129>
jmp    124e <main+0x12e>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1273 <main+0x153>
movsd  -0x10(%rbp),%xmm0
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    132c <main+0x20c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     12b5 <main+0x195>
jmp    1293 <main+0x173>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     12d9 <main+0x1b9>
jmp    12a4 <main+0x184>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     12fd <main+0x1dd>
jmp    1321 <main+0x201>
movsd  -0x10(%rbp),%xmm0
movsd  0xd3e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1327 <main+0x207>
movsd  -0x10(%rbp),%xmm0
movsd  0xd22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1327 <main+0x207>
movsd  -0x10(%rbp),%xmm0
movsd  0xd06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1327 <main+0x207>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13cd <main+0x2ad>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2,%eax
je     13a2 <main+0x282>
jmp    1340 <main+0x220>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     1382 <main+0x262>
jmp    1351 <main+0x231>
mov    -0x24(%rbp),%eax
sub    $0x4,%eax
jne    13c2 <main+0x2a2>
jmp    1362 <main+0x242>
movsd  0xca6(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    13c8 <main+0x2a8>
movsd  0xc7e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    13c8 <main+0x2a8>
movsd  0xc56(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    13c8 <main+0x2a8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    13cd <main+0x2ad>
jmp    124e <main+0x12e>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf8d(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0xe(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xf(%rsp),%cl
add    $0x9a,%cl
cmp    $0x13,%cl
ja     116a <main+0x4a>
mov    $0x1,%eax
movzbl %cl,%ecx
lea    0xebe(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x2,%eax
jmp    117a <main+0x5a>
xor    %eax,%eax
jmp    117a <main+0x5a>
mov    $0x4,%eax
jmp    117a <main+0x5a>
mov    $0x3,%eax
mov    0xe(%rsp),%dl
add    $0x9a,%dl
cmp    $0x13,%dl
ja     11a5 <main+0x85>
mov    $0x1,%ecx
movzbl %dl,%edx
lea    0xed3(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x2,%ecx
jmp    11b5 <main+0x95>
xor    %ecx,%ecx
jmp    11b5 <main+0x95>
mov    $0x4,%ecx
jmp    11b5 <main+0x95>
mov    $0x3,%ecx
movsd  0x10(%rsp),%xmm0
cmp    %ecx,%eax
jne    11d2 <main+0xb2>
lea    0xefc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
movsd  0xe36(%rip),%xmm1
movsd  0xe26(%rip),%xmm2
movsd  0xe16(%rip),%xmm3
jmp    1204 <main+0xe4>
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%eax
nopl   0x0(%rax,%rax,1)
cmp    %ecx,%eax
je     11bf <main+0x9f>
cmp    %eax,%ecx
jbe    1220 <main+0x100>
cmp    $0x3,%eax
je     1235 <main+0x115>
cmp    $0x2,%eax
je     1246 <main+0x126>
cmp    $0x1,%eax
jne    11bf <main+0x9f>
divsd  %xmm3,%xmm0
jmp    125b <main+0x13b>
nopl   (%rax)
cmp    $0x2,%eax
je     11ec <main+0xcc>
cmp    $0x3,%eax
je     1257 <main+0x137>
cmp    $0x4,%eax
jne    11bf <main+0x9f>
mulsd  %xmm1,%xmm0
jmp    124a <main+0x12a>
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x4,%eax
jmp    1200 <main+0xe0>
divsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x3,%eax
jmp    1200 <main+0xe0>
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%eax
jmp    1200 <main+0xe0>

LLVM IR (-O0):
@.str = [10 x i8] c"%lf %c %c\00"
@.str.1 = [7 x i8] c"%.6lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double* %2, i8* %3, i8* %4)
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 105
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 1, i32* %5
br label %31
12: ; preds = %0
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 102
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 2, i32* %5
br label %30
17: ; preds = %12
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 121
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 3, i32* %5
br label %29
22: ; preds = %17
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 109
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 4, i32* %5
br label %28
27: ; preds = %22
store i32 0, i32* %5
br label %28
28: ; preds = %27, %26
br label %29
29: ; preds = %28, %21
br label %30
30: ; preds = %29, %16
br label %31
31: ; preds = %30, %11
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 105
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %6
br label %55
36: ; preds = %31
%37 = load i8, i8* %4
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 102
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 2, i32* %6
br label %54
41: ; preds = %36
%42 = load i8, i8* %4
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 121
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 3, i32* %6
br label %53
46: ; preds = %41
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 109
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 4, i32* %6
br label %52
51: ; preds = %46
store i32 0, i32* %6
br label %52
52: ; preds = %51, %50
br label %53
53: ; preds = %52, %45
br label %54
54: ; preds = %53, %40
br label %55
55: ; preds = %54, %35
br label %56
56: ; preds = %55, %107
%57 = load i32, i32* %5
%58 = load i32, i32* %6
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load double, double* %2
%62 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %61)
ret i32 0
63: ; preds = %56
%64 = load i32, i32* %6
%65 = load i32, i32* %5
%66 = icmp sgt i32 %64, %65
br i1 %66, label %67, label %87
67: ; preds = %63
%68 = load i32, i32* %5
switch i32 %68, label %84 [
i32 1, label %69
i32 2, label %74
i32 3, label %79
]
69: ; preds = %67
%70 = load double, double* %2
%71 = fdiv double %70, 1.200000e+01
store double %71, double* %2
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
store i32 %73, i32* %5
br label %86
74: ; preds = %67
%75 = load double, double* %2
%76 = fdiv double %75, 3.000000e+00
store double %76, double* %2
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
store i32 %78, i32* %5
br label %86
79: ; preds = %67
%80 = load double, double* %2
%81 = fdiv double %80, 1.760000e+03
store double %81, double* %2
%82 = load i32, i32* %5
%83 = add nsw i32 %82, 1
store i32 %83, i32* %5
br label %86
84: ; preds = %67
%85 = load i32, i32* %6
store i32 %85, i32* %5
br label %86
86: ; preds = %84, %79, %74, %69
br label %107
87: ; preds = %63
%88 = load i32, i32* %5
switch i32 %88, label %104 [
i32 4, label %89
i32 3, label %94
i32 2, label %99
]
89: ; preds = %87
%90 = load double, double* %2
%91 = fmul double %90, 1.760000e+03
store double %91, double* %2
%92 = load i32, i32* %5
%93 = add nsw i32 %92, -1
store i32 %93, i32* %5
br label %106
94: ; preds = %87
%95 = load double, double* %2
%96 = fmul double %95, 3.000000e+00
store double %96, double* %2
%97 = load i32, i32* %5
%98 = add nsw i32 %97, -1
store i32 %98, i32* %5
br label %106
99: ; preds = %87
%100 = load double, double* %2
%101 = fmul double %100, 1.200000e+01
store double %101, double* %2
%102 = load i32, i32* %5
%103 = add nsw i32 %102, -1
store i32 %103, i32* %5
br label %106
104: ; preds = %87
%105 = load i32, i32* %6
store i32 %105, i32* %5
br label %106
106: ; preds = %104, %99, %94, %89
br label %107
107: ; preds = %106, %86
br label %56
}

LLVM IR (-O2):
@.str = [10 x i8] c"%lf %c %c\00"
@.str.1 = [7 x i8] c"%.6lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i8
%3 = alloca i8
%4 = bitcast double* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double* %1, i8* %2, i8* %3)
%6 = load i8, i8* %2
switch i8 %6, label %10 [
i8 105, label %11
i8 102, label %7
i8 121, label %8
i8 109, label %9
]
7: ; preds = %0
br label %11
8: ; preds = %0
br label %11
9: ; preds = %0
br label %11
10: ; preds = %0
br label %11
11: ; preds = %0, %7, %9, %10, %8
%12 = phi i32 [ 2, %7 ], [ 3, %8 ], [ 4, %9 ], [ 0, %10 ], [ 1, %0 ]
%13 = load i8, i8* %3
switch i8 %13, label %17 [
i8 105, label %18
i8 102, label %14
i8 121, label %15
i8 109, label %16
]
14: ; preds = %11
br label %18
15: ; preds = %11
br label %18
16: ; preds = %11
br label %18
17: ; preds = %11
br label %18
18: ; preds = %11, %14, %16, %17, %15
%19 = phi i32 [ 2, %14 ], [ 3, %15 ], [ 4, %16 ], [ 0, %17 ], [ 1, %11 ]
%20 = load double, double* %1
%21 = icmp eq i32 %12, %19
br i1 %21, label %22, label %25
22: ; preds = %36, %29, %43, %18
%23 = phi double [ %20, %18 ], [ %27, %36 ], [ %27, %29 ], [ %44, %43 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %23)
ret i32 0
25: ; preds = %18, %43
%26 = phi i32 [ %45, %43 ], [ %12, %18 ]
%27 = phi double [ %44, %43 ], [ %20, %18 ]
%28 = icmp ugt i32 %19, %26
br i1 %28, label %29, label %36
29: ; preds = %25
switch i32 %26, label %22 [
i32 1, label %30
i32 2, label %32
i32 3, label %34
]
30: ; preds = %29
%31 = fdiv double %27, 1.200000e+01
store double %31, double* %1
br label %43
32: ; preds = %29
%33 = fdiv double %27, 3.000000e+00
store double %33, double* %1
br label %43
34: ; preds = %29
%35 = fdiv double %27, 1.760000e+03
store double %35, double* %1
br label %43
36: ; preds = %25
switch i32 %26, label %22 [
i32 4, label %37
i32 3, label %39
i32 2, label %41
]
37: ; preds = %36
%38 = fmul double %27, 1.760000e+03
store double %38, double* %1
br label %43
39: ; preds = %36
%40 = fmul double %27, 3.000000e+00
store double %40, double* %1
br label %43
41: ; preds = %36
%42 = fmul double %27, 1.200000e+01
store double %42, double* %1
br label %43
43: ; preds = %37, %39, %41, %30, %32, %34
%44 = phi double [ %35, %34 ], [ %33, %32 ], [ %31, %30 ], [ %42, %41 ], [ %40, %39 ], [ %38, %37 ]
%45 = phi i32 [ 4, %34 ], [ 3, %32 ], [ 2, %30 ], [ 1, %41 ], [ 2, %39 ], [ 3, %37 ]
%46 = icmp eq i32 %45, %19
br i1 %46, label %22, label %25
}