#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 */
char getchar();
int /*<<< orphan*/ putchar(char);
char *get_pass() {
  static char buf[64];
  char c;
  int i = 0;
  while ((c = getchar()) != '\n') {
    buf[i++] = c;
    putchar('*');
  }
  buf[i] = '\0';
  putchar('\n');
  return buf;
}


x86 assembly (clang, -O0):
<get_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     116f <get_pass+0x4f>
mov    -0x1(%rbp),%dl
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2ee3(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
jmp    112f <get_pass+0xf>
movslq -0x8(%rbp),%rcx
lea    0x2ec6(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x2eb1(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pass>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     115f <get_pass+0x3f>
lea    0x2f08(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rbx,%r14,1)
add    $0x1,%rbx
mov    $0x2a,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1140 <get_pass+0x20>
mov    %ebx,%ebx
lea    0x2eda(%rip),%r14
movb   $0x0,(%rbx,%r14,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@get_pass.buf = internal global [64 x i8] zeroinitializer
define i8* @get_pass() {
%1 = alloca i8
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %7, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %1
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = load i8, i8* %1
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds [64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 %11
store i8 %8, i8* %12
%13 = call i32 @putchar(i8 signext 42)
br label %3
14: ; preds = %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @putchar(i8 signext 10)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@get_pass.buf = internal global [64 x i8] zeroinitializer
define i8* @get_pass() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 10
br i1 %2, label %13, label %3
3: ; preds = %0, %3
%4 = phi i64 [ %6, %3 ], [ 0, %0 ]
%5 = phi i8 [ %9, %3 ], [ %1, %0 ]
%6 = add nuw i64 %4, 1
%7 = getelementptr inbounds [64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 %4
store i8 %5, i8* %7
%8 = tail call i32 @putchar(i8 signext 42)
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = and i64 %6, 4294967295
br label %13
13: ; preds = %11, %0
%14 = phi i64 [ 0, %0 ], [ %12, %11 ]
%15 = getelementptr inbounds [64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 %14
store i8 0, i8* %15
%16 = tail call i32 @putchar(i8 signext 10)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_pass.buf, i64 0, i64 0)
}