#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 */
scalar_t__ strcmp(char *, char *);
char getop(char *str) {
  char ch;
  if (strcmp(str, "+") == 0) {
    ch = '+';
  } else if (strcmp(str, "-") == 0) {
    ch = '-';
  } else if (strcmp(str, "*") == 0) {
    ch = '*';
  } else if (strcmp(str, "/") == 0) {
    ch = '/';
  } else {
    ch = 'n';
  }
  return ch;
}


x86 assembly (clang, -O0):
<getop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    113f <getop+0x2f>
movb   $0x2b,-0x9(%rbp)
jmp    11bb <getop+0xab>
mov    -0x8(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1162 <getop+0x52>
movb   $0x2d,-0x9(%rbp)
jmp    11b6 <getop+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1185 <getop+0x75>
movb   $0x2a,-0x9(%rbp)
jmp    11b1 <getop+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <getop+0x98>
movb   $0x2f,-0x9(%rbp)
jmp    11ac <getop+0x9c>
movb   $0x6e,-0x9(%rbp)
jmp    11b1 <getop+0xa1>
jmp    11b6 <getop+0xa6>
jmp    11bb <getop+0xab>
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getop>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116e <getop+0x5e>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1172 <getop+0x62>
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1176 <getop+0x66>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
mov    $0x2f,%ecx
mov    $0x6e,%eax
cmove  %ecx,%eax
pop    %rbx
ret
mov    $0x2b,%al
pop    %rbx
ret
mov    $0x2d,%al
pop    %rbx
ret
mov    $0x2a,%al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"/\00"
define signext i8 @getop(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 43, i8* %3
br label %27
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 45, i8* %3
br label %26
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 42, i8* %3
br label %25
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 47, i8* %3
br label %24
23: ; preds = %18
store i8 110, i8* %3
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25, %12
br label %27
27: ; preds = %26, %7
%28 = load i8, i8* %3
ret i8 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"/\00"
define signext i8 @getop(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8 47, i8 110
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i8 [ 43, %1 ], [ 45, %4 ], [ 42, %7 ], [ %13, %10 ]
ret i8 %15
}