#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*/ *);
char *BUF_strdup(char *);
int atoi(char *);
char *getenv(char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *app_get_pass(BIO *err, char *arg, int keepbio) {
  char *tmp, tpass[1024];
  static BIO *pwdbio = NULL;
  int i;
  if (!strncmp(arg, "pass:", 5))
    return BUF_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 BUF_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 = atoi(arg + 3);
      if (i >= 0)
        pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
      if ((i < 0) || !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 BUF_strdup(tpass);
}


x86 assembly (clang, -O0):
<app_get_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdef(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    123a <app_get_pass+0x4a>
mov    -0x18(%rbp),%rdi
add    $0x5,%rdi
call   10e0 <BUF_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
mov    -0x18(%rbp),%rdi
lea    0xdc1(%rip),%rsi
mov    $0x4,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    12ad <app_get_pass+0xbd>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129b <app_get_pass+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x4,%rdx
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
mov    -0x28(%rbp),%rdi
call   10e0 <BUF_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
cmpl   $0x0,-0x1c(%rbp)
je     12c5 <app_get_pass+0xd5>
cmpq   $0x0,0x2de1(%rip)
jne    14a2 <app_get_pass+0x2b2>
mov    -0x18(%rbp),%rdi
lea    0xd5f(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1338 <app_get_pass+0x148>
mov    -0x18(%rbp),%rdi
add    $0x5,%rdi
lea    0xd43(%rip),%rsi
call   1110 <BIO_new_file@plt>
mov    %rax,0x2da2(%rip)
cmpq   $0x0,0x2d9a(%rip)
jne    1333 <app_get_pass+0x143>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x5,%rdx
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
jmp    149d <app_get_pass+0x2ad>
mov    -0x18(%rbp),%rdi
lea    0xd08(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1407 <app_get_pass+0x217>
mov    -0x18(%rbp),%rdi
add    $0x3,%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x0,-0x434(%rbp)
jl     1391 <app_get_pass+0x1a1>
mov    -0x434(%rbp),%edi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
call   1060 <BIO_new_fd@plt>
mov    %rax,0x2d0f(%rip)
cmpl   $0x0,-0x434(%rbp)
jl     13ac <app_get_pass+0x1bc>
cmpq   $0x0,0x2cfa(%rip)
jne    13d3 <app_get_pass+0x1e3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x3,%rdx
lea    0xc90(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
mov    $0x0,%al
call   10b0 <BIO_f_buffer@plt>
mov    %eax,%edi
call   10c0 <BIO_new@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
mov    0x2caa(%rip),%rsi
call   1070 <BIO_push@plt>
mov    %rax,0x2c9e(%rip)
jmp    1498 <app_get_pass+0x2a8>
mov    -0x18(%rbp),%rdi
lea    0xc5e(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1470 <app_get_pass+0x280>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
mov    0x2bb8(%rip),%rax
mov    (%rax),%esi
call   1040 <BIO_new_fp@plt>
mov    %rax,0x2c62(%rip)
cmpq   $0x0,0x2c5a(%rip)
jne    146b <app_get_pass+0x27b>
mov    -0x10(%rbp),%rdi
lea    0xc1f(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
jmp    1493 <app_get_pass+0x2a3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xc11(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
jmp    1498 <app_get_pass+0x2a8>
jmp    149d <app_get_pass+0x2ad>
jmp    14a2 <app_get_pass+0x2b2>
mov    0x2bf7(%rip),%rdi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   10d0 <BIO_gets@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     14e1 <app_get_pass+0x2f1>
mov    0x2bcf(%rip),%rdi
call   1100 <BIO_free_all@plt>
movq   $0x0,0x2bbf(%rip)
cmpl   $0x0,-0x434(%rbp)
jg     150d <app_get_pass+0x31d>
mov    -0x10(%rbp),%rdi
lea    0xbb7(%rip),%rsi
mov    $0x0,%al
call   1090 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1544 <app_get_pass+0x354>
lea    -0x430(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1534 <app_get_pass+0x344>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x430(%rbp),%rdi
call   10e0 <BUF_strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<app_get_pass>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     12a7 <app_get_pass+0xb7>
lea    0xde0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     12b0 <app_get_pass+0xc0>
test   %ebp,%ebp
je     12d4 <app_get_pass+0xe4>
mov    0x2e5a(%rip),%rdi
test   %rdi,%rdi
je     12d4 <app_get_pass+0xe4>
mov    %rsp,%rsi
mov    $0x400,%edx
call   10d0 <BIO_gets@plt>
mov    %eax,%ebx
cmp    $0x1,%ebp
je     127a <app_get_pass+0x8a>
mov    0x2e36(%rip),%rdi
call   1100 <BIO_free_all@plt>
movq   $0x0,0x2e26(%rip)
test   %ebx,%ebx
jle    1327 <app_get_pass+0x137>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1297 <app_get_pass+0xa7>
movb   $0x0,(%rax)
mov    %rsp,%rdi
call   10e0 <BUF_strdup@plt>
mov    %rax,%rbp
jmp    1421 <app_get_pass+0x231>
add    $0x5,%rbx
mov    %rbx,%rdi
jmp    12c4 <app_get_pass+0xd4>
add    $0x4,%rbx
mov    %rbx,%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     133f <app_get_pass+0x14f>
mov    %rax,%rdi
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10e0 <BUF_strdup@plt>
lea    0xd54(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     134b <app_get_pass+0x15b>
lea    0xd58(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     137d <app_get_pass+0x18d>
lea    0xd65(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     13d5 <app_get_pass+0x1e5>
lea    0xd6e(%rip),%rsi
jmp    1412 <app_get_pass+0x222>
lea    0xd82(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <BIO_printf@plt>
jmp    1421 <app_get_pass+0x231>
lea    0xcc5(%rip),%rsi
jmp    1412 <app_get_pass+0x222>
add    $0x5,%rbx
lea    0xcdf(%rip),%rsi
mov    %rbx,%rdi
call   1110 <BIO_new_file@plt>
mov    %rax,%rdi
mov    %rax,0x2d38(%rip)
test   %rax,%rax
jne    124f <app_get_pass+0x5f>
lea    0xcbf(%rip),%rsi
jmp    1412 <app_get_pass+0x222>
add    $0x3,%rbx
mov    %rbx,%rdi
call   10f0 <atoi@plt>
test   %eax,%eax
js     140b <app_get_pass+0x21b>
mov    0x2c54(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1060 <BIO_new_fd@plt>
mov    %rax,0x2cfc(%rip)
test   %rax,%rax
je     140b <app_get_pass+0x21b>
xor    %eax,%eax
call   10b0 <BIO_f_buffer@plt>
mov    %eax,%edi
call   10c0 <BIO_new@plt>
mov    0x2ce2(%rip),%rsi
mov    %rax,%rdi
call   1070 <BIO_push@plt>
mov    %rax,%rdi
mov    %rax,0x2cd0(%rip)
jmp    124f <app_get_pass+0x5f>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
mov    0x2c03(%rip),%rax
mov    (%rax),%esi
call   1040 <BIO_new_fp@plt>
mov    %rax,%rdi
mov    %rax,0x2caa(%rip)
test   %rax,%rax
jne    124f <app_get_pass+0x5f>
lea    0xc70(%rip),%rsi
jmp    132e <app_get_pass+0x13e>
lea    0xc3d(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <BIO_printf@plt>
mov    %rbp,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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