#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*/ SIGCONT;
int /*<<< orphan*/ SIGSTOP;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIG_IGN;
int getppid();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int main() {
  int sleeptime = 10;
  int ppid = getppid();
  kill(ppid, SIGSTOP);
  signal(SIGTERM, SIG_IGN);
  printf("sleeping for %d seconds\n", sleeptime);
  sleep(sleeptime);
  printf("still alive!\n");
  kill(ppid, SIGCONT);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    $0x0,%al
call   1060 <getppid@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
mov    -0x8(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <sleep@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <getppid@plt>
mov    %eax,%ebx
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <kill@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
lea    0xe68(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1080 <sleep@plt>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <kill@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SIGSTOP = global i32 0
@SIGTERM = global i32 0
@SIG_IGN = global i32 0
@.str = [25 x i8] c"sleeping for %d seconds\0A\00"
@.str.1 = [14 x i8] c"still alive!\0A\00"
@SIGCONT = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%4 = call i32 (...) @getppid()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = load i32, i32* @SIGSTOP
%7 = call i32 @kill(i32 %5, i32 %6)
%8 = load i32, i32* @SIGTERM
%9 = load i32, i32* @SIG_IGN
%10 = call i32 @signal(i32 %8, i32 %9)
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @sleep(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = load i32, i32* @SIGCONT
%18 = call i32 @kill(i32 %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@SIGSTOP = global i32 0
@SIGTERM = global i32 0
@SIG_IGN = global i32 0
@.str = [25 x i8] c"sleeping for %d seconds\0A\00"
@SIGCONT = global i32 0
@str = [13 x i8] c"still alive!\00"
define i32 @main() {
%1 = tail call i32 (...) @getppid()
%2 = load i32, i32* @SIGSTOP
%3 = tail call i32 @kill(i32 %1, i32 %2)
%4 = load i32, i32* @SIGTERM
%5 = load i32, i32* @SIG_IGN
%6 = tail call i32 @signal(i32 %4, i32 %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 10)
%8 = tail call i32 @sleep(i32 10)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @SIGCONT
%11 = tail call i32 @kill(i32 %1, i32 %10)
ret i32 0
}