#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 */
scalar_t__ asprintf(char **, char *, char *, char const *);
int /*<<< orphan*/ dub_die(char *, ...);
char *getenv(char *);
char *pparm_common_name(const char *postfix) {
  char *base = getenv("NAME");
  char *str = NULL;
  if (!base)
    dub_die("NAME not specified");
  if (asprintf(&str, "%s.%s", base, postfix) < 0)
    dub_die("Couldn't form name <%s.%s>", base, postfix);
  return str;
}


x86 assembly (clang, -O0):
<pparm_common_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <pparm_common_name+0x3d>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <dub_die@plt>
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <asprintf@plt>
cmp    $0x0,%rax
jge    11a5 <pparm_common_name+0x75>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <dub_die@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pparm_common_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
test   %rax,%rax
jne    1161 <pparm_common_name+0x31>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <dub_die@plt>
lea    0xeb0(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <asprintf@plt>
test   %rax,%rax
jns    118f <pparm_common_name+0x5f>
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <dub_die@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"NAME\00"
@.str.1 = [19 x i8] c"NAME not specified\00"
@.str.2 = [6 x i8] c"%s.%s\00"
@.str.3 = [27 x i8] c"Couldn't form name <%s.%s>\00"
define i8* @pparm_common_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %3
store i8* null, i8** %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 (i8*, ...) @dub_die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i64 @asprintf(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @dub_die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
br label %19
19: ; preds = %15, %10
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
@.str = [5 x i8] c"NAME\00"
@.str.1 = [19 x i8] c"NAME not specified\00"
@.str.2 = [6 x i8] c"%s.%s\00"
@.str.3 = [27 x i8] c"Couldn't form name <%s.%s>\00"
define i8* @pparm_common_name(i8* %0) {
%2 = alloca i8*
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = icmp eq i8* %3, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @dub_die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i64 @asprintf(i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* %0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @dub_die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %0)
br label %13
13: ; preds = %11, %8
%14 = load i8*, i8** %2
ret i8* %14
}