#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 */
scalar_t__ asprintf(char **, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int system(char *);
int run_cryptcreate(char *pass, char *crypt_cmd) {
  int retval;
  char *cmd;
  if (crypt_cmd == NULL || pass == NULL)
    return -1;
  if (asprintf(&cmd, "echo '%s' | %s >/dev/null 2>/dev/null", pass, crypt_cmd) <
      0)
    return -2;
  retval = system(cmd);
  free(cmd);
  return (retval);
}


x86 assembly (clang, -O0):
<run_cryptcreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1156 <run_cryptcreate+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    1162 <run_cryptcreate+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <run_cryptcreate+0x7b>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1050 <asprintf@plt>
cmp    $0x0,%rax
jge    1190 <run_cryptcreate+0x60>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11ab <run_cryptcreate+0x7b>
mov    -0x28(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_cryptcreate>:
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     117d <run_cryptcreate+0x4d>
mov    %rsi,%rcx
test   %rsi,%rsi
je     117d <run_cryptcreate+0x4d>
mov    %rdi,%rdx
lea    0xeaf(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <asprintf@plt>
test   %rax,%rax
js     1178 <run_cryptcreate+0x48>
mov    0x8(%rsp),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    117d <run_cryptcreate+0x4d>
mov    $0xfffffffe,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"echo '%s' | %s >/dev/null 2>/dev/null\00"
define i32 @run_cryptcreate(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store i32 -1, i32* %3
br label %26
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i64 @asprintf(i8** %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 -2, i32* %3
br label %26
20: ; preds = %14
%21 = load i8*, i8** %7
%22 = call i32 @system(i8* %21)
store i32 %22, i32* %6
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %26
26: ; preds = %20, %19, %13
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [38 x i8] c"echo '%s' | %s >/dev/null 2>/dev/null\00"
define i32 @run_cryptcreate(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i8* %1, null
%6 = icmp eq i8* %0, null
%7 = or i1 %6, %5
br i1 %7, label %16, label %8
8: ; preds = %2
%9 = call i64 @asprintf(i8** %3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = call i32 @system(i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
br label %16
16: ; preds = %8, %2, %11
%17 = phi i32 [ %13, %11 ], [ -1, %2 ], [ -2, %8 ]
ret i32 %17
}