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

/* Variables and functions */
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigwait(int /*<<< orphan*/ *, int *);
void *two(void *arg) {
  int catch;
  int target = *((int *)arg);
  int i = 1;
  sigset_t set;
  sigemptyset(&set);
  sigaddset(&set, SIGUSR1);
  while (i < target) {
    printf("Odds Waiting..\n");
    sigwait(&set, &catch);
    printf("Odd!: %d\n", i);
    i = i + 2;
    raise(SIGUSR2);
  }
}


x86 assembly (clang, -O0):
<two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11db <two+0x8b>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <sigwait@plt>
mov    -0x1c(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
jmp    1187 <two+0x37>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<two>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
cmp    $0x2,%ebp
jl     11e2 <two+0x82>
mov    $0x1,%ebx
mov    %rsp,%r15
lea    0x4(%rsp),%r12
lea    0xe5e(%rip),%r13
mov    0x2e2f(%rip),%r14
nopl   0x0(%rax)
lea    0xe53(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <sigwait@plt>
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x2,%ebx
mov    (%r14),%edi
call   1030 <raise@plt>
cmp    %ebp,%ebx
jl     11b0 <two+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SIGUSR1 = global i32 0
@.str = [16 x i8] c"Odds Waiting..\0A\00"
@.str.1 = [10 x i8] c"Odd!: %d\0A\00"
@SIGUSR2 = global i32 0
define i8* @two(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %5
store i32 1, i32* %6
%11 = call i32 @sigemptyset(i32* %7)
%12 = load i32, i32* @SIGUSR1
%13 = call i32 @sigaddset(i32* %7, i32 %12)
br label %14
14: ; preds = %18, %1
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @sigwait(i32* %7, i32* %4)
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 2
store i32 %24, i32* %6
%25 = load i32, i32* @SIGUSR2
%26 = call i32 @raise(i32 %25)
br label %14
27: ; preds = %14
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@.str.1 = [10 x i8] c"Odd!: %d\0A\00"
@SIGUSR2 = global i32 0
@str = [15 x i8] c"Odds Waiting..\00"
define noalias i8* @two(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i8* %0 to i32*
%6 = load i32, i32* %5
%7 = bitcast i32* %3 to i8*
%8 = call i32 @sigemptyset(i32* %3)
%9 = load i32, i32* @SIGUSR1
%10 = call i32 @sigaddset(i32* %3, i32 %9)
%11 = icmp sgt i32 %6, 1
br i1 %11, label %12, label %21
12: ; preds = %1, %12
%13 = phi i32 [ %17, %12 ], [ 1, %1 ]
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%15 = call i32 @sigwait(i32* %3, i32* %2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%17 = add nuw nsw i32 %13, 2
%18 = load i32, i32* @SIGUSR2
%19 = call i32 @raise(i32 %18)
%20 = icmp slt i32 %17, %6
br i1 %20, label %12, label %21
21: ; preds = %12, %1
ret i8* undef
}