#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 */
union sigval {
  int sival_int;
};

/* Variables and functions */
#define SIGHUP 131
#define SIGILL 130
#define SIGINT 129
#define SIGQUIT 128
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getppid();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigqueue(int /*<<< orphan*/, int /*<<< orphan*/,
                            union sigval);
int /*<<< orphan*/ stderr;
void seller(int sig) {
  switch (sig) {
  case SIGHUP:
    kill(getppid(), SIGUSR1);
    break;
  case SIGINT:
    kill(getppid(), SIGUSR2);
    break;
    union sigval val;
  case SIGILL:
    val.sival_int = 123;
    sigqueue(getppid(), SIGTSTP, val);
    break;
  case SIGQUIT:
    fprintf(stderr, "seller: All get off the bus!\n");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<seller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11fe <seller+0xae>
mov    -0x10(%rbp),%rax
lea    0xe85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <getppid@plt>
mov    %eax,%edi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
jmp    11fe <seller+0xae>
mov    $0x0,%al
call   1060 <getppid@plt>
mov    %eax,%edi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
jmp    11fe <seller+0xae>
movl   $0x7b,-0x8(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    %eax,%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
call   1050 <sigqueue@plt>
jmp    11fe <seller+0xae>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seller>:
push   %rax
add    $0xffffff80,%edi
cmp    $0x3,%edi
ja     1179 <seller+0x29>
lea    0xea0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1060 <getppid@plt>
mov    0x2e51(%rip),%rcx
jmp    11a6 <seller+0x56>
pop    %rax
ret
xor    %eax,%eax
call   1060 <getppid@plt>
mov    0x2e57(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
mov    $0x7b,%edx
pop    %rax
jmp    1050 <sigqueue@plt>
xor    %eax,%eax
call   1060 <getppid@plt>
mov    0x2e42(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
pop    %rax
jmp    1040 <kill@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%union.sigval = type { i32 }
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGTSTP = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"seller: All get off the bus!\0A\00"
define void @seller(i32 %0) {
%2 = alloca i32
%3 = alloca %union.sigval
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %24 [
i32 131, label %5
i32 129, label %9
i32 130, label %13
i32 128, label %20
]
5: ; preds = %1
%6 = call i32 (...) @getppid()
%7 = load i32, i32* @SIGUSR1
%8 = call i32 @kill(i32 %6, i32 %7)
br label %24
9: ; preds = %1
%10 = call i32 (...) @getppid()
%11 = load i32, i32* @SIGUSR2
%12 = call i32 @kill(i32 %10, i32 %11)
br label %24
13: ; preds = %1
%14 = bitcast %union.sigval* %3 to i32*
store i32 123, i32* %14
%15 = call i32 (...) @getppid()
%16 = load i32, i32* @SIGTSTP
%17 = getelementptr inbounds %union.sigval, %union.sigval* %3, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @sigqueue(i32 %15, i32 %16, i32 %18)
br label %24
20: ; preds = %1
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %1, %13, %9, %5
ret void
}

LLVM IR (-O2):
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGTSTP = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"seller: All get off the bus!\0A\00"
define void @seller(i32 %0) {
switch i32 %0, label %18 [
i32 131, label %2
i32 129, label %6
i32 130, label %10
i32 128, label %14
]
2: ; preds = %1
%3 = tail call i32 (...) @getppid()
%4 = load i32, i32* @SIGUSR1
%5 = tail call i32 @kill(i32 %3, i32 %4)
br label %18
6: ; preds = %1
%7 = tail call i32 (...) @getppid()
%8 = load i32, i32* @SIGUSR2
%9 = tail call i32 @kill(i32 %7, i32 %8)
br label %18
10: ; preds = %1
%11 = tail call i32 (...) @getppid()
%12 = load i32, i32* @SIGTSTP
%13 = tail call i32 @sigqueue(i32 %11, i32 %12, i32 123)
br label %18
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %1, %10, %6, %2
ret void
}