#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
void main() {
  char ch;
  int f, a = 10, b = 20;
  double e, c = 10.0, d = 20.0;
  for (int i = 0; i < 5; i++) {
    ch = getchar();
    switch (ch) {
    case '+':
      f = a + b;
      printf("f = %d\n", f);
      break;
    case '-':
      f = a - b;
      printf("f = %d\n", f);
      break;
    case '*':
      f = a * b;
      printf("f = %d\n", f);
      break;
    case '/':
      e = c / d;
      printf("f = %.2f\n", e);
      break;
    default:
      printf("invalid operator\n");
    }
    getchar();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0xa,-0xc(%rbp)
movl   $0x14,-0x10(%rbp)
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jge    123d <main+0x11d>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x5,%eax
ja     121a <main+0xfa>
mov    -0x38(%rbp),%rax
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <main+0x108>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <main+0x108>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1228 <main+0x108>
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe22(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1228 <main+0x108>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1157 <main+0x37>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     116f <main+0x3f>
lea    0xebe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf26(%rip),%rdi
mov    $0xc8,%esi
jmp    1189 <main+0x59>
lea    0xf18(%rip),%rdi
mov    $0x1e,%esi
jmp    1189 <main+0x59>
lea    0xf1c(%rip),%rdi
call   1030 <puts@plt>
jmp    11a8 <main+0x78>
lea    0xefc(%rip),%rdi
mov    $0xfffffff6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a8 <main+0x78>
lea    0xeef(%rip),%rdi
movsd  0xe5f(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11ed <main+0xbd>
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea8(%rip),%rdi
mov    $0xc8,%esi
jmp    1207 <main+0xd7>
lea    0xe9a(%rip),%rdi
mov    $0x1e,%esi
jmp    1207 <main+0xd7>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
jmp    1226 <main+0xf6>
lea    0xe7e(%rip),%rdi
mov    $0xfffffff6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1226 <main+0xf6>
lea    0xe71(%rip),%rdi
movsd  0xde1(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     126b <main+0x13b>
lea    0xdf2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe2a(%rip),%rdi
mov    $0xc8,%esi
jmp    1285 <main+0x155>
lea    0xe1c(%rip),%rdi
mov    $0x1e,%esi
jmp    1285 <main+0x155>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
jmp    12a4 <main+0x174>
lea    0xe00(%rip),%rdi
mov    $0xfffffff6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a4 <main+0x174>
lea    0xdf3(%rip),%rdi
movsd  0xd63(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     12e9 <main+0x1b9>
lea    0xd8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdac(%rip),%rdi
mov    $0xc8,%esi
jmp    1303 <main+0x1d3>
lea    0xd9e(%rip),%rdi
mov    $0x1e,%esi
jmp    1303 <main+0x1d3>
lea    0xda2(%rip),%rdi
call   1030 <puts@plt>
jmp    1322 <main+0x1f2>
lea    0xd82(%rip),%rdi
mov    $0xfffffff6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1322 <main+0x1f2>
lea    0xd75(%rip),%rdi
movsd  0xce5(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     1367 <main+0x237>
lea    0xd26(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd2e(%rip),%rdi
mov    $0xc8,%esi
jmp    1381 <main+0x251>
lea    0xd20(%rip),%rdi
mov    $0x1e,%esi
jmp    1381 <main+0x251>
lea    0xd24(%rip),%rdi
call   1030 <puts@plt>
jmp    13a0 <main+0x270>
lea    0xd04(%rip),%rdi
mov    $0xfffffff6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    13a0 <main+0x270>
lea    0xcf7(%rip),%rdi
movsd  0xc67(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <getchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"f = %d\0A\00"
@.str.1 = [10 x i8] c"f = %.2f\0A\00"
@.str.2 = [18 x i8] c"invalid operator\0A\00"
define void @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 10, i32* %3
store i32 20, i32* %4
store double 1.000000e+01, double* %6
store double 2.000000e+01, double* %7
store i32 0, i32* %8
br label %9
9: ; preds = %44, %0
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %47
12: ; preds = %9
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %1
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
switch i32 %15, label %40 [
i32 43, label %16
i32 45, label %22
i32 42, label %28
i32 47, label %34
]
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = add nsw i32 %17, %18
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %42
22: ; preds = %12
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %42
28: ; preds = %12
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = mul nsw i32 %29, %30
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %42
34: ; preds = %12
%35 = load double, double* %6
%36 = load double, double* %7
%37 = fdiv double %35, %36
store double %37, double* %5
%38 = load double, double* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %38)
br label %42
40: ; preds = %12
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %34, %28, %22, %16
%43 = call signext i8 (...) @getchar()
br label %44
44: ; preds = %42
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %9
47: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"f = %d\0A\00"
@.str.1 = [10 x i8] c"f = %.2f\0A\00"
@str = [17 x i8] c"invalid operator\00"
define void @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = sext i8 %1 to i32
switch i32 %2, label %11 [
i32 43, label %3
i32 45, label %5
i32 42, label %7
i32 47, label %9
]
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 30)
br label %13
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -10)
br label %13
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 200)
br label %13
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
br label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5, %3
%14 = tail call signext i8 (...) @getchar()
%15 = tail call signext i8 (...) @getchar()
%16 = sext i8 %15 to i32
switch i32 %16, label %25 [
i32 43, label %23
i32 45, label %21
i32 42, label %19
i32 47, label %17
]
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
br label %27
19: ; preds = %13
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 200)
br label %27
21: ; preds = %13
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -10)
br label %27
23: ; preds = %13
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 30)
br label %27
25: ; preds = %13
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %23, %21, %19, %17
%28 = tail call signext i8 (...) @getchar()
%29 = tail call signext i8 (...) @getchar()
%30 = sext i8 %29 to i32
switch i32 %30, label %39 [
i32 43, label %37
i32 45, label %35
i32 42, label %33
i32 47, label %31
]
31: ; preds = %27
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
br label %41
33: ; preds = %27
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 200)
br label %41
35: ; preds = %27
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -10)
br label %41
37: ; preds = %27
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 30)
br label %41
39: ; preds = %27
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %41
41: ; preds = %39, %37, %35, %33, %31
%42 = tail call signext i8 (...) @getchar()
%43 = tail call signext i8 (...) @getchar()
%44 = sext i8 %43 to i32
switch i32 %44, label %53 [
i32 43, label %51
i32 45, label %49
i32 42, label %47
i32 47, label %45
]
45: ; preds = %41
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
br label %55
47: ; preds = %41
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 200)
br label %55
49: ; preds = %41
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -10)
br label %55
51: ; preds = %41
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 30)
br label %55
53: ; preds = %41
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %55
55: ; preds = %53, %51, %49, %47, %45
%56 = tail call signext i8 (...) @getchar()
%57 = tail call signext i8 (...) @getchar()
%58 = sext i8 %57 to i32
switch i32 %58, label %67 [
i32 43, label %65
i32 45, label %63
i32 42, label %61
i32 47, label %59
]
59: ; preds = %55
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
br label %69
61: ; preds = %55
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 200)
br label %69
63: ; preds = %55
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 -10)
br label %69
65: ; preds = %55
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 30)
br label %69
67: ; preds = %55
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %69
69: ; preds = %67, %65, %63, %61, %59
%70 = tail call signext i8 (...) @getchar()
ret void
}