#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*/ buffer;

/* Variables and functions */
int getpid();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sprintf(char *, char *, ...);
const char *__GetProcessID() {
  static char buffer[32];
  memset(buffer, 0, sizeof(buffer));
  int res = sprintf(buffer, "_");
  sprintf(buffer + res, "%d", getpid());
  return buffer;
}


x86 assembly (clang, -O0):
<__GetProcessID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x2f11(%rip),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    0x2efe(%rip),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2ee2(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%edx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    0x2eb9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__GetProcessID>:
push   %rbx
lea    0x2f18(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
movw   $0x5f,0x2f00(%rip)
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0x2ef3(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@__GetProcessID.buffer = internal global [32 x i8] zeroinitializer
@.str = [2 x i8] c"_\00"
@.str.1 = [3 x i8] c"%d\00"
define i8* @__GetProcessID() {
%1 = alloca i32
%2 = call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0), i32 0, i32 32)
%3 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0), i64 %5
%7 = call i32 (...) @getpid()
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@__GetProcessID.buffer = internal global [32 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
define i8* @__GetProcessID() {
%1 = tail call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0), i32 0, i32 32)
store i16 95, i16* bitcast ([32 x i8]* @__GetProcessID.buffer to i16*)
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 1), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %2)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__GetProcessID.buffer, i64 0, i64 0)
}