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

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ dprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getppid();
scalar_t__ kill(int /*<<< orphan*/, int);
int /*<<< orphan*/ sched_yield();
int /*<<< orphan*/ usleep(int);
void __attribute__((noreturn)) signal_sender(int signo, bool sleep) {
  pid_t target = getppid();
  while (true) {
    if (kill(target, signo) != 0) {
      dprintf(STDOUT_FILENO, "error: kill: %m\n");
      abort();
    }
    if (sleep)
      usleep(1 * 1000 * 1000);
    else
      sched_yield();
  }
}


x86 assembly (clang, -O0):
<signal_sender>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1060 <kill@plt>
cmp    $0x0,%rax
je     11a9 <signal_sender+0x49>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1040 <dprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c2 <signal_sender+0x62>
mov    $0xf4240,%edi
call   1080 <usleep@plt>
jmp    11c9 <signal_sender+0x69>
mov    $0x0,%al
call   1050 <sched_yield@plt>
jmp    1178 <signal_sender+0x18>

x86 assembly (clang, -O2):
<signal_sender>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <getppid@plt>
mov    %eax,%ebx
mov    %eax,%edi
jmp    118c <signal_sender+0x2c>
cs nopw 0x0(%rax,%rax,1)
mov    $0xf4240,%edi
call   1080 <usleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <kill@plt>
test   %rax,%rax
jne    11a8 <signal_sender+0x48>
test   %r14d,%r14d
jne    1180 <signal_sender+0x20>
xor    %eax,%eax
call   1050 <sched_yield@plt>
mov    %ebx,%edi
jmp    118c <signal_sender+0x2c>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
call   1040 <dprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [17 x i8] c"error: kill: %m\0A\00"
define void @signal_sender(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 (...) @getppid()
store i32 %6, i32* %5
br label %7
7: ; preds = %2, %23
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = call i64 @kill(i32 %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @STDOUT_FILENO
%14 = call i32 @dprintf(i32 %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %7
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @usleep(i32 1000000)
br label %23
21: ; preds = %16
%22 = call i32 (...) @sched_yield()
br label %23
23: ; preds = %21, %19
br label %7
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [17 x i8] c"error: kill: %m\0A\00"
define void @signal_sender(i32 %0, i32 %1) {
%3 = tail call i32 (...) @getppid()
%4 = tail call i64 @kill(i32 %3, i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br label %12
8: ; preds = %17, %2
%9 = load i32, i32* @STDOUT_FILENO
%10 = tail call i32 @dprintf(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %6, %17
br i1 %7, label %15, label %13
13: ; preds = %12
%14 = tail call i32 @usleep(i32 1000000)
br label %17
15: ; preds = %12
%16 = tail call i32 (...) @sched_yield()
br label %17
17: ; preds = %15, %13
%18 = tail call i64 @kill(i32 %3, i32 %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %12, label %8
}