#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*/ PR_GET_NAME;
int /*<<< orphan*/ PR_GET_PDEATHSIG;
int /*<<< orphan*/ perror(char *);
int prctl(int /*<<< orphan*/, unsigned long, int /*<<< orphan*/,
          int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char my_name[17];
  int pdeathsig;
  int r;
  r = prctl(PR_GET_PDEATHSIG, (unsigned long)&pdeathsig, 0, 0, 0);
  if (r != 0) {
    perror("Can't get PDEATHSIG: ");
  } else {
    printf("PDEATHSIG = %d.\n", pdeathsig);
  }
  my_name[16] = 0;
  r = prctl(PR_GET_NAME, (unsigned long)&my_name[0], 0, 0, 0);
  if (r != 0) {
    perror("Can't get NAME: ");
  } else {
    printf("NAME = %s.\n", my_name);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
lea    -0x34(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <prctl@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     117f <main+0x4f>
lea    0xe8b(%rip),%rdi
call   1050 <perror@plt>
jmp    1190 <main+0x60>
mov    -0x34(%rbp),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x20(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <prctl@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     11cd <main+0x9d>
lea    0xe64(%rip),%rdi
call   1050 <perror@plt>
jmp    11df <main+0xaf>
lea    -0x30(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <prctl@plt>
test   %eax,%eax
jne    11a1 <main+0x71>
mov    0xc(%rsp),%esi
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x0,0x20(%rsp)
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <prctl@plt>
test   %eax,%eax
jne    11af <main+0x7f>
lea    0xeaa(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe58(%rip),%rdi
call   1050 <perror@plt>
jmp    1164 <main+0x34>
lea    0xe71(%rip),%rdi
call   1050 <perror@plt>
jmp    119a <main+0x6a>

LLVM IR (-O0):
@PR_GET_PDEATHSIG = global i32 0
@.str = [22 x i8] c"Can't get PDEATHSIG: \00"
@.str.1 = [17 x i8] c"PDEATHSIG = %d.\0A\00"
@PR_GET_NAME = global i32 0
@.str.2 = [17 x i8] c"Can't get NAME: \00"
@.str.3 = [12 x i8] c"NAME = %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [17 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @PR_GET_PDEATHSIG
%10 = ptrtoint i32* %7 to i64
%11 = call i32 @prctl(i32 %9, i64 %10, i32 0, i32 0, i32 0)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %19
16: ; preds = %2
%17 = load i32, i32* %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 16
store i8 0, i8* %20
%21 = load i32, i32* @PR_GET_NAME
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%23 = ptrtoint i8* %22 to i64
%24 = call i32 @prctl(i32 %21, i64 %23, i32 0, i32 0, i32 0)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %32
29: ; preds = %19
%30 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %29, %27
ret i32 0
}

LLVM IR (-O2):
@PR_GET_PDEATHSIG = global i32 0
@.str = [22 x i8] c"Can't get PDEATHSIG: \00"
@.str.1 = [17 x i8] c"PDEATHSIG = %d.\0A\00"
@PR_GET_NAME = global i32 0
@.str.2 = [17 x i8] c"Can't get NAME: \00"
@.str.3 = [12 x i8] c"NAME = %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @PR_GET_PDEATHSIG
%8 = ptrtoint i32* %4 to i64
%9 = call i32 @prctl(i32 %7, i64 %8, i32 0, i32 0, i32 0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %16
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %11
%17 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 16
store i8 0, i8* %17
%18 = load i32, i32* @PR_GET_NAME
%19 = ptrtoint [17 x i8]* %3 to i64
%20 = call i32 @prctl(i32 %18, i64 %19, i32 0, i32 0, i32 0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %26
26: ; preds = %24, %22
ret i32 0
}