#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*/ EXIT_FAILURE;
int execl(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
void sig_handler(int signal) {
  printf("\nCHILD: signal %d received; now calling execl(prof_prog)...",
         signal);
  if (execl("prof_prog", "prof_prog", NULL) == -1) {
    perror("\nCHILD: execl failure");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<sig_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1060 <execl@plt>
cmp    $0xffffffff,%eax
jne    1190 <sig_handler+0x50>
lea    0xec9(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_handler>:
push   %rax
mov    %edi,%esi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1060 <execl@plt>
cmp    $0xffffffff,%eax
je     1167 <sig_handler+0x27>
pop    %rax
ret
lea    0xed8(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"\0ACHILD: signal %d received; now calling execl(prof_prog)...\00"
@.str.1 = [10 x i8] c"prof_prog\00"
@.str.2 = [22 x i8] c"\0ACHILD: execl failure\00"
@EXIT_FAILURE = global i32 0
define void @sig_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* null)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
ret void
}

LLVM IR (-O2):
@.str = [60 x i8] c"\0ACHILD: signal %d received; now calling execl(prof_prog)...\00"
@.str.1 = [10 x i8] c"prof_prog\00"
@.str.2 = [22 x i8] c"\0ACHILD: execl failure\00"
@EXIT_FAILURE = global i32 0
define void @sig_handler(i32 %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32* null)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
ret void
}