#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *locase(char const *);
char *malloc(size_t);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *, char const *,
                            char *);
int /*<<< orphan*/ stderr;
int strlen(char const *);
char *make_argname(const char *pname, const char *vname) {
  char *name;
  size_t len;
  len = strlen(pname) + strlen(vname) + strlen("argument") + 3;
  name = malloc(len);
  if (!name) {
    fprintf(stderr, "failed in malloc");
    exit(1);
  }
  snprintf(name, len, "%s_%s_%s", locase(pname), vname, "argument");
  return (name);
}


x86 assembly (clang, -O0):
<make_argname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
lea    0xe6a(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x3,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <make_argname+0x82>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <locase@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rcx
mov    -0x10(%rbp),%r8
lea    0xe09(%rip),%rdx
lea    0xde8(%rip),%r9
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_argname>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xe7a(%rip),%rdi
call   1030 <strlen@plt>
add    %ebp,%ebx
add    %ebx,%eax
add    $0x3,%eax
movslq %eax,%r12
mov    %r12,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     11d8 <make_argname+0x78>
mov    %rax,%rbx
mov    %r15,%rdi
call   1080 <locase@plt>
lea    0xe66(%rip),%rdx
lea    0xe45(%rip),%r9
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rax,%rcx
mov    %r14,%r8
call   1040 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"argument\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"failed in malloc\00"
@.str.2 = [9 x i8] c"%s_%s_%s\00"
define i8* @make_argname(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%13 = add nsw i32 %11, %12
%14 = add nsw i32 %13, 3
%15 = sext i32 %14 to i64
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i8*, i8** %5
%26 = load i64, i64* %6
%27 = load i8*, i8** %3
%28 = call i8* @locase(i8* %27)
%29 = load i8*, i8** %4
%30 = call i32 @snprintf(i8* %25, i64 %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%31 = load i8*, i8** %5
ret i8* %31
}

LLVM IR (-O2):
@.str = [9 x i8] c"argument\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"failed in malloc\00"
@.str.2 = [9 x i8] c"%s_%s_%s\00"
define i8* @make_argname(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = add i32 %3, 3
%7 = add i32 %6, %4
%8 = add i32 %7, %5
%9 = sext i32 %8 to i64
%10 = tail call i8* @malloc(i64 %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = tail call i8* @locase(i8* %0)
%18 = tail call i32 @snprintf(i8* %10, i64 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i8* %10
}