#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 /*<<< orphan*/ __nop();
int /*<<< orphan*/ delay(unsigned int);
void delay_cycles(unsigned int n) {
  switch (n) {
  case 3:
    __nop();
  case 2:
    __nop();
  case 1:
    __nop();
  case 0:
    return;
  }
  delay((n - 1) / 3);
  switch (n % 3) {
  case 0:
    __nop();
  case 2:
    __nop();
  }
}


x86 assembly (clang, -O0):
<delay_cycles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     116a <delay_cycles+0x4a>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1040 <__nop@plt>
mov    $0x0,%al
call   1040 <__nop@plt>
mov    $0x0,%al
call   1040 <__nop@plt>
jmp    11d1 <delay_cycles+0xb1>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    $0xaaaaaaab,%ecx
mov    %rcx,-0x20(%rbp)
imul   %rcx,%rax
shr    $0x21,%rax
mov    %eax,%edi
call   1030 <delay@plt>
mov    -0x20(%rbp),%rdx
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %ecx,%eax
imul   %rdx,%rcx
shr    $0x21,%rcx
mov    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
je     11c3 <delay_cycles+0xa3>
jmp    11b2 <delay_cycles+0x92>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11ca <delay_cycles+0xaa>
jmp    11d1 <delay_cycles+0xb1>
mov    $0x0,%al
call   1040 <__nop@plt>
mov    $0x0,%al
call   1040 <__nop@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay_cycles>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
cmp    $0x3,%edi
ja     1146 <delay_cycles+0x26>
lea    0xecc(%rip),%rax
movslq (%rax,%r14,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1040 <__nop@plt>
jmp    1175 <delay_cycles+0x55>
mov    %edi,%ebx
lea    -0x1(%rbx),%edi
mov    $0xaaaaaaab,%r15d
imul   %r15,%rdi
shr    $0x21,%rdi
call   1030 <delay@plt>
imul   %r15,%r14
shr    $0x21,%r14
lea    (%r14,%r14,2),%eax
sub    %eax,%ebx
cmp    $0x2,%ebx
je     117c <delay_cycles+0x5c>
test   %ebx,%ebx
jne    1188 <delay_cycles+0x68>
xor    %eax,%eax
call   1040 <__nop@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <__nop@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @delay_cycles(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %11 [
i32 3, label %4
i32 2, label %6
i32 1, label %8
i32 0, label %10
]
4: ; preds = %1
%5 = call i32 (...) @__nop()
br label %6
6: ; preds = %1, %4
%7 = call i32 (...) @__nop()
br label %8
8: ; preds = %1, %6
%9 = call i32 (...) @__nop()
br label %10
10: ; preds = %1, %8
br label %22
11: ; preds = %1
%12 = load i32, i32* %2
%13 = sub i32 %12, 1
%14 = udiv i32 %13, 3
%15 = call i32 @delay(i32 %14)
%16 = load i32, i32* %2
%17 = urem i32 %16, 3
switch i32 %17, label %22 [
i32 0, label %18
i32 2, label %20
]
18: ; preds = %11
%19 = call i32 (...) @__nop()
br label %20
20: ; preds = %11, %18
%21 = call i32 (...) @__nop()
br label %22
22: ; preds = %10, %20, %11
ret void
}

LLVM IR (-O2):
define void @delay_cycles(i32 %0) {
switch i32 %0, label %4 [
i32 3, label %2
i32 2, label %9
i32 1, label %11
i32 0, label %13
]
2: ; preds = %1
%3 = tail call i32 (...) @__nop()
br label %9
4: ; preds = %1
%5 = add i32 %0, -1
%6 = udiv i32 %5, 3
%7 = tail call i32 @delay(i32 %6)
%8 = urem i32 %0, 3
switch i32 %8, label %13 [
i32 0, label %9
i32 2, label %11
]
9: ; preds = %4, %2, %1
%10 = tail call i32 (...) @__nop()
br label %11
11: ; preds = %9, %4, %1
%12 = tail call i32 (...) @__nop()
br label %13
13: ; preds = %11, %1, %4
ret void
}