#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 rand();
char determine_operand(int difficulty) {
  int temp_operand = 0;
  char operand = '0';
  if (difficulty == 1) {
    temp_operand = rand() % 2;
  } else if (difficulty == 2) {
    temp_operand = (rand() % 2) + 2;
  } else {
    temp_operand = rand() % 4;
  }
  if (temp_operand == 0) {
    operand = '+';
  } else if (temp_operand == 1) {
    operand = '-';
  } else if (temp_operand == 2) {
    operand = '*';
  } else if (temp_operand == 3) {
    operand = '/';
  }
  return operand;
}


x86 assembly (clang, -O0):
<determine_operand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x30,-0x9(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1147 <determine_operand+0x37>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
jmp    1182 <determine_operand+0x72>
cmpl   $0x2,-0x4(%rbp)
jne    116b <determine_operand+0x5b>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x2,%edx
mov    %edx,-0x8(%rbp)
jmp    117d <determine_operand+0x6d>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
jmp    1182 <determine_operand+0x72>
cmpl   $0x0,-0x8(%rbp)
jne    1195 <determine_operand+0x85>
movb   $0x2b,-0x9(%rbp)
jmp    11d8 <determine_operand+0xc8>
cmpl   $0x1,-0x8(%rbp)
jne    11a8 <determine_operand+0x98>
movb   $0x2d,-0x9(%rbp)
jmp    11d3 <determine_operand+0xc3>
cmpl   $0x2,-0x8(%rbp)
jne    11bb <determine_operand+0xab>
movb   $0x2a,-0x9(%rbp)
jmp    11ce <determine_operand+0xbe>
cmpl   $0x3,-0x8(%rbp)
jne    11c9 <determine_operand+0xb9>
movb   $0x2f,-0x9(%rbp)
jmp    11ce <determine_operand+0xbe>
jmp    11d3 <determine_operand+0xc3>
jmp    11d8 <determine_operand+0xc8>
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_operand>:
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
je     112e <determine_operand+0x1e>
cmp    $0x1,%edi
jne    1146 <determine_operand+0x36>
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
jmp    1156 <determine_operand+0x46>
call   1030 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x2,%eax
jmp    1158 <determine_operand+0x48>
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
lea    0x0(,%rax,8),%ecx
mov    $0x2f2a2d2b,%edx
shr    %cl,%edx
cmp    $0x4,%eax
mov    $0x30,%eax
cmovb  %edx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define signext i8 @determine_operand(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
store i32 0, i32* %3
store i8 48, i8* %4
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 2
store i32 %9, i32* %3
br label %21
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 2
%16 = add nsw i32 %15, 2
store i32 %16, i32* %3
br label %20
17: ; preds = %10
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 4
store i32 %19, i32* %3
br label %20
20: ; preds = %17, %13
br label %21
21: ; preds = %20, %7
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i8 43, i8* %4
br label %40
25: ; preds = %21
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %25
store i8 45, i8* %4
br label %39
29: ; preds = %25
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %33
32: ; preds = %29
store i8 42, i8* %4
br label %38
33: ; preds = %29
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %37
36: ; preds = %33
store i8 47, i8* %4
br label %37
37: ; preds = %36, %33
br label %38
38: ; preds = %37, %32
br label %39
39: ; preds = %38, %28
br label %40
40: ; preds = %39, %24
%41 = load i8, i8* %4
ret i8 %41
}

LLVM IR (-O2):
define signext i8 @determine_operand(i32 %0) {
switch i32 %0, label %9 [
i32 1, label %2
i32 2, label %5
]
2: ; preds = %1
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 2
br label %12
5: ; preds = %1
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 2
%8 = add nsw i32 %7, 2
br label %12
9: ; preds = %1
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 4
br label %12
12: ; preds = %5, %9, %2
%13 = phi i32 [ %4, %2 ], [ %8, %5 ], [ %11, %9 ]
%14 = icmp ult i32 %13, 4
%15 = shl nsw i32 %13, 3
%16 = lshr i32 791293227, %15
%17 = trunc i32 %16 to i8
%18 = select i1 %14, i8 %17, i8 48
ret i8 %18
}