#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 sched_entity {
  int dummy;
};
struct cfs_rq {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ __check_preempt_curr_fair(struct cfs_rq *,
                                             struct sched_entity *,
                                             struct sched_entity *,
                                             int /*<<< orphan*/);
struct sched_entity *__pick_next_entity(struct cfs_rq *);
int /*<<< orphan*/ dequeue_entity(struct cfs_rq *, struct sched_entity *,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ enqueue_entity(struct cfs_rq *, struct sched_entity *,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ sched_granularity(struct cfs_rq *);
void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) {
  struct sched_entity *next;
  dequeue_entity(cfs_rq, curr, 0);
  enqueue_entity(cfs_rq, curr, 0);
  next = __pick_next_entity(cfs_rq);
  if (next == curr)
    return;
  __check_preempt_curr_fair(cfs_rq, next, curr, sched_granularity(cfs_rq));
}


x86 assembly (clang, -O0):
<entity_tick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <dequeue_entity@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <enqueue_entity@plt>
mov    -0x8(%rbp),%rdi
call   1060 <__pick_next_entity@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    119e <entity_tick+0x4e>
jmp    11d2 <entity_tick+0x82>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <sched_granularity@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
call   1050 <__check_preempt_curr_fair@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entity_tick>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edx,%edx
call   1030 <dequeue_entity@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <enqueue_entity@plt>
mov    %rbx,%rdi
call   1060 <__pick_next_entity@plt>
cmp    %r14,%rax
je     119c <entity_tick+0x4c>
mov    %rax,%r15
mov    %rbx,%rdi
call   1070 <sched_granularity@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <__check_preempt_curr_fair@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cfs_rq = type { i32 }
%struct.sched_entity = type { i32 }
define void @entity_tick(%struct.cfs_rq* %0, %struct.sched_entity* %1) {
%3 = alloca %struct.cfs_rq*
%4 = alloca %struct.sched_entity*
%5 = alloca %struct.sched_entity*
store %struct.cfs_rq* %0, %struct.cfs_rq** %3
store %struct.sched_entity* %1, %struct.sched_entity** %4
%6 = load %struct.cfs_rq*, %struct.cfs_rq** %3
%7 = load %struct.sched_entity*, %struct.sched_entity** %4
%8 = call i32 @dequeue_entity(%struct.cfs_rq* %6, %struct.sched_entity* %7, i32 0)
%9 = load %struct.cfs_rq*, %struct.cfs_rq** %3
%10 = load %struct.sched_entity*, %struct.sched_entity** %4
%11 = call i32 @enqueue_entity(%struct.cfs_rq* %9, %struct.sched_entity* %10, i32 0)
%12 = load %struct.cfs_rq*, %struct.cfs_rq** %3
%13 = call %struct.sched_entity* @__pick_next_entity(%struct.cfs_rq* %12)
store %struct.sched_entity* %13, %struct.sched_entity** %5
%14 = load %struct.sched_entity*, %struct.sched_entity** %5
%15 = load %struct.sched_entity*, %struct.sched_entity** %4
%16 = icmp eq %struct.sched_entity* %14, %15
br i1 %16, label %17, label %18
17: ; preds = %2
br label %25
18: ; preds = %2
%19 = load %struct.cfs_rq*, %struct.cfs_rq** %3
%20 = load %struct.sched_entity*, %struct.sched_entity** %5
%21 = load %struct.sched_entity*, %struct.sched_entity** %4
%22 = load %struct.cfs_rq*, %struct.cfs_rq** %3
%23 = call i32 @sched_granularity(%struct.cfs_rq* %22)
%24 = call i32 @__check_preempt_curr_fair(%struct.cfs_rq* %19, %struct.sched_entity* %20, %struct.sched_entity* %21, i32 %23)
br label %25
25: ; preds = %18, %17
ret void
}

LLVM IR (-O2):
%struct.cfs_rq = type { i32 }
%struct.sched_entity = type { i32 }
define void @entity_tick(%struct.cfs_rq* %0, %struct.sched_entity* %1) {
%3 = tail call i32 @dequeue_entity(%struct.cfs_rq* %0, %struct.sched_entity* %1, i32 0)
%4 = tail call i32 @enqueue_entity(%struct.cfs_rq* %0, %struct.sched_entity* %1, i32 0)
%5 = tail call %struct.sched_entity* @__pick_next_entity(%struct.cfs_rq* %0)
%6 = icmp eq %struct.sched_entity* %5, %1
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @sched_granularity(%struct.cfs_rq* %0)
%9 = tail call i32 @__check_preempt_curr_fair(%struct.cfs_rq* %0, %struct.sched_entity* %5, %struct.sched_entity* %1, i32 %8)
br label %10
10: ; preds = %2, %7
ret void
}