#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
void login_input(char *name, char *password) {
  do {
    printf("login: ");
    fgets(name, 32 - 1, stdin);
    name[strlen(name) - 1] = '\0';
    printf("password: ");
    fgets(password, 32 - 1, stdin);
    password[strlen(password) - 1] = '\0';
  } while (strlen(name) == 0 || strlen(password) == 0);
}


x86 assembly (clang, -O0):
<login_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x1f,%esi
call   1050 <fgets@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
mov    $0x1f,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11f3 <login_input+0xc3>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1140 <login_input+0x10>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<login_input>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeba(%rip),%r15
mov    0x2e9b(%rip),%r13
lea    0xeb4(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1f,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r12,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x1f,%esi
call   1050 <fgets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1160 <login_input+0x30>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1160 <login_input+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"login: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"password: \00"
define void @login_input(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %34, %2
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 31, i32 %8)
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %10, i64 %14
store i8 0, i8* %15
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %4
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 31, i32 %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %5
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = icmp eq i32 %32, 0
br label %34
34: ; preds = %30, %26
%35 = phi i1 [ true, %26 ], [ %33, %30 ]
br i1 %35, label %5, label %36
36: ; preds = %34
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"login: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"password: \00"
define void @login_input(i8* %0, i8* %1) {
br label %3
3: ; preds = %23, %2
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = tail call i32 @fgets(i8* %0, i32 31, i32 %5)
%7 = tail call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = tail call i32 @fgets(i8* %1, i32 31, i32 %12)
%14 = tail call i32 @strlen(i8* %1)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 0, i8* %17
%18 = tail call i32 @strlen(i8* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %3
%21 = tail call i32 @strlen(i8* %1)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20, %3
br label %3
24: ; preds = %20
ret void
}