#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 */
typedef int /*<<< orphan*/ output;

/* Variables and functions */
int /*<<< orphan*/ ENOMEM;
char *crypt_gensalt_rn(char const *, unsigned long, char const *, int, char *,
                       int);
int /*<<< orphan*/ errno;
char *strdup(char *);
char *crypt_gensalt_ra(const char *prefix, unsigned long count,
                       const char *input, int size) {
  char output[(7 + 22 + 1)];
  char *retval;
  retval = crypt_gensalt_rn(prefix, count, input, size, output, sizeof(output));
  if (retval) {
    retval = strdup(retval);
    if (!retval)
      errno = (ENOMEM);
  }
  return retval;
}


x86 assembly (clang, -O0):
<crypt_gensalt_ra>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    -0x40(%rbp),%r8
mov    $0x1e,%r9d
call   1030 <crypt_gensalt_rn@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1193 <crypt_gensalt_ra+0x73>
mov    -0x48(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    118e <crypt_gensalt_ra+0x6e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e4c(%rip),%rax
mov    %ecx,(%rax)
jmp    1193 <crypt_gensalt_ra+0x73>
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt_gensalt_ra>:
sub    $0x28,%rsp
mov    %rsp,%r8
mov    $0x1e,%r9d
call   1030 <crypt_gensalt_rn@plt>
test   %rax,%rax
je     115b <crypt_gensalt_ra+0x3b>
mov    %rax,%rdi
call   1040 <strdup@plt>
test   %rax,%rax
je     1149 <crypt_gensalt_ra+0x29>
add    $0x28,%rsp
ret
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
mov    0x2e7f(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@ENOMEM = global i32 0
@errno = global i32 0
define i8* @crypt_gensalt_ra(i8* %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [30 x i8]
%10 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = load i8*, i8** %7
%14 = load i32, i32* %8
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %9, i64 0, i64 0
%16 = call i8* @crypt_gensalt_rn(i8* %11, i64 %12, i8* %13, i32 %14, i8* %15, i32 30)
store i8* %16, i8** %10
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %4
%20 = load i8*, i8** %10
%21 = call i8* @strdup(i8* %20)
store i8* %21, i8** %10
%22 = load i8*, i8** %10
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = load i32, i32* @ENOMEM
store i32 %25, i32* @errno
br label %26
26: ; preds = %24, %19
br label %27
27: ; preds = %26, %4
%28 = load i8*, i8** %10
ret i8* %28
}

LLVM IR (-O2):
@ENOMEM = global i32 0
@errno = global i32 0
define noalias i8* @crypt_gensalt_ra(i8* %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca [30 x i8]
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%7 = call i8* @crypt_gensalt_rn(i8* %0, i64 %1, i8* %2, i32 %3, i8* %6, i32 30)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = call i8* @strdup(i8* %7)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32, i32* @ENOMEM
store i32 %13, i32* @errno
br label %14
14: ; preds = %9, %12, %4
%15 = phi i8* [ %10, %9 ], [ null, %12 ], [ null, %4 ]
ret i8* %15
}