#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*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
void *count_odds(void *arg) {
  int i;
  int target = *((int *)arg);
  for (i = 0; i <= target; i++)
    if (i % 2 == 1) {
      (void)printf("Odd!:   %d\n", i);
      sleep(1);
    }
  return NULL;
}


x86 assembly (clang, -O0):
<count_odds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1188 <count_odds+0x68>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1175 <count_odds+0x55>
mov    -0xc(%rbp),%esi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    117a <count_odds+0x5a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <count_odds+0x1c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_odds>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%ebp
test   %ebp,%ebp
js     1162 <count_odds+0x42>
add    $0x1,%ebp
xor    %ebx,%ebx
lea    0xeca(%rip),%r14
jmp    1147 <count_odds+0x27>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     1162 <count_odds+0x42>
test   $0x1,%bl
je     1140 <count_odds+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
jmp    1140 <count_odds+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Odd!: %d\0A\00"
define i8* @count_odds(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
store i32 %7, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %21, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i32, i32* %3
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @sleep(i32 1)
br label %20
20: ; preds = %16, %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %8
24: ; preds = %8
ret i8* null
}

LLVM IR (-O2):
@.str = [12 x i8] c"Odd!: %d\0A\00"
define noalias i8* @count_odds(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %1, %12
%6 = phi i32 [ %13, %12 ], [ 0, %1 ]
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
%11 = tail call i32 @sleep(i32 1)
br label %12
12: ; preds = %5, %9
%13 = add nuw i32 %6, 1
%14 = icmp eq i32 %6, %3
br i1 %14, label %15, label %5
15: ; preds = %12, %1
ret i8* null
}