#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*/ assert(int);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, int);
int strlen(char *);
char *dbeta_toenvstring_density(char *x, char **par, unsigned int npar,
                                int give_log) {
  char *a, *b, *buff;
  assert(par != NULL && npar >= 2);
  a = par[0];
  b = par[1];
  buff = malloc(sizeof(char) * (strlen(x) + strlen(a) + strlen(b) + 40));
  sprintf(buff, "dbeta(state, %s, %s, %s, %d)", x, a, b, give_log);
  return buff;
}


x86 assembly (clang, -O0):
<dbeta_toenvstring_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x31(%rbp)
je     1170 <dbeta_toenvstring_density+0x30>
cmpl   $0x2,-0x14(%rbp)
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
add    $0x28,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x18(%rbp),%r9d
lea    0xe0e(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbeta_toenvstring_density>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
setne  %al
cmp    $0x2,%edx
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    (%rbx),%r13
mov    0x8(%rbx),%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <strlen@plt>
add    %ebx,%ebp
lea    (%rax,%rbp,1),%edi
add    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    %r14d,%r9d
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"dbeta(state, %s, %s, %s, %d)\00"
define i8* @dbeta_toenvstring_density(i8* %0, i8** %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i8**, i8*** %6
%13 = icmp ne i8** %12, null
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32, i32* %7
%16 = icmp uge i32 %15, 2
br label %17
17: ; preds = %14, %4
%18 = phi i1 [ false, %4 ], [ %16, %14 ]
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
store i8* %23, i8** %9
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %10
%27 = load i8*, i8** %5
%28 = call i32 @strlen(i8* %27)
%29 = load i8*, i8** %9
%30 = call i32 @strlen(i8* %29)
%31 = add nsw i32 %28, %30
%32 = load i8*, i8** %10
%33 = call i32 @strlen(i8* %32)
%34 = add nsw i32 %31, %33
%35 = add nsw i32 %34, 40
%36 = sext i32 %35 to i64
%37 = mul i64 1, %36
%38 = trunc i64 %37 to i32
%39 = call i8* @malloc(i32 %38)
store i8* %39, i8** %11
%40 = load i8*, i8** %11
%41 = load i8*, i8** %5
%42 = load i8*, i8** %9
%43 = load i8*, i8** %10
%44 = load i32, i32* %8
%45 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %41, i8* %42, i8* %43, i32 %44)
%46 = load i8*, i8** %11
ret i8* %46
}

LLVM IR (-O2):
@.str = [29 x i8] c"dbeta(state, %s, %s, %s, %d)\00"
define noalias i8* @dbeta_toenvstring_density(i8* %0, i8** %1, i32 %2, i32 %3) {
%5 = icmp ne i8** %1, null
%6 = icmp ugt i32 %2, 1
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* %0)
%14 = tail call i32 @strlen(i8* %10)
%15 = tail call i32 @strlen(i8* %12)
%16 = add i32 %13, 40
%17 = add i32 %16, %14
%18 = add i32 %17, %15
%19 = tail call i8* @malloc(i32 %18)
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %10, i8* %12, i32 %3)
ret i8* %19
}