#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ __builtin_arc_nop();
int arcv2_timer0_count_get();
__attribute__((always_)) void delayTicks(uint32_t ticks) {
  if (ticks == 0)
    return;
  else if (ticks < 10) {
    __builtin_arc_nop();
    __builtin_arc_nop();
    __builtin_arc_nop();
    __builtin_arc_nop();
    __builtin_arc_nop();
  } else {
    ticks -= 10;
    uint32_t init_count = arcv2_timer0_count_get();
    while (arcv2_timer0_count_get() - init_count < ticks)
      ;
  }
}


x86 assembly (clang, -O0):
<delayTicks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113a <delayTicks+0x1a>
jmp    11a1 <delayTicks+0x81>
cmpl   $0xa,-0x4(%rbp)
jge    116c <delayTicks+0x4c>
mov    $0x0,%al
call   1040 <__builtin_arc_nop@plt>
mov    $0x0,%al
call   1040 <__builtin_arc_nop@plt>
mov    $0x0,%al
call   1040 <__builtin_arc_nop@plt>
mov    $0x0,%al
call   1040 <__builtin_arc_nop@plt>
mov    $0x0,%al
call   1040 <__builtin_arc_nop@plt>
jmp    119c <delayTicks+0x7c>
mov    -0x4(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <arcv2_timer0_count_get@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <arcv2_timer0_count_get@plt>
sub    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1197 <delayTicks+0x77>
jmp    117f <delayTicks+0x5f>
jmp    119c <delayTicks+0x7c>
jmp    11a1 <delayTicks+0x81>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delayTicks>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
je     117d <delayTicks+0x5d>
mov    %edi,%ebx
cmp    $0x9,%edi
jg     1157 <delayTicks+0x37>
xor    %eax,%eax
call   1040 <__builtin_arc_nop@plt>
xor    %eax,%eax
call   1040 <__builtin_arc_nop@plt>
xor    %eax,%eax
call   1040 <__builtin_arc_nop@plt>
xor    %eax,%eax
call   1040 <__builtin_arc_nop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <__builtin_arc_nop@plt>
add    $0xfffffff6,%ebx
xor    %eax,%eax
call   1030 <arcv2_timer0_count_get@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <arcv2_timer0_count_get@plt>
sub    %ebp,%eax
cmp    %ebx,%eax
jl     1170 <delayTicks+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @delayTicks(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %29
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = call i32 (...) @__builtin_arc_nop()
%12 = call i32 (...) @__builtin_arc_nop()
%13 = call i32 (...) @__builtin_arc_nop()
%14 = call i32 (...) @__builtin_arc_nop()
%15 = call i32 (...) @__builtin_arc_nop()
br label %28
16: ; preds = %7
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 10
store i32 %18, i32* %2
%19 = call i32 (...) @arcv2_timer0_count_get()
store i32 %19, i32* %3
br label %20
20: ; preds = %26, %16
%21 = call i32 (...) @arcv2_timer0_count_get()
%22 = load i32, i32* %3
%23 = sub nsw i32 %21, %22
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %20
br label %20
27: ; preds = %20
br label %28
28: ; preds = %27, %10
br label %29
29: ; preds = %6, %28
ret void
}

LLVM IR (-O2):
define void @delayTicks(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 10
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = tail call i32 (...) @__builtin_arc_nop()
%7 = tail call i32 (...) @__builtin_arc_nop()
%8 = tail call i32 (...) @__builtin_arc_nop()
%9 = tail call i32 (...) @__builtin_arc_nop()
%10 = tail call i32 (...) @__builtin_arc_nop()
br label %18
11: ; preds = %3
%12 = add nsw i32 %0, -10
%13 = tail call i32 (...) @arcv2_timer0_count_get()
br label %14
14: ; preds = %14, %11
%15 = tail call i32 (...) @arcv2_timer0_count_get()
%16 = sub nsw i32 %15, %13
%17 = icmp slt i32 %16, %12
br i1 %17, label %14, label %18
18: ; preds = %14, %5, %1
ret void
}