#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 add(int, int);
int chu(int, int);
int minus(int, int);
int mod(int, int);
int mul(int, int);
int /*<<< orphan*/ printf(char *, int);
void get_result(char ch, int x, int y) {
  switch (ch) {
  case '+':
    printf("%d\n", add(x, y));
    break;
  case '-':
    printf("%d\n", minus(x, y));
    break;
  case '*':
    printf("%d\n", mul(x, y));
    break;
  case '/':
    printf("%d\n", chu(x, y));
    break;
  case '%':
    printf("%d\n", mod(x, y));
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<get_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     1234 <get_result+0xd4>
mov    -0x18(%rbp),%rax
lea    0xe6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <add@plt>
mov    %eax,%esi
lea    0xe7a(%rip),%rdi
call   1070 <printf@plt>
jmp    1239 <get_result+0xd9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <minus@plt>
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
call   1070 <printf@plt>
jmp    1239 <get_result+0xd9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <mul@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
call   1070 <printf@plt>
jmp    1239 <get_result+0xd9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <chu@plt>
mov    %eax,%esi
lea    0xe20(%rip),%rdi
call   1070 <printf@plt>
jmp    1239 <get_result+0xd9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <mod@plt>
mov    %eax,%esi
lea    0xe02(%rip),%rdi
call   1070 <printf@plt>
jmp    1239 <get_result+0xd9>
jmp    1239 <get_result+0xd9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_result>:
push   %rax
add    $0xffffffdb,%edi
cmp    $0xa,%edi
ja     1184 <get_result+0x24>
lea    0xe90(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %esi,%edi
mov    %edx,%esi
call   1030 <mod@plt>
jmp    11b0 <get_result+0x50>
pop    %rax
ret
mov    %esi,%edi
mov    %edx,%esi
call   1080 <mul@plt>
jmp    11b0 <get_result+0x50>
mov    %esi,%edi
mov    %edx,%esi
call   1040 <add@plt>
jmp    11b0 <get_result+0x50>
mov    %esi,%edi
mov    %edx,%esi
call   1060 <minus@plt>
jmp    11b0 <get_result+0x50>
mov    %esi,%edi
mov    %edx,%esi
call   1050 <chu@plt>
lea    0xe75(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1070 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @get_result(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
switch i32 %8, label %34 [
i32 43, label %9
i32 45, label %14
i32 42, label %19
i32 47, label %24
i32 37, label %29
]
9: ; preds = %3
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 @add(i32 %10, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %35
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @minus(i32 %15, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %35
19: ; preds = %3
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @mul(i32 %20, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %35
24: ; preds = %3
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 @chu(i32 %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %35
29: ; preds = %3
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = call i32 @mod(i32 %30, i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %35
34: ; preds = %3
br label %35
35: ; preds = %34, %29, %24, %19, %14, %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @get_result(i8 signext %0, i32 %1, i32 %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %18 [
i32 43, label %5
i32 45, label %7
i32 42, label %9
i32 47, label %11
i32 37, label %13
]
5: ; preds = %3
%6 = tail call i32 @add(i32 %1, i32 %2)
br label %15
7: ; preds = %3
%8 = tail call i32 @minus(i32 %1, i32 %2)
br label %15
9: ; preds = %3
%10 = tail call i32 @mul(i32 %1, i32 %2)
br label %15
11: ; preds = %3
%12 = tail call i32 @chu(i32 %1, i32 %2)
br label %15
13: ; preds = %3
%14 = tail call i32 @mod(i32 %1, i32 %2)
br label %15
15: ; preds = %5, %7, %9, %11, %13
%16 = phi i32 [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15, %3
ret void
}