#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_SET_NAME;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ xprctl(int /*<<< orphan*/, unsigned long, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  char name[80];
  xprctl(PR_GET_NAME, (unsigned long)name, 0, 0, 0);
  printf("%s\n", name);
  strcpy(name, "test");
  xprctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);
  printf("%s\n", name);
  for (;;)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <xprctl@plt>
lea    -0x60(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1050 <xprctl@plt>
lea    -0x60(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
jmp    11a5 <main+0x75>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <xprctl@plt>
lea    0xea7(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <xprctl@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@PR_GET_NAME = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"test\00"
@PR_SET_NAME = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
store i32 0, i32* %1
%3 = load i32, i32* @PR_GET_NAME
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = ptrtoint i8* %4 to i64
%6 = call i32 @xprctl(i32 %3, i64 %5, i32 0, i32 0, i32 0)
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @PR_SET_NAME
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = ptrtoint i8* %12 to i64
%14 = call i32 @xprctl(i32 %11, i64 %13, i32 0, i32 0, i32 0)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %17, %0
br label %17
}

LLVM IR (-O2):
@PR_GET_NAME = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"test\00"
@PR_SET_NAME = global i32 0
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @PR_GET_NAME
%4 = ptrtoint [80 x i8]* %1 to i64
%5 = call i32 @xprctl(i32 %3, i64 %4, i32 0, i32 0, i32 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @PR_SET_NAME
%9 = call i32 @xprctl(i32 %8, i64 %4, i32 0, i32 0, i32 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %11
11: ; preds = %11, %0
br label %11
}