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


x86 assembly (clang, -O0):
<dexp_toenvstring_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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,-0x29(%rbp)
je     1170 <dexp_toenvstring_density+0x30>
cmpl   $0x1,-0x14(%rbp)
setae  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
add    $0x28,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8d
lea    0xe31(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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