#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ eerrorx(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
char *getenv(char *);
scalar_t__ kill(int, int /*<<< orphan*/);
int sscanf(char const *, char *, int *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main(void) {
  const char *p = getenv("RC_PID");
  int pid;
  if (p && sscanf(p, "%d", &pid) == 1) {
    if (kill(pid, SIGUSR1) != 0)
      eerrorx("rc-abort: failed to signal parent %d: %s", pid, strerror(errno));
    return EXIT_SUCCESS;
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e8 <main+0x98>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11e8 <main+0x98>
mov    -0x14(%rbp),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
je     11d7 <main+0x87>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xe38(%rip),%rdi
call   1060 <eerrorx@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f4 <main+0xa4>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1030 <getenv@plt>
mov    0x2e6a(%rip),%rbx
test   %rax,%rax
je     11c4 <main+0x74>
lea    0xe95(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11c4 <main+0x74>
mov    0x4(%rsp),%edi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
mov    0x2e2b(%rip),%rbx
test   %rax,%rax
je     11c4 <main+0x74>
mov    0x4(%rsp),%ebp
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1060 <eerrorx@plt>
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"RC_PID\00"
@.str.1 = [3 x i8] c"%d\00"
@SIGUSR1 = global i32 0
@.str.2 = [41 x i8] c"rc-abort: failed to signal parent %d: %s\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* @SIGUSR1
%14 = call i64 @kill(i32 %12, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %3
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @eerrorx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %19)
br label %21
21: ; preds = %16, %11
%22 = load i32, i32* @EXIT_SUCCESS
store i32 %22, i32* %1
br label %25
23: ; preds = %7, %0
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %1
br label %25
25: ; preds = %23, %21
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [7 x i8] c"RC_PID\00"
@.str.1 = [3 x i8] c"%d\00"
@SIGUSR1 = global i32 0
@.str.2 = [41 x i8] c"rc-abort: failed to signal parent %d: %s\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = icmp eq i8* %2, null
br i1 %4, label %18, label %5
5: ; preds = %0
%6 = call i32 @sscanf(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %1
%10 = load i32, i32* @SIGUSR1
%11 = call i64 @kill(i32 %9, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i32, i32* %1
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @eerrorx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16)
br label %18
18: ; preds = %0, %5, %8, %13
%19 = phi i32* [ @EXIT_SUCCESS, %13 ], [ @EXIT_SUCCESS, %8 ], [ @EXIT_FAILURE, %5 ], [ @EXIT_FAILURE, %0 ]
%20 = load i32, i32* %19
ret i32 %20
}