#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*/ coro_yield();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
void gen_even(int limit) {
  for (int i = 0; i < limit; i++) {
    if (i % 2 == 0) {
      fprintf(stdout, "%d ", (i));
      coro_yield();
    }
  }
}


x86 assembly (clang, -O0):
<gen_even>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1184 <gen_even+0x64>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1171 <gen_even+0x51>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe9b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <coro_yield@plt>
jmp    1176 <gen_even+0x56>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <gen_even+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_even>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1163 <gen_even+0x43>
mov    %edi,%ebx
mov    0x2eac(%rip),%r15
lea    0xec5(%rip),%r14
xor    %ebp,%ebp
jmp    1147 <gen_even+0x27>
nop
add    $0x1,%ebp
cmp    %ebp,%ebx
je     1163 <gen_even+0x43>
test   $0x1,%bpl
jne    1140 <gen_even+0x20>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <coro_yield@plt>
jmp    1140 <gen_even+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [4 x i8] c"%d \00"
define void @gen_even(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %18, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = load i32, i32* %3
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i32, i32* @stdout
%14 = load i32, i32* %3
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @coro_yield()
br label %17
17: ; preds = %12, %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"%d \00"
define void @gen_even(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %4, label %3
3: ; preds = %12, %1
ret void
4: ; preds = %1, %12
%5 = phi i32 [ %13, %12 ], [ 0, %1 ]
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i32, i32* @stdout
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%11 = tail call i32 (...) @coro_yield()
br label %12
12: ; preds = %4, %8
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, %0
br i1 %14, label %3, label %4
}