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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ mq_send(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/);
int child(mqd_t gq, mqd_t bq) {
  srand(time(0));
  int status = rand() % 2;
  if (status == 0) {
    printf("Hello world\n");
    mq_send(gq, NULL, NULL, NULL);
    fflush(stdout);
  } else {
    printf("Bye world\n");
    mq_send(bq, NULL, NULL, NULL);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11c9 <child+0x69>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <mq_send@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    11f5 <child+0x95>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <mq_send@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<child>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
test   $0x1,%al
lea    0xe85(%rip),%rax
lea    0xe74(%rip),%rdi
cmove  %rax,%rdi
cmovne %ebp,%ebx
call   1030 <puts@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <mq_send@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <fflush@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Hello world\0A\00"
@stdout = global i32 0
@.str.1 = [11 x i8] c"Bye world\0A\00"
define i32 @child(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = call i32 @time(i32 0)
%8 = call i32 @srand(i32 %7)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 2
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = call i32 @mq_send(i32 %15, i32* null, i32* null, i32* null)
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
br label %25
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %5
%22 = call i32 @mq_send(i32 %21, i32* null, i32* null, i32* null)
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
br label %25
25: ; preds = %19, %13
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [10 x i8] c"Bye world\00"
@str.2 = [12 x i8] c"Hello world\00"
define i32 @child(i32 %0, i32 %1) {
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0)
%9 = select i1 %7, i32 %0, i32 %1
%10 = tail call i32 @puts(i8* dereferenceable(1) %8)
%11 = tail call i32 @mq_send(i32 %9, i32* null, i32* null, i32* null)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
ret i32 undef
}