#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *, int *);
int main() {
  char currency;
  int money;
  printf("Please input the price:\n");
  scanf("%1c%d", &currency, &money);
  switch (currency) {
  case '$':
    money *= 6;
    break;
  case 'E':
    money *= 8;
    break;
  default:
    printf("Error!\n");
    break;
  }
  currency = 'Y';
  printf("price=%c%d\n", currency, money);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x24,%eax
je     1177 <main+0x57>
jmp    1166 <main+0x46>
mov    -0x10(%rbp),%eax
sub    $0x45,%eax
je     1183 <main+0x63>
jmp    1191 <main+0x71>
imul   $0x6,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    119f <main+0x7f>
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    119f <main+0x7f>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x59,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x3(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1050 <scanf@plt>
movsbl 0x3(%rsp),%eax
cmp    $0x45,%eax
je     1171 <main+0x41>
cmp    $0x24,%eax
jne    117e <main+0x4e>
mov    0x4(%rsp),%eax
add    %eax,%eax
lea    (%rax,%rax,2),%edx
mov    %edx,0x4(%rsp)
jmp    118e <main+0x5e>
mov    0x4(%rsp),%edx
shl    $0x3,%edx
mov    %edx,0x4(%rsp)
jmp    118e <main+0x5e>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edx
movb   $0x59,0x3(%rsp)
lea    0xe6c(%rip),%rdi
mov    $0x59,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please input the price:\0A\00"
@.str.1 = [6 x i8] c"%1c%d\00"
@.str.2 = [8 x i8] c"Error!\0A\00"
@.str.3 = [12 x i8] c"price=%c%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32* %3)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
switch i32 %7, label %14 [
i32 36, label %8
i32 69, label %11
]
8: ; preds = %0
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, 6
store i32 %10, i32* %3
br label %16
11: ; preds = %0
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, 8
store i32 %13, i32* %3
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11, %8
store i8 89, i8* %2
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%1c%d\00"
@.str.3 = [12 x i8] c"price=%c%d\0A\00"
@str = [24 x i8] c"Please input the price:\00"
@str.4 = [7 x i8] c"Error!\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32* %2)
%6 = load i8, i8* %1
%7 = sext i8 %6 to i32
switch i32 %7, label %14 [
i32 36, label %8
i32 69, label %11
]
8: ; preds = %0
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 6
store i32 %10, i32* %2
br label %17
11: ; preds = %0
%12 = load i32, i32* %2
%13 = shl nsw i32 %12, 3
store i32 %13, i32* %2
br label %17
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.4, i64 0, i64 0))
%16 = load i32, i32* %2
br label %17
17: ; preds = %14, %11, %8
%18 = phi i32 [ %16, %14 ], [ %13, %11 ], [ %10, %8 ]
store i8 89, i8* %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 89, i32 %18)
ret i32 0
}