#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 *, ...);
void simple_acts(void) {
  int num_one, num_two;
  char ch;
  int sum = 0;
  printf("Enter your function:");
  scanf("%d", &num_one);
  while (ch != '\n') {
    scanf("%c", &ch);
    switch (ch) {
    case '+':
      scanf("%d", &num_two);
      num_one += num_two;
      break;
    case '-':
      scanf("%d", &num_two);
      num_one -= num_two;
      break;
    case '*':
      scanf("%d", &num_two);
      num_one *= num_two;
      break;
    case '/':
      scanf("%d", &num_two);
      num_one /= num_two;
      break;
    }
  }
  printf("result is %d\n", num_one);
}


x86 assembly (clang, -O0):
<simple_acts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     121e <simple_acts+0xfe>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
lea    -0x9(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x9(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1219 <simple_acts+0xf9>
mov    -0x18(%rbp),%rax
lea    0xe71(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <simple_acts+0xf9>
lea    0xe6e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <simple_acts+0xf9>
lea    0xe4c(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <simple_acts+0xf9>
lea    0xe2b(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    114f <simple_acts+0x2f>
mov    -0x4(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_acts>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xee4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed8(%rip),%r15
lea    0x7(%rsp),%r13
lea    0xe9c(%rip),%rbx
lea    0xc(%rsp),%r12
jmp    1193 <simple_acts+0x73>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
cltd
idivl  0xc(%rsp)
mov    %eax,0x8(%rsp)
movzbl 0x7(%rsp),%eax
cmp    $0xa,%al
je     1207 <simple_acts+0xe7>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%eax
mov    %eax,%ecx
add    $0xffffffd6,%ecx
cmp    $0x5,%ecx
ja     118f <simple_acts+0x6f>
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
jmp    1186 <simple_acts+0x66>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
add    %eax,0x8(%rsp)
jmp    118a <simple_acts+0x6a>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
sub    %eax,0x8(%rsp)
jmp    118a <simple_acts+0x6a>
mov    0x8(%rsp),%esi
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"Enter your function:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [14 x i8] c"result is %d\0A\00"
define void @simple_acts() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %8
8: ; preds = %0, %34
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
switch i32 %11, label %34 [
i32 43, label %12
i32 45, label %17
i32 42, label %22
i32 47, label %27
]
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = add nsw i32 %15, %14
store i32 %16, i32* %1
br label %32
17: ; preds = %8
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
%20 = load i32, i32* %1
%21 = sub nsw i32 %20, %19
store i32 %21, i32* %1
br label %32
22: ; preds = %8
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %2
%25 = load i32, i32* %1
%26 = mul nsw i32 %25, %24
store i32 %26, i32* %1
br label %32
27: ; preds = %8
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%29 = load i32, i32* %2
%30 = load i32, i32* %1
%31 = sdiv i32 %30, %29
store i32 %31, i32* %1
br label %32
32: ; preds = %12, %17, %22, %27
%33 = load i8, i8* %3
br label %34
34: ; preds = %32, %8
%35 = phi i8 [ %33, %32 ], [ %10, %8 ]
%36 = icmp eq i8 %35, 10
br i1 %36, label %37, label %8
37: ; preds = %34
%38 = load i32, i32* %1
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %38)
ret void
}