#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*/ SIG_BLOCK;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  sigset_t sigs;
  sigemptyset(&sigs);
  sigaddset(&sigs, SIGALRM);
  sigprocmask(SIG_BLOCK, &sigs, 0);
  if (argc > 1) {
    execvp(argv[1], argv + 1);
    perror("execv");
  } else {
    fprintf(stderr, "Usage: %s <command> [args...]\n", argv[0]);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11d5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1070 <execvp@plt>
lea    0xe35(%rip),%rdi
call   1060 <perror@plt>
jmp    11f1 <main+0x91>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <sigaddset@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0x2,%ebp
jge    11c9 <main+0x69>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%r14),%rdi
add    $0x8,%r14
mov    %r14,%rsi
call   1070 <execvp@plt>
lea    0xe20(%rip),%rdi
call   1060 <perror@plt>
jmp    11bb <main+0x5b>

LLVM IR (-O0):
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@.str = [6 x i8] c"execv\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"Usage: %s <command> [args...]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @sigemptyset(i32* %6)
%8 = load i32, i32* @SIGALRM
%9 = call i32 @sigaddset(i32* %6, i32 %8)
%10 = load i32, i32* @SIG_BLOCK
%11 = call i32 @sigprocmask(i32 %10, i32* %6, i32 0)
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = call i32 @execvp(i8* %17, i8** %19)
%21 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %28
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %22, %14
ret i32 1
}

LLVM IR (-O2):
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@.str = [6 x i8] c"execv\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"Usage: %s <command> [args...]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @sigemptyset(i32* %3)
%6 = load i32, i32* @SIGALRM
%7 = call i32 @sigaddset(i32* %3, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* %3, i32 0)
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @execvp(i8* %13, i8** %12)
%15 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %11
ret i32 1
}