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

/* Variables and functions */
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int login(int num) {
  char u_passwd[15];
  int i;
  send(num, "Password: ", 11, 0);
  recv(num, u_passwd, sizeof(u_passwd), 0);
  for (i = 0; i < strlen(u_passwd); i++) {
    if (u_passwd[i] == '\n' || u_passwd[i] == '\r')
      u_passwd[i] = '\0';
  }
  if (strcmp("1234", u_passwd) == 0)
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xeab(%rip),%rsi
mov    $0xb,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x8(%rbp),%edi
lea    -0x17(%rbp),%rsi
mov    $0xf,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x17(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11d7 <login+0x97>
movslq -0x1c(%rbp),%rax
movsbl -0x17(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11bb <login+0x7b>
movslq -0x1c(%rbp),%rax
movsbl -0x17(%rbp,%rax,1),%eax
cmp    $0xd,%eax
jne    11c4 <login+0x84>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x17(%rbp,%rax,1)
jmp    11c9 <login+0x89>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <login+0x3b>
lea    -0x17(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11fd <login+0xbd>
movl   $0x1,-0x4(%rbp)
jmp    1204 <login+0xc4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<login>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0xeb0(%rip),%rsi
mov    $0xb,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    0x9(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xf,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b7 <login+0x77>
xor    %ebx,%ebx
lea    0x9(%rsp),%r14
jmp    11a8 <login+0x68>
nopw   0x0(%rax,%rax,1)
movb   $0x0,0x9(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11b7 <login+0x77>
movzbl 0x9(%rsp,%rbx,1),%eax
cmp    $0xd,%al
je     1190 <login+0x50>
cmp    $0xa,%al
je     1190 <login+0x50>
jmp    1195 <login+0x55>
lea    0xe4d(%rip),%rdi
lea    0x9(%rsp),%rsi
call   1060 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [5 x i8] c"1234\00"
define i32 @login(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [15 x i8]
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = call i32 @send(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11, i32 0)
%8 = load i32, i32* %3
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%10 = call i32 @recv(i32 %8, i8* %9, i32 15, i32 0)
store i32 0, i32* %5
br label %11
11: ; preds = %35, %1
%12 = load i32, i32* %5
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %38
16: ; preds = %11
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %30, label %23
23: ; preds = %16
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 13
br i1 %29, label %30, label %34
30: ; preds = %23, %16
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %30, %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %11
38: ; preds = %11
%39 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%40 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 1, i32* %2
br label %44
43: ; preds = %38
store i32 0, i32* %2
br label %44
44: ; preds = %43, %42
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [11 x i8] c"Password: \00"
@.str.1 = [5 x i8] c"1234\00"
define i32 @login(i32 %0) {
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @send(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11, i32 0)
%5 = call i32 @recv(i32 %0, i8* %3, i32 15, i32 0)
%6 = call i32 @strlen(i8* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %1, %13
%9 = phi i64 [ %14, %13 ], [ 0, %1 ]
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %13 [
i8 10, label %12
i8 13, label %12
]
12: ; preds = %8, %8
store i8 0, i8* %10
br label %13
13: ; preds = %8, %12
%14 = add nuw nsw i64 %9, 1
%15 = call i32 @strlen(i8* %3)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %8, label %18
18: ; preds = %13, %1
%19 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
ret i32 %21
}