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


x86 assembly (clang, -O0):
<dweib_toenvstring_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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 <dweib_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
shl    $0x1,%ecx
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    -0x20(%rbp),%r9
mov    -0x18(%rbp),%eax
lea    0xe08(%rip),%rsi
mov    %eax,(%rsp)
call   1060 <sprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dweib_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),%rbp
mov    0x8(%rbx),%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    0x0(%r13,%rbx,2),%ecx
lea    (%rax,%rcx,1),%edi
add    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14d,(%rsp)
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
mov    %rbp,%r9
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 = [41 x i8] c"dweib(state, %s, %s, pow(%s, -1/%s), %d)\00"
define i8* @dweib_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 = mul nsw i32 %30, 2
%32 = add nsw i32 %28, %31
%33 = load i8*, i8** %10
%34 = call i32 @strlen(i8* %33)
%35 = add nsw i32 %32, %34
%36 = add nsw i32 %35, 40
%37 = sext i32 %36 to i64
%38 = mul i64 1, %37
%39 = trunc i64 %38 to i32
%40 = call i8* @malloc(i32 %39)
store i8* %40, i8** %11
%41 = load i8*, i8** %11
%42 = load i8*, i8** %5
%43 = load i8*, i8** %9
%44 = load i8*, i8** %10
%45 = load i8*, i8** %9
%46 = load i32, i32* %8
%47 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %42, i8* %43, i8* %44, i8* %45, i32 %46)
%48 = load i8*, i8** %11
ret i8* %48
}

LLVM IR (-O2):
@.str = [41 x i8] c"dweib(state, %s, %s, pow(%s, -1/%s), %d)\00"
define noalias i8* @dweib_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 = shl nsw i32 %14, 1
%16 = tail call i32 @strlen(i8* %12)
%17 = add i32 %13, 40
%18 = add i32 %17, %15
%19 = add i32 %18, %16
%20 = tail call i8* @malloc(i32 %19)
%21 = tail call i32 @sprintf(i8* dereferenceable(1) %20, i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %10, i8* %12, i8* %10, i32 %3)
ret i8* %20
}