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

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_f_buffer();
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int BIO_gets(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_fd(int, int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_file(char *, char *);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ INT_MAX;
char *getenv(char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
char *strdup(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int strtonum(char *, int /*<<< orphan*/, int /*<<< orphan*/, char const **);
char *app_get_pass(BIO *err, char *arg, int keepbio) {
  char *tmp, tpass[1024];
  static BIO *pwdbio = NULL;
  const char *errstr = NULL;
  int i;
  if (!strncmp(arg, "pass:", 5))
    return strdup(arg + 5);
  if (!strncmp(arg, "env:", 4)) {
    tmp = getenv(arg + 4);
    if (!tmp) {
      BIO_printf(err, "Can't read environment variable %s\n", arg + 4);
      return NULL;
    }
    return strdup(tmp);
  }
  if (!keepbio || !pwdbio) {
    if (!strncmp(arg, "file:", 5)) {
      pwdbio = BIO_new_file(arg + 5, "r");
      if (!pwdbio) {
        BIO_printf(err, "Can't open file %s\n", arg + 5);
        return NULL;
      }
    } else if (!strncmp(arg, "fd:", 3)) {
      BIO *btmp;
      i = strtonum(arg + 3, 0, INT_MAX, &errstr);
      if (errstr) {
        BIO_printf(err, "Invalid file descriptor %s: %s\n", arg, errstr);
        return NULL;
      }
      pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
      if (!pwdbio) {
        BIO_printf(err, "Can't access file descriptor %s\n", arg + 3);
        return NULL;
      }
      btmp = BIO_new(BIO_f_buffer());
      pwdbio = BIO_push(btmp, pwdbio);
    } else if (!strcmp(arg, "stdin")) {
      pwdbio = BIO_new_fp(stdin, BIO_NOCLOSE);
      if (!pwdbio) {
        BIO_printf(err, "Can't open BIO for stdin\n");
        return NULL;
      }
    } else {
      BIO_printf(err, "Invalid password argument \"%s\"\n", arg);
      return NULL;
    }
  }
  i = BIO_gets(pwdbio, tpass, 1024);
  if (keepbio != 1) {
    BIO_free_all(pwdbio);
    pwdbio = NULL;
  }
  if (i <= 0) {
    BIO_printf(err, "Error reading password from BIO\n");
    return NULL;
  }
  tmp = strchr(tpass, '\n');
  if (tmp)
    *tmp = 0;
  return strdup(tpass);
}


x86 assembly (clang, -O0):
<app_get_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movq   $0x0,-0x438(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1245 <app_get_pass+0x55>
mov    -0x18(%rbp),%rdi
add    $0x5,%rdi
call   1100 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
mov    -0x18(%rbp),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    12b8 <app_get_pass+0xc8>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12a6 <app_get_pass+0xb6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x4,%rdx
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
mov    -0x28(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
cmpl   $0x0,-0x1c(%rbp)
je     12d0 <app_get_pass+0xe0>
cmpq   $0x0,0x2dd6(%rip)
jne    14dd <app_get_pass+0x2ed>
mov    -0x18(%rbp),%rdi
lea    0xd54(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1343 <app_get_pass+0x153>
mov    -0x18(%rbp),%rdi
add    $0x5,%rdi
lea    0xd38(%rip),%rsi
call   1110 <BIO_new_file@plt>
mov    %rax,0x2d97(%rip)
cmpq   $0x0,0x2d8f(%rip)
jne    133e <app_get_pass+0x14e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x5,%rdx
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
jmp    14d8 <app_get_pass+0x2e8>
mov    -0x18(%rbp),%rdi
lea    0xcfd(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1442 <app_get_pass+0x252>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
mov    0x2c68(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
lea    -0x438(%rbp),%rcx
call   10e0 <strtonum@plt>
mov    %eax,-0x43c(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     13be <app_get_pass+0x1ce>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x438(%rbp),%rcx
lea    0xca5(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
mov    -0x43c(%rbp),%edi
mov    0x2c1d(%rip),%rax
mov    (%rax),%esi
call   1060 <BIO_new_fd@plt>
mov    %rax,0x2cc7(%rip)
cmpq   $0x0,0x2cbf(%rip)
jne    140e <app_get_pass+0x21e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x3,%rdx
lea    0xc75(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
mov    $0x0,%al
call   10b0 <BIO_f_buffer@plt>
mov    %eax,%edi
call   10c0 <BIO_new@plt>
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rdi
mov    0x2c6f(%rip),%rsi
call   1070 <BIO_push@plt>
mov    %rax,0x2c63(%rip)
jmp    14d3 <app_get_pass+0x2e3>
mov    -0x18(%rbp),%rdi
lea    0xc43(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    14ab <app_get_pass+0x2bb>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
mov    0x2b7d(%rip),%rax
mov    (%rax),%esi
call   1040 <BIO_new_fp@plt>
mov    %rax,0x2c27(%rip)
cmpq   $0x0,0x2c1f(%rip)
jne    14a6 <app_get_pass+0x2b6>
mov    -0x10(%rbp),%rdi
lea    0xc04(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
jmp    14ce <app_get_pass+0x2de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xbf6(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
jmp    14d3 <app_get_pass+0x2e3>
jmp    14d8 <app_get_pass+0x2e8>
jmp    14dd <app_get_pass+0x2ed>
mov    0x2bbc(%rip),%rdi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   10d0 <BIO_gets@plt>
mov    %eax,-0x43c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     151c <app_get_pass+0x32c>
mov    0x2b94(%rip),%rdi
call   10f0 <BIO_free_all@plt>
movq   $0x0,0x2b84(%rip)
cmpl   $0x0,-0x43c(%rbp)
jg     1548 <app_get_pass+0x358>
mov    -0x10(%rbp),%rdi
lea    0xb9c(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    157f <app_get_pass+0x38f>
lea    -0x430(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     156f <app_get_pass+0x37f>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x430(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<app_get_pass>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     12b8 <app_get_pass+0xc8>
lea    0xdd5(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     12c1 <app_get_pass+0xd1>
test   %ebp,%ebp
je     12e7 <app_get_pass+0xf7>
mov    0x2e4f(%rip),%rdi
test   %rdi,%rdi
je     12e7 <app_get_pass+0xf7>
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   10d0 <BIO_gets@plt>
mov    %eax,%ebx
cmp    $0x1,%ebp
je     1287 <app_get_pass+0x97>
mov    0x2e29(%rip),%rdi
call   10f0 <BIO_free_all@plt>
movq   $0x0,0x2e19(%rip)
test   %ebx,%ebx
jle    133b <app_get_pass+0x14b>
lea    0x10(%rsp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     12a6 <app_get_pass+0xb6>
movb   $0x0,(%rax)
lea    0x10(%rsp),%rdi
call   1100 <strdup@plt>
mov    %rax,%rbp
jmp    1395 <app_get_pass+0x1a5>
add    $0x5,%rbx
mov    %rbx,%rdi
jmp    12d5 <app_get_pass+0xe5>
add    $0x4,%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1350 <app_get_pass+0x160>
mov    %rax,%rdi
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1100 <strdup@plt>
lea    0xd41(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     1359 <app_get_pass+0x169>
lea    0xd45(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     13a6 <app_get_pass+0x1b6>
lea    0xd6e(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     13e4 <app_get_pass+0x1f4>
lea    0xd77(%rip),%rsi
jmp    1386 <app_get_pass+0x196>
lea    0xd8e(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <BIO_printf@plt>
jmp    1395 <app_get_pass+0x1a5>
lea    0xcb4(%rip),%rsi
jmp    1386 <app_get_pass+0x196>
add    $0x5,%rbx
lea    0xcd1(%rip),%rsi
mov    %rbx,%rdi
call   1110 <BIO_new_file@plt>
mov    %rax,%rdi
mov    %rax,0x2d2a(%rip)
test   %rax,%rax
jne    125a <app_get_pass+0x6a>
lea    0xcb1(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <BIO_printf@plt>
mov    %rbp,%rax
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x3(%rbx),%r15
mov    0x2c27(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %r15,%rdi
xor    %esi,%esi
call   10e0 <strtonum@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     141a <app_get_pass+0x22a>
lea    0xc7c(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <BIO_printf@plt>
jmp    1395 <app_get_pass+0x1a5>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    0x2bf4(%rip),%rax
mov    (%rax),%esi
call   1040 <BIO_new_fp@plt>
mov    %rax,%rdi
mov    %rax,0x2c9b(%rip)
test   %rax,%rax
jne    125a <app_get_pass+0x6a>
lea    0xc81(%rip),%rsi
jmp    1342 <app_get_pass+0x152>
mov    0x2bc7(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1060 <BIO_new_fd@plt>
mov    %rax,0x2c6f(%rip)
test   %rax,%rax
je     1462 <app_get_pass+0x272>
xor    %eax,%eax
call   10b0 <BIO_f_buffer@plt>
mov    %eax,%edi
call   10c0 <BIO_new@plt>
mov    0x2c55(%rip),%rsi
mov    %rax,%rdi
call   1070 <BIO_push@plt>
mov    %rax,%rdi
mov    %rax,0x2c43(%rip)
jmp    125a <app_get_pass+0x6a>
lea    0xc06(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rdx
jmp    138e <app_get_pass+0x19e>

LLVM IR (-O0):
@app_get_pass.pwdbio = internal global i32* null
@.str = [6 x i8] c"pass:\00"
@.str.1 = [5 x i8] c"env:\00"
@.str.2 = [36 x i8] c"Can't read environment variable %s\0A\00"
@.str.3 = [6 x i8] c"file:\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [20 x i8] c"Can't open file %s\0A\00"
@.str.6 = [4 x i8] c"fd:\00"
@INT_MAX = global i32 0
@.str.7 = [32 x i8] c"Invalid file descriptor %s: %s\0A\00"
@BIO_NOCLOSE = global i32 0
@.str.8 = [33 x i8] c"Can't access file descriptor %s\0A\00"
@.str.9 = [6 x i8] c"stdin\00"
@stdin = global i32 0
@.str.10 = [26 x i8] c"Can't open BIO for stdin\0A\00"
@.str.11 = [32 x i8] c"Invalid password argument \22%s\22\0A\00"
@.str.12 = [33 x i8] c"Error reading password from BIO\0A\00"
define i8* @app_get_pass(i32* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* null, i8** %10
%13 = load i8*, i8** %6
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 5
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %4
br label %139
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%23 = icmp ne i32 %22, 0
br i1 %23, label %38, label %24
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 4
%27 = call i8* @getenv(i8* %26)
store i8* %27, i8** %8
%28 = load i8*, i8** %8
%29 = icmp ne i8* %28, null
br i1 %29, label %35, label %30
30: ; preds = %24
%31 = load i32*, i32** %5
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 4
%34 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %31, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i8* null, i8** %4
br label %139
35: ; preds = %24
%36 = load i8*, i8** %8
%37 = call i8* @strdup(i8* %36)
store i8* %37, i8** %4
br label %139
38: ; preds = %20
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32*, i32** @app_get_pass.pwdbio
%43 = icmp ne i32* %42, null
br i1 %43, label %114, label %44
44: ; preds = %41, %38
%45 = load i8*, i8** %6
%46 = call i32 @strncmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%47 = icmp ne i32 %46, 0
br i1 %47, label %60, label %48
48: ; preds = %44
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 5
%51 = call i32* @BIO_new_file(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %51, i32** @app_get_pass.pwdbio
%52 = load i32*, i32** @app_get_pass.pwdbio
%53 = icmp ne i32* %52, null
br i1 %53, label %59, label %54
54: ; preds = %48
%55 = load i32*, i32** %5
%56 = load i8*, i8** %6
%57 = getelementptr inbounds i8, i8* %56, i64 5
%58 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %57)
store i8* null, i8** %4
br label %139
59: ; preds = %48
br label %113
60: ; preds = %44
%61 = load i8*, i8** %6
%62 = call i32 @strncmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%63 = icmp ne i32 %62, 0
br i1 %63, label %93, label %64
64: ; preds = %60
%65 = load i8*, i8** %6
%66 = getelementptr inbounds i8, i8* %65, i64 3
%67 = load i32, i32* @INT_MAX
%68 = call i32 @strtonum(i8* %66, i32 0, i32 %67, i8** %10)
store i32 %68, i32* %11
%69 = load i8*, i8** %10
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %76
71: ; preds = %64
%72 = load i32*, i32** %5
%73 = load i8*, i8** %6
%74 = load i8*, i8** %10
%75 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %72, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %73, i8* %74)
store i8* null, i8** %4
br label %139
76: ; preds = %64
%77 = load i32, i32* %11
%78 = load i32, i32* @BIO_NOCLOSE
%79 = call i32* @BIO_new_fd(i32 %77, i32 %78)
store i32* %79, i32** @app_get_pass.pwdbio
%80 = load i32*, i32** @app_get_pass.pwdbio
%81 = icmp ne i32* %80, null
br i1 %81, label %87, label %82
82: ; preds = %76
%83 = load i32*, i32** %5
%84 = load i8*, i8** %6
%85 = getelementptr inbounds i8, i8* %84, i64 3
%86 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %83, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %85)
store i8* null, i8** %4
br label %139
87: ; preds = %76
%88 = call i32 (...) @BIO_f_buffer()
%89 = call i32* @BIO_new(i32 %88)
store i32* %89, i32** %12
%90 = load i32*, i32** %12
%91 = load i32*, i32** @app_get_pass.pwdbio
%92 = call i32* @BIO_push(i32* %90, i32* %91)
store i32* %92, i32** @app_get_pass.pwdbio
br label %112
93: ; preds = %60
%94 = load i8*, i8** %6
%95 = call i32 @strcmp(i8* %94, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%96 = icmp ne i32 %95, 0
br i1 %96, label %107, label %97
97: ; preds = %93
%98 = load i32, i32* @stdin
%99 = load i32, i32* @BIO_NOCLOSE
%100 = call i32* @BIO_new_fp(i32 %98, i32 %99)
store i32* %100, i32** @app_get_pass.pwdbio
%101 = load i32*, i32** @app_get_pass.pwdbio
%102 = icmp ne i32* %101, null
br i1 %102, label %106, label %103
103: ; preds = %97
%104 = load i32*, i32** %5
%105 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %104, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
store i8* null, i8** %4
br label %139
106: ; preds = %97
br label %111
107: ; preds = %93
%108 = load i32*, i32** %5
%109 = load i8*, i8** %6
%110 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %108, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %109)
store i8* null, i8** %4
br label %139
111: ; preds = %106
br label %112
112: ; preds = %111, %87
br label %113
113: ; preds = %112, %59
br label %114
114: ; preds = %113, %41
%115 = load i32*, i32** @app_get_pass.pwdbio
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%117 = call i32 @BIO_gets(i32* %115, i8* %116, i32 1024)
store i32 %117, i32* %11
%118 = load i32, i32* %7
%119 = icmp ne i32 %118, 1
br i1 %119, label %120, label %123
120: ; preds = %114
%121 = load i32*, i32** @app_get_pass.pwdbio
%122 = call i32 @BIO_free_all(i32* %121)
store i32* null, i32** @app_get_pass.pwdbio
br label %123
123: ; preds = %120, %114
%124 = load i32, i32* %11
%125 = icmp sle i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i32*, i32** %5
%128 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %127, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
store i8* null, i8** %4
br label %139
129: ; preds = %123
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%131 = call i8* @strchr(i8* %130, i8 signext 10)
store i8* %131, i8** %8
%132 = load i8*, i8** %8
%133 = icmp ne i8* %132, null
br i1 %133, label %134, label %136
134: ; preds = %129
%135 = load i8*, i8** %8
store i8 0, i8* %135
br label %136
136: ; preds = %134, %129
%137 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%138 = call i8* @strdup(i8* %137)
store i8* %138, i8** %4
br label %139
139: ; preds = %136, %126, %107, %103, %82, %71, %54, %35, %30, %16
%140 = load i8*, i8** %4
ret i8* %140
}

LLVM IR (-O2):
@app_get_pass.pwdbio = internal unnamed_addr global i32* null
@.str = [6 x i8] c"pass:\00"
@.str.1 = [5 x i8] c"env:\00"
@.str.2 = [36 x i8] c"Can't read environment variable %s\0A\00"
@.str.3 = [6 x i8] c"file:\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [20 x i8] c"Can't open file %s\0A\00"
@.str.6 = [4 x i8] c"fd:\00"
@INT_MAX = global i32 0
@.str.7 = [32 x i8] c"Invalid file descriptor %s: %s\0A\00"
@BIO_NOCLOSE = global i32 0
@.str.8 = [33 x i8] c"Can't access file descriptor %s\0A\00"
@.str.9 = [6 x i8] c"stdin\00"
@stdin = global i32 0
@.str.10 = [26 x i8] c"Can't open BIO for stdin\0A\00"
@.str.11 = [32 x i8] c"Invalid password argument \22%s\22\0A\00"
@.str.12 = [33 x i8] c"Error reading password from BIO\0A\00"
define noalias i8* @app_get_pass(i32* %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = getelementptr inbounds i8, i8* %1, i64 5
%12 = tail call i8* @strdup(i8* %11)
br label %89
13: ; preds = %3
%14 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %1, i64 4
%18 = tail call i8* @getenv(i8* %17)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %89
22: ; preds = %16
%23 = tail call i8* @strdup(i8* %18)
br label %89
24: ; preds = %13
%25 = icmp ne i32 %2, 0
%26 = load i32*, i32** @app_get_pass.pwdbio
%27 = icmp ne i32* %26, null
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %72, label %29
29: ; preds = %24
%30 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = getelementptr inbounds i8, i8* %1, i64 5
%34 = tail call i32* @BIO_new_file(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %34, i32** @app_get_pass.pwdbio
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %72
36: ; preds = %32
%37 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %33)
br label %89
38: ; preds = %29
%39 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %60
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %1, i64 3
%43 = load i32, i32* @INT_MAX
%44 = call i32 @strtonum(i8* %42, i32 0, i32 %43, i8** %5)
%45 = load i8*, i8** %5
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %47
47: ; preds = %41
%48 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %1, i8* %45)
br label %89
49: ; preds = %41
%50 = load i32, i32* @BIO_NOCLOSE
%51 = call i32* @BIO_new_fd(i32 %44, i32 %50)
store i32* %51, i32** @app_get_pass.pwdbio
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %42)
br label %89
55: ; preds = %49
%56 = call i32 (...) @BIO_f_buffer()
%57 = call i32* @BIO_new(i32 %56)
%58 = load i32*, i32** @app_get_pass.pwdbio
%59 = call i32* @BIO_push(i32* %57, i32* %58)
store i32* %59, i32** @app_get_pass.pwdbio
br label %72
60: ; preds = %38
%61 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load i32, i32* @stdin
%65 = load i32, i32* @BIO_NOCLOSE
%66 = tail call i32* @BIO_new_fp(i32 %64, i32 %65)
store i32* %66, i32** @app_get_pass.pwdbio
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %89
70: ; preds = %60
%71 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %1)
br label %89
72: ; preds = %55, %32, %63, %24
%73 = phi i32* [ %59, %55 ], [ %34, %32 ], [ %66, %63 ], [ %26, %24 ]
%74 = call i32 @BIO_gets(i32* %73, i8* %6, i32 1024)
%75 = icmp eq i32 %2, 1
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = load i32*, i32** @app_get_pass.pwdbio
%78 = call i32 @BIO_free_all(i32* %77)
store i32* null, i32** @app_get_pass.pwdbio
br label %79
79: ; preds = %76, %72
%80 = icmp slt i32 %74, 1
br i1 %80, label %81, label %83
81: ; preds = %79
%82 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
br label %89
83: ; preds = %79
%84 = call i8* @strchr(i8* %6, i8 signext 10)
%85 = icmp eq i8* %84, null
br i1 %85, label %87, label %86
86: ; preds = %83
store i8 0, i8* %84
br label %87
87: ; preds = %86, %83
%88 = call i8* @strdup(i8* %6)
br label %89
89: ; preds = %47, %53, %87, %81, %70, %68, %36, %22, %20, %10
%90 = phi i8* [ null, %81 ], [ %88, %87 ], [ null, %70 ], [ null, %68 ], [ null, %36 ], [ %23, %22 ], [ null, %20 ], [ %12, %10 ], [ null, %53 ], [ null, %47 ]
ret i8* %90
}