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

/* Variables and functions */
int /*<<< orphan*/ disable_echo();
int /*<<< orphan*/ enable_echo();
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char const *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strip_newline(char *, int /*<<< orphan*/);
char *get_password(const char *prompt) {
  char *input = NULL;
  size_t len = 0;
  ssize_t read;
  printf(prompt);
  disable_echo();
  read = getline(&input, &len, stdin);
  strip_newline(input, read);
  printf("\n");
  enable_echo();
  return input;
}


x86 assembly (clang, -O0):
<get_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <disable_echo@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <strip_newline@plt>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <enable_echo@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_password>:
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <disable_echo@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1080 <getline@plt>
mov    0x8(%rsp),%rdi
mov    %eax,%esi
call   1030 <strip_newline@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1070 <enable_echo@plt>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
define i8* @get_password(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
store i64 0, i64* %4
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* %6)
%8 = call i32 (...) @disable_echo()
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %3, i64* %4, i32 %9)
store i32 %10, i32* %5
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = call i32 @strip_newline(i8* %11, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @enable_echo()
%16 = load i8*, i8** %3
ret i8* %16
}

LLVM IR (-O2):
@stdin = global i32 0
define i8* @get_password(i8* nocapture %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = tail call i32 @printf(i8* dereferenceable(1) %0)
%7 = tail call i32 (...) @disable_echo()
%8 = load i32, i32* @stdin
%9 = call i32 @getline(i8** %2, i64* %3, i32 %8)
%10 = load i8*, i8** %2
%11 = call i32 @strip_newline(i8* %10, i32 %9)
%12 = call i32 @putchar(i32 10)
%13 = call i32 (...) @enable_echo()
%14 = load i8*, i8** %2
ret i8* %14
}