#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 */
scalar_t__ _greenlet_savecontext(void **);
int /*<<< orphan*/ _greenlet_switchcontext(void **, int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *);
void time_greenlet_switchcontext(int count) {
  int i;
  void *frame[8];
  for (i = 0; i < count; i++) {
    if (_greenlet_savecontext(frame))
      continue;
    _greenlet_switchcontext(frame, NULL, NULL);
  }
}


x86 assembly (clang, -O0):
<time_greenlet_switchcontext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1174 <time_greenlet_switchcontext+0x54>
lea    -0x50(%rbp),%rdi
call   1040 <_greenlet_savecontext@plt>
cmp    $0x0,%rax
je     1156 <time_greenlet_switchcontext+0x36>
jmp    1166 <time_greenlet_switchcontext+0x46>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1030 <_greenlet_switchcontext@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <time_greenlet_switchcontext+0x12>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_greenlet_switchcontext>:
push   %r14
push   %rbx
sub    $0x48,%rsp
test   %edi,%edi
jle    1160 <time_greenlet_switchcontext+0x40>
mov    %edi,%ebx
mov    %rsp,%r14
jmp    1145 <time_greenlet_switchcontext+0x25>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebx
je     1160 <time_greenlet_switchcontext+0x40>
mov    %r14,%rdi
call   1040 <_greenlet_savecontext@plt>
test   %rax,%rax
jne    1140 <time_greenlet_switchcontext+0x20>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <_greenlet_switchcontext@plt>
jmp    1140 <time_greenlet_switchcontext+0x20>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @time_greenlet_switchcontext(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i8*]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 0
%11 = call i64 @_greenlet_savecontext(i8** %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %17
14: ; preds = %9
%15 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 0
%16 = call i32 @_greenlet_switchcontext(i8** %15, i32* null, i32* null)
br label %17
17: ; preds = %14, %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @time_greenlet_switchcontext(i32 %0) {
%2 = alloca [8 x i8*]
%3 = bitcast [8 x i8*]* %2 to i8*
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 0
br label %7
7: ; preds = %5, %13
%8 = phi i32 [ 0, %5 ], [ %14, %13 ]
%9 = call i64 @_greenlet_savecontext(i8** %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @_greenlet_switchcontext(i8** %6, i32* null, i32* null)
br label %13
13: ; preds = %7, %11
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, %0
br i1 %15, label %16, label %7
16: ; preds = %13, %1
ret void
}