#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 /*<<< orphan*/ ucontext_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ swapcontext(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void odd(ucontext_t *ctx1, ucontext_t *ctx2) {
  int i;
  for (i = 1; i <= 9; i = i + 2) {
    printf("%3d", i);
    swapcontext(ctx2, ctx1);
  }
}


x86 assembly (clang, -O0):
<odd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jg     116b <odd+0x4b>
mov    -0x14(%rbp),%esi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <swapcontext@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <odd+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<odd>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xece(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <swapcontext@plt>
mov    %r15,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <swapcontext@plt>
mov    %r15,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <swapcontext@plt>
mov    %r15,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <swapcontext@plt>
mov    %r15,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <swapcontext@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%3d\00"
define void @odd(i32* %0, i32* %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = tail call i32 @swapcontext(i32* %1, i32* %0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = tail call i32 @swapcontext(i32* %1, i32* %0)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = tail call i32 @swapcontext(i32* %1, i32* %0)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = tail call i32 @swapcontext(i32* %1, i32* %0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 9)
%12 = tail call i32 @swapcontext(i32* %1, i32* %0)
ret void
}