#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*/ memcpy(char *, char const *, int);
int strlen(char const *);
int MPI_Get_processor_name(char *name, int *resultlen) {
  const char host[] = "localhost";
  int len;
  if (!name || !resultlen)
    return -1;
  len = strlen(host);
  memcpy(name, host, len + 1);
  *resultlen = len;
  return 0;
}


x86 assembly (clang, -O0):
<MPI_Get_processor_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xec6(%rip),%ax
mov    %ax,-0x1a(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115c <MPI_Get_processor_name+0x3c>
cmpq   $0x0,-0x18(%rbp)
jne    1168 <MPI_Get_processor_name+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    1197 <MPI_Get_processor_name+0x77>
lea    -0x22(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x22(%rbp),%rsi
mov    -0x28(%rbp),%edx
add    $0x1,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPI_Get_processor_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x736f686c61636f6c,%rax
68 6f 73
mov    %rax,0x8(%rsp)
movw   $0x74,0x10(%rsp)
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     117b <MPI_Get_processor_name+0x5b>
mov    %rsi,%r14
test   %rsi,%rsi
je     117b <MPI_Get_processor_name+0x5b>
mov    %rdi,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
lea    0x1(%r12),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <memcpy@plt>
mov    %r12d,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.MPI_Get_processor_name.host = [10 x i8] c"localhost\00"
define i32 @MPI_Get_processor_name(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [10 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = bitcast [10 x i8]* %6 to i8*
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = icmp ne i32* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11, %2
store i32 -1, i32* %3
br label %25
15: ; preds = %11
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %7
%18 = load i8*, i8** %4
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = call i32 @memcpy(i8* %18, i8* %19, i32 %21)
%23 = load i32, i32* %7
%24 = load i32*, i32** %5
store i32 %23, i32* %24
store i32 0, i32* %3
br label %25
25: ; preds = %15, %14
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@__const.MPI_Get_processor_name.host = [10 x i8] c"localhost\00"
define i32 @MPI_Get_processor_name(i8* %0, i32* writeonly %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = icmp ne i8* %0, null
%6 = icmp ne i32* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = call i32 @strlen(i8* %4)
%10 = add nsw i32 %9, 1
%11 = call i32 @memcpy(i8* %0, i8* %4, i32 %10)
store i32 %9, i32* %1
br label %12
12: ; preds = %2, %8
%13 = phi i32 [ 0, %8 ], [ -1, %2 ]
ret i32 %13
}