#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_library_version(char *version, int *resultlen) {
  const char string[] = "LAMMPS MPI STUBS for LAMMPS version "
                        "19 Sep 2019";
  int len;
  if (!version || !resultlen)
    return -1;
  len = strlen(string);
  memcpy(version, string, len + 1);
  *resultlen = len;
  return 0;
}


x86 assembly (clang, -O0):
<MPI_Get_library_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
cmpq   $0x0,-0x10(%rbp)
je     115b <MPI_Get_library_version+0x3b>
cmpq   $0x0,-0x18(%rbp)
jne    1167 <MPI_Get_library_version+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <MPI_Get_library_version+0x76>
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
add    $0x1,%edx
call   1040 <memcpy@plt>
mov    -0x54(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPI_Get_library_version>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps 0xeee(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1186 <MPI_Get_library_version+0x66>
mov    %rsi,%r14
test   %rsi,%rsi
je     1186 <MPI_Get_library_version+0x66>
mov    %rdi,%rbx
mov    %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    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.MPI_Get_library_version.string = [48 x i8] c"LAMMPS MPI STUBS for LAMMPS version 19 Sep 2019\00"
define i32 @MPI_Get_library_version(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [48 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = bitcast [48 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 [48 x i8], [48 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 [48 x i8], [48 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_library_version.string = [48 x i8] c"LAMMPS MPI STUBS for LAMMPS version 19 Sep 2019\00"
define i32 @MPI_Get_library_version(i8* %0, i32* writeonly %1) {
%3 = alloca [48 x i8]
%4 = getelementptr inbounds [48 x i8], [48 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
}