#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*/ SIGALRM;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ execve(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
main() {
  open("/dev/urandom", 0);
  open("/dev/null", 0);
  open("/dev/urandom", 0);
  signal(SIGINT, SIG_IGN);
  signal(SIGALRM, SIG_IGN);
  sigset_t mask, oldmask;
  sigemptyset(&mask);
  sigaddset(&mask, SIGALRM);
  sigprocmask(SIG_BLOCK, &mask, &oldmask);
  execve("./times-up-one-last-time", NULL, NULL);
  printf("Error");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
xor    %esi,%esi
call   1080 <open@plt>
lea    0xe80(%rip),%rdi
xor    %esi,%esi
call   1080 <open@plt>
lea    0xe65(%rip),%rdi
xor    %esi,%esi
call   1080 <open@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
lea    -0x4(%rbp),%rdi
call   1070 <sigemptyset@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1090 <sigaddset@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <execve@plt>
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <open@plt>
lea    0xe81(%rip),%rdi
xor    %esi,%esi
call   1080 <open@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <open@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x2e2b(%rip),%rbx
mov    (%rbx),%esi
call   1060 <signal@plt>
mov    0x2e2d(%rip),%r14
mov    (%r14),%edi
mov    (%rbx),%esi
call   1060 <signal@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sigemptyset@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1090 <sigaddset@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1030 <sigprocmask@plt>
lea    0xe1f(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <execve@plt>
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [10 x i8] c"/dev/null\00"
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@.str.2 = [25 x i8] c"./times-up-one-last-time\00"
@.str.3 = [6 x i8] c"Error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 0)
%5 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = load i32, i32* @SIGINT
%7 = load i32, i32* @SIG_IGN
%8 = call i32 @signal(i32 %6, i32 %7)
%9 = load i32, i32* @SIGALRM
%10 = load i32, i32* @SIG_IGN
%11 = call i32 @signal(i32 %9, i32 %10)
%12 = call i32 @sigemptyset(i32* %1)
%13 = load i32, i32* @SIGALRM
%14 = call i32 @sigaddset(i32* %1, i32 %13)
%15 = load i32, i32* @SIG_BLOCK
%16 = call i32 @sigprocmask(i32 %15, i32* %1, i32* %2)
%17 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null)
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [10 x i8] c"/dev/null\00"
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@.str.2 = [25 x i8] c"./times-up-one-last-time\00"
@.str.3 = [6 x i8] c"Error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 0)
%5 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = load i32, i32* @SIGINT
%7 = load i32, i32* @SIG_IGN
%8 = tail call i32 @signal(i32 %6, i32 %7)
%9 = load i32, i32* @SIGALRM
%10 = load i32, i32* @SIG_IGN
%11 = tail call i32 @signal(i32 %9, i32 %10)
%12 = bitcast i32* %1 to i8*
%13 = bitcast i32* %2 to i8*
%14 = call i32 @sigemptyset(i32* %1)
%15 = load i32, i32* @SIGALRM
%16 = call i32 @sigaddset(i32* %1, i32 %15)
%17 = load i32, i32* @SIG_BLOCK
%18 = call i32 @sigprocmask(i32 %17, i32* %1, i32* %2)
%19 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null)
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}