#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 */
int /*<<< orphan*/ err_sys(char *);
char *my_getpass(char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *ptr;
  if ((ptr = my_getpass("Enter Password:")) == NULL)
    err_sys("getpass error");
  printf("password: %s\n", ptr);
  while (*ptr != 0)
    *ptr++ = 0;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1050 <my_getpass@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1165 <main+0x35>
lea    0xeb0(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119c <main+0x6c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
jmp    1175 <main+0x45>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1050 <my_getpass@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1151 <main+0x21>
lea    0xec4(%rip),%rdi
call   1030 <err_sys@plt>
lea    0xec6(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
cmpb   $0x0,(%rbx)
je     117d <main+0x4d>
add    $0x1,%rbx
nopl   0x0(%rax)
movb   $0x0,-0x1(%rbx)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x40>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter Password:\00"
@.str.1 = [14 x i8] c"getpass error\00"
@.str.2 = [14 x i8] c"password: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @my_getpass(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %15, %7
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
store i8 0, i8* %16
br label %10
18: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter Password:\00"
@.str.1 = [14 x i8] c"getpass error\00"
@.str.2 = [14 x i8] c"password: %s\0A\00"
define i32 @main() {
%1 = tail call i8* @my_getpass(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5, %9
%10 = phi i8* [ %11, %9 ], [ %1, %5 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8 0, i8* %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %9
14: ; preds = %9, %5
ret i32 0
}