#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 apply(int, int, int);
int get_value(char *);
int pop();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ push(int);
void work_with(char *s, int type, int value) {
  int n1, n2;
  switch (type) {
  case 110:
    n1 = pop();
    n2 = pop();
    push(apply(value, n1, n2));
    printf("work with oper %d, numbers %d,%d, result %d\n", value, n1, n2,
           apply(value, n1, n2));
    break;
  case 111:
    printf("work with number %d\n", value);
    push(value);
    break;
  case 112:
    push(get_value(s));
    break;
  }
}


x86 assembly (clang, -O0):
<work_with>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x6e,%eax
je     1198 <work_with+0x48>
jmp    1176 <work_with+0x26>
mov    -0x1c(%rbp),%eax
sub    $0x6f,%eax
je     1200 <work_with+0xb0>
jmp    1187 <work_with+0x37>
mov    -0x1c(%rbp),%eax
sub    $0x70,%eax
je     121e <work_with+0xce>
jmp    122e <work_with+0xde>
mov    $0x0,%al
call   1040 <pop@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <pop@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <apply@plt>
mov    %eax,%edi
call   1070 <push@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <apply@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    %eax,%r8d
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <work_with+0xde>
mov    -0x10(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
call   1070 <push@plt>
jmp    122e <work_with+0xde>
mov    -0x8(%rbp),%rdi
call   1060 <get_value@plt>
mov    %eax,%edi
call   1070 <push@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<work_with>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x70,%esi
je     11b3 <work_with+0x63>
mov    %edx,%ebx
cmp    $0x6f,%esi
je     11bc <work_with+0x6c>
cmp    $0x6e,%esi
jne    11d7 <work_with+0x87>
xor    %eax,%eax
call   1040 <pop@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <pop@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   1050 <apply@plt>
mov    %eax,%edi
call   1070 <push@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1050 <apply@plt>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
call   1060 <get_value@plt>
mov    %eax,%edi
jmp    11ce <work_with+0x7e>
lea    0xe6a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <push@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"work with oper %d, numbers %d,%d, result %d\0A\00"
@.str.1 = [21 x i8] c"work with number %d\0A\00"
define void @work_with(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
switch i32 %9, label %35 [
i32 110, label %10
i32 111, label %26
i32 112, label %31
]
10: ; preds = %3
%11 = call i32 (...) @pop()
store i32 %11, i32* %7
%12 = call i32 (...) @pop()
store i32 %12, i32* %8
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @apply(i32 %13, i32 %14, i32 %15)
%17 = call i32 @push(i32 %16)
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @apply(i32 %21, i32 %22, i32 %23)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %24)
br label %35
26: ; preds = %3
%27 = load i32, i32* %6
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = call i32 @push(i32 %29)
br label %35
31: ; preds = %3
%32 = load i8*, i8** %4
%33 = call i32 @get_value(i8* %32)
%34 = call i32 @push(i32 %33)
br label %35
35: ; preds = %3, %31, %26, %10
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"work with oper %d, numbers %d,%d, result %d\0A\00"
@.str.1 = [21 x i8] c"work with number %d\0A\00"
define void @work_with(i8* %0, i32 %1, i32 %2) {
switch i32 %1, label %17 [
i32 110, label %4
i32 111, label %11
i32 112, label %14
]
4: ; preds = %3
%5 = tail call i32 (...) @pop()
%6 = tail call i32 (...) @pop()
%7 = tail call i32 @apply(i32 %2, i32 %5, i32 %6)
%8 = tail call i32 @push(i32 %7)
%9 = tail call i32 @apply(i32 %2, i32 %5, i32 %6)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %5, i32 %6, i32 %9)
br label %17
11: ; preds = %3
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%13 = tail call i32 @push(i32 %2)
br label %17
14: ; preds = %3
%15 = tail call i32 @get_value(i8* %0)
%16 = tail call i32 @push(i32 %15)
br label %17
17: ; preds = %3, %14, %11, %4
ret void
}