#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *);
int strlen(char *);
char *getArgsDeclaration(char *id, char *type, char *currentDeclaration) {
  int size = strlen(currentDeclaration) + strlen(id) + strlen(type) + 7;
  char *result = (char *)malloc(size);
  snprintf(result, size, "(%s: %s); %s", id, type, currentDeclaration);
  free(id);
  free(currentDeclaration);
  return result;
}


x86 assembly (clang, -O0):
<getArgsDeclaration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x7,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe51(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArgsDeclaration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %r12d,%ebp
add    %eax,%ebp
add    $0x7,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe76(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r13,%rcx
mov    %r15,%r8
mov    %r14,%r9
call   1050 <snprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"(%s: %s); %s\00"
define i8* @getArgsDeclaration(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 7
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = load i32, i32* %7
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = call i32 @snprintf(i8* %21, i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24, i8* %25)
%27 = load i8*, i8** %4
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %6
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %8
ret i8* %31
}

LLVM IR (-O2):
@.str = [13 x i8] c"(%s: %s); %s\00"
define i8* @getArgsDeclaration(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = add i32 %4, 7
%8 = add i32 %7, %5
%9 = add i32 %8, %6
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @snprintf(i8* %11, i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
%13 = tail call i32 @free(i8* %0)
%14 = tail call i32 @free(i8* %2)
ret i8* %11
}