#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 */
char *getenv(char *);
int strlen(char *);
char *strncpy(char *, char *, int);
void mumps_get_save_prefix_c(int *len_save_prefix, char *save_prefix, int l1) {
  char *tmp_save_prefix;
  tmp_save_prefix = getenv("MUMPS_SAVE_PREFIX");
  if (tmp_save_prefix == NULL) {
    tmp_save_prefix = "NAME_NOT_INITIALIZED";
  }
  *len_save_prefix = strlen(tmp_save_prefix);
  save_prefix = strncpy(save_prefix, tmp_save_prefix, l1);
}


x86 assembly (clang, -O0):
<mumps_get_save_prefix_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xeb6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1169 <mumps_get_save_prefix_c+0x39>
lea    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncpy@plt>
mov    %rax,-0x10(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mumps_get_save_prefix_c>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xeb9(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xebc(%rip),%rbx
cmovne %rax,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,0x0(%rbp)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strncpy@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"MUMPS_SAVE_PREFIX\00"
@.str.1 = [21 x i8] c"NAME_NOT_INITIALIZED\00"
define void @mumps_get_save_prefix_c(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %12
12: ; preds = %11, %3
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = load i32*, i32** %4
store i32 %14, i32* %15
%16 = load i8*, i8** %5
%17 = load i8*, i8** %7
%18 = load i32, i32* %6
%19 = call i8* @strncpy(i8* %16, i8* %17, i32 %18)
store i8* %19, i8** %5
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"MUMPS_SAVE_PREFIX\00"
@.str.1 = [21 x i8] c"NAME_NOT_INITIALIZED\00"
define void @mumps_get_save_prefix_c(i32* nocapture writeonly %0, i8* %1, i32 %2) {
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
%6 = select i1 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %4
%7 = tail call i32 @strlen(i8* %6)
store i32 %7, i32* %0
%8 = tail call i8* @strncpy(i8* %1, i8* %6, i32 %2)
ret void
}