#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*/ FILE;

/* Variables and functions */
scalar_t__ calloc(unsigned int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, unsigned int);
char *passgen(char *ppassgen_path, unsigned int length) {
  char *pcmd = (char *)calloc(1024, sizeof(char));
  sprintf(pcmd, "%s -c 1 -l %d", ppassgen_path, length);
  FILE *pfd = popen(pcmd, "r");
  char *ppass = (char *)calloc(length, sizeof(char));
  fscanf(pfd, "%s", ppass);
  pclose(pfd);
  free(pcmd);
  return ppass;
}


x86 assembly (clang, -O0):
<passgen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe6c(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe43(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passgen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
mov    $0x400,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
lea    0xe79(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1080 <sprintf@plt>
lea    0xe72(%rip),%rsi
mov    %r12,%rdi
call   1070 <popen@plt>
mov    %rax,%rbp
mov    %r15d,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
lea    0xe52(%rip),%rsi
mov    %rbp,%rdi
mov    %rax,%rdx
call   1050 <fscanf@plt>
mov    %rbp,%rdi
call   1040 <pclose@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%s -c 1 -l %d\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i8* @passgen(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = call i64 @calloc(i32 1024, i32 1)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12)
%14 = load i8*, i8** %5
%15 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32, i32* %4
%17 = call i64 @calloc(i32 %16, i32 1)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %7
%19 = load i32*, i32** %6
%20 = load i8*, i8** %7
%21 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** %6
%23 = call i32 @pclose(i32* %22)
%24 = load i8*, i8** %5
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %7
ret i8* %26
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s -c 1 -l %d\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i8* @passgen(i8* %0, i32 %1) {
%3 = tail call i64 @calloc(i32 1024, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%6 = tail call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i64 @calloc(i32 %1, i32 1)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @pclose(i32* %6)
%11 = tail call i32 @free(i8* %4)
ret i8* %8
}