#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_third(int limit) {
  for (int i = 0; i < limit; i++) {
    if (i % 3 == 0) {
      fprintf(stdout, "%d ", (i + limit));
      coro_yield();
    }
  }
}


x86 assembly (clang, -O0):
<gen_third>:
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    1187 <gen_third+0x67>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1174 <gen_third+0x54>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
add    -0x4(%rbp),%edx
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <coro_yield@plt>
jmp    1179 <gen_third+0x59>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <gen_third+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_third>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    1182 <gen_third+0x62>
mov    %edi,%r13d
mov    $0xaaaaaaab,%r15d
mov    0x2ea3(%rip),%r12
lea    0xebc(%rip),%r14
xor    %ebx,%ebx
jmp    1158 <gen_third+0x38>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%r13d
je     1182 <gen_third+0x62>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
cmp    %ebx,%eax
jne    1150 <gen_third+0x30>
mov    (%r12),%edi
lea    (%rbx,%r13,1),%edx
mov    %r14,%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <coro_yield@plt>
jmp    1150 <gen_third+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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