#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 */
struct mtwist_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ infinite_taunt0(struct mtwist_state *, char *, int);
int /*<<< orphan*/ infinite_taunt1(struct mtwist_state *, char *, int);
int /*<<< orphan*/ infinite_taunt2(struct mtwist_state *, char *, int);
int /*<<< orphan*/ infinite_taunt3(struct mtwist_state *, char *, int);
int mtwist_next(struct mtwist_state *);
void infinite_taunt(struct mtwist_state *mt, char *buffer, int buflen) {
  switch (mtwist_next(mt) % 4) {
  case 0:
    infinite_taunt0(mt, buffer, buflen);
    break;
  case 1:
    infinite_taunt1(mt, buffer, buflen);
    break;
  case 2:
    infinite_taunt2(mt, buffer, buflen);
    break;
  case 3:
    infinite_taunt3(mt, buffer, buflen);
    break;
  default:
    infinite_taunt1(mt, buffer, buflen);
    break;
  }
}


x86 assembly (clang, -O0):
<infinite_taunt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <mtwist_next@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,-0x20(%rbp)
sub    $0x3,%eax
ja     11f4 <infinite_taunt+0xa4>
mov    -0x20(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <infinite_taunt0@plt>
jmp    1204 <infinite_taunt+0xb4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <infinite_taunt1@plt>
jmp    1204 <infinite_taunt+0xb4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <infinite_taunt2@plt>
jmp    1204 <infinite_taunt+0xb4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <infinite_taunt3@plt>
jmp    1204 <infinite_taunt+0xb4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <infinite_taunt1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<infinite_taunt>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1050 <mtwist_next@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     1196 <infinite_taunt+0x46>
lea    0xe85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <infinite_taunt0@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <infinite_taunt1@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <infinite_taunt2@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <infinite_taunt3@plt>

LLVM IR (-O0):
%struct.mtwist_state = type { i32 }
define void @infinite_taunt(%struct.mtwist_state* %0, i8* %1, i32 %2) {
%4 = alloca %struct.mtwist_state*
%5 = alloca i8*
%6 = alloca i32
store %struct.mtwist_state* %0, %struct.mtwist_state** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%8 = call i32 @mtwist_next(%struct.mtwist_state* %7)
%9 = srem i32 %8, 4
switch i32 %9, label %30 [
i32 0, label %10
i32 1, label %15
i32 2, label %20
i32 3, label %25
]
10: ; preds = %3
%11 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @infinite_taunt0(%struct.mtwist_state* %11, i8* %12, i32 %13)
br label %35
15: ; preds = %3
%16 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i32 @infinite_taunt1(%struct.mtwist_state* %16, i8* %17, i32 %18)
br label %35
20: ; preds = %3
%21 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = call i32 @infinite_taunt2(%struct.mtwist_state* %21, i8* %22, i32 %23)
br label %35
25: ; preds = %3
%26 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = call i32 @infinite_taunt3(%struct.mtwist_state* %26, i8* %27, i32 %28)
br label %35
30: ; preds = %3
%31 = load %struct.mtwist_state*, %struct.mtwist_state** %4
%32 = load i8*, i8** %5
%33 = load i32, i32* %6
%34 = call i32 @infinite_taunt1(%struct.mtwist_state* %31, i8* %32, i32 %33)
br label %35
35: ; preds = %30, %25, %20, %15, %10
ret void
}

LLVM IR (-O2):
%struct.mtwist_state = type { i32 }
define void @infinite_taunt(%struct.mtwist_state* %0, i8* %1, i32 %2) {
%4 = tail call i32 @mtwist_next(%struct.mtwist_state* %0)
%5 = srem i32 %4, 4
switch i32 %5, label %14 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
]
6: ; preds = %3
%7 = tail call i32 @infinite_taunt0(%struct.mtwist_state* %0, i8* %1, i32 %2)
br label %16
8: ; preds = %3
%9 = tail call i32 @infinite_taunt1(%struct.mtwist_state* %0, i8* %1, i32 %2)
br label %16
10: ; preds = %3
%11 = tail call i32 @infinite_taunt2(%struct.mtwist_state* %0, i8* %1, i32 %2)
br label %16
12: ; preds = %3
%13 = tail call i32 @infinite_taunt3(%struct.mtwist_state* %0, i8* %1, i32 %2)
br label %16
14: ; preds = %3
%15 = tail call i32 @infinite_taunt1(%struct.mtwist_state* %0, i8* %1, i32 %2)
br label %16
16: ; preds = %14, %12, %10, %8, %6
ret void
}