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

/* Variables and functions */
int read(int /*<<< orphan*/, char *, int);
const char *readpw(void) {
  static char pw[64];
  for (int i = 0; i < sizeof(pw); i++) {
    int r = read(0, &pw[i], 1);
    if (r != 1)
      return 0;
    if (pw[i] == '\r') {
      pw[i] = 0;
    } else if (pw[i] == '\n') {
      pw[i] = 0;
      return pw;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readpw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x40,%rax
jae    11dc <readpw+0xcc>
movslq -0xc(%rbp),%rax
lea    0x2f08(%rip),%rsi
add    %rax,%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1030 <read@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1161 <readpw+0x51>
movq   $0x0,-0x8(%rbp)
jmp    11e4 <readpw+0xd4>
movslq -0xc(%rbp),%rcx
lea    0x2ed4(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    118d <readpw+0x7d>
movslq -0xc(%rbp),%rcx
lea    0x2ebc(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    11c9 <readpw+0xb9>
movslq -0xc(%rbp),%rcx
lea    0x2ea8(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11c4 <readpw+0xb4>
movslq -0xc(%rbp),%rcx
lea    0x2e90(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e85(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <readpw+0xd4>
jmp    11c9 <readpw+0xb9>
jmp    11ce <readpw+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <readpw+0xf>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readpw>:
push   %r15
push   %r14
push   %rbx
xor    %r15d,%r15d
lea    0x2f21(%rip),%r14
jmp    113d <readpw+0x2d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
add    $0x1,%r15
cmp    $0x40,%r15
je     1167 <readpw+0x57>
lea    (%r14,%r15,1),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <read@plt>
cmp    $0x1,%eax
jne    1167 <readpw+0x57>
movzbl (%rbx),%eax
cmp    $0xd,%al
je     1130 <readpw+0x20>
cmp    $0xa,%al
jne    1133 <readpw+0x23>
movb   $0x0,(%r15,%r14,1)
jmp    116a <readpw+0x5a>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@readpw.pw = internal global [64 x i8] zeroinitializer
define i8* @readpw() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %40, %0
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = icmp ult i64 %6, 64
br i1 %7, label %8, label %43
8: ; preds = %4
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %10
%12 = call i32 @read(i32 0, i8* %11, i32 1)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %8
store i8* null, i8** %1
br label %44
16: ; preds = %8
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 13
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %25
store i8 0, i8* %26
br label %39
27: ; preds = %16
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %27
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %36
store i8 0, i8* %37
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 0), i8** %1
br label %44
38: ; preds = %27
br label %39
39: ; preds = %38, %23
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %4
43: ; preds = %4
store i8* null, i8** %1
br label %44
44: ; preds = %43, %34, %15
%45 = load i8*, i8** %1
ret i8* %45
}

LLVM IR (-O2):
@readpw.pw = internal global [64 x i8] zeroinitializer
define i8* @readpw() {
br label %1
1: ; preds = %0, %10
%2 = phi i64 [ 0, %0 ], [ %11, %10 ]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 %2
%4 = tail call i32 @read(i32 0, i8* %3, i32 1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i8, i8* %3
switch i8 %7, label %10 [
i8 13, label %8
i8 10, label %9
]
8: ; preds = %6
store i8 0, i8* %3
br label %10
9: ; preds = %6
store i8 0, i8* %3
br label %13
10: ; preds = %6, %8
%11 = add nuw nsw i64 %2, 1
%12 = icmp eq i64 %11, 64
br i1 %12, label %13, label %1
13: ; preds = %1, %10, %9
%14 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @readpw.pw, i64 0, i64 0), %9 ], [ null, %10 ], [ null, %1 ]
ret i8* %14
}