#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();
unsigned long taviso(void) {
  unsigned long r = 0;
  switch (rand() % 4) {
  case 0:
    r = rand() & rand();
    break;
  case 1:
    r = rand() % rand();
    break;
  case 2:
    r = rand() | rand();
    break;
  case 3:
    r = rand();
    break;
  default:
    break;
  }
  return r;
}


x86 assembly (clang, -O0):
<taviso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11d8 <taviso+0xc8>
mov    -0x10(%rbp),%rax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
and    %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11dd <taviso+0xcd>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x8(%rbp)
jmp    11dd <taviso+0xcd>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11dd <taviso+0xcd>
mov    $0x0,%al
call   1030 <rand@plt>
cltq
mov    %rax,-0x8(%rbp)
jmp    11dd <taviso+0xcd>
jmp    11dd <taviso+0xcd>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taviso>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     118a <taviso+0x7a>
lea    0xecd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
and    %ebx,%eax
jmp    1187 <taviso+0x77>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
movslq %edx,%rbx
jmp    118a <taviso+0x7a>
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
or     %ebx,%eax
jmp    1187 <taviso+0x77>
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @taviso() {
%1 = alloca i64
store i64 0, i64* %1
%2 = call i32 (...) @rand()
%3 = srem i32 %2, 4
switch i32 %3, label %22 [
i32 0, label %4
i32 1, label %9
i32 2, label %14
i32 3, label %19
]
4: ; preds = %0
%5 = call i32 (...) @rand()
%6 = call i32 (...) @rand()
%7 = and i32 %5, %6
%8 = sext i32 %7 to i64
store i64 %8, i64* %1
br label %23
9: ; preds = %0
%10 = call i32 (...) @rand()
%11 = call i32 (...) @rand()
%12 = srem i32 %10, %11
%13 = sext i32 %12 to i64
store i64 %13, i64* %1
br label %23
14: ; preds = %0
%15 = call i32 (...) @rand()
%16 = call i32 (...) @rand()
%17 = or i32 %15, %16
%18 = sext i32 %17 to i64
store i64 %18, i64* %1
br label %23
19: ; preds = %0
%20 = call i32 (...) @rand()
%21 = sext i32 %20 to i64
store i64 %21, i64* %1
br label %23
22: ; preds = %0
br label %23
23: ; preds = %22, %19, %14, %9, %4
%24 = load i64, i64* %1
ret i64 %24
}

LLVM IR (-O2):
define i64 @taviso() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 4
switch i32 %2, label %21 [
i32 0, label %3
i32 1, label %8
i32 2, label %13
i32 3, label %18
]
3: ; preds = %0
%4 = tail call i32 (...) @rand()
%5 = tail call i32 (...) @rand()
%6 = and i32 %5, %4
%7 = sext i32 %6 to i64
br label %21
8: ; preds = %0
%9 = tail call i32 (...) @rand()
%10 = tail call i32 (...) @rand()
%11 = srem i32 %9, %10
%12 = sext i32 %11 to i64
br label %21
13: ; preds = %0
%14 = tail call i32 (...) @rand()
%15 = tail call i32 (...) @rand()
%16 = or i32 %15, %14
%17 = sext i32 %16 to i64
br label %21
18: ; preds = %0
%19 = tail call i32 (...) @rand()
%20 = sext i32 %19 to i64
br label %21
21: ; preds = %0, %18, %13, %8, %3
%22 = phi i64 [ 0, %0 ], [ %20, %18 ], [ %17, %13 ], [ %12, %8 ], [ %7, %3 ]
ret i64 %22
}