#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int do_auth(void) {
  char username[1024], password[1024];
  fprintf(stdout, "Please enter your username: ");
  fgets(username, 1024, stdin);
  fflush(stdin);
  fprintf(stdout, "Please enter your password: ");
  fgets(password, 1024, stdin);
  if (!strcmp(username, "user") && !strcmp(password, "washere")) {
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<do_auth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1030 <fgets@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1030 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fb <do_auth+0xbb>
lea    -0x810(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fb <do_auth+0xbb>
movl   $0x0,-0x4(%rbp)
jmp    1202 <do_auth+0xc2>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_auth>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    0x2e97(%rip),%r14
mov    (%r14),%edi
lea    0xeb5(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e91(%rip),%rbx
mov    (%rbx),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    (%r14),%edi
lea    0xea6(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edx
lea    0x400(%rsp),%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
mov    $0x72657375,%eax
xor    (%rsp),%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
setne  %al
movabs $0x65726568736177,%rcx
cmp    %rcx,0x400(%rsp)
setne  %cl
or     %al,%cl
movzbl %cl,%eax
neg    %eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [29 x i8] c"Please enter your username: \00"
@stdin = global i32 0
@.str.1 = [29 x i8] c"Please enter your password: \00"
@.str.2 = [5 x i8] c"user\00"
@.str.3 = [8 x i8] c"washere\00"
define i32 @do_auth() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = load i32, i32* @stdout
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 1024, i32 %7)
%9 = load i32, i32* @stdin
%10 = call i32 @fflush(i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 1024, i32 %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 0, i32* %1
br label %25
24: ; preds = %19, %0
store i32 -1, i32* %1
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [29 x i8] c"Please enter your username: \00"
@stdin = global i32 0
@.str.1 = [29 x i8] c"Please enter your password: \00"
@.str.2 = [5 x i8] c"user\00"
define i32 @do_auth() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %3, i32 1024, i32 %7)
%9 = load i32, i32* @stdin
%10 = call i32 @fflush(i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %4, i32 1024, i32 %13)
%15 = call i32 @bcmp(i8* dereferenceable(5) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%16 = icmp ne i32 %15, 0
%17 = bitcast [1024 x i8]* %2 to i64*
%18 = load i64, i64* %17
%19 = icmp ne i64 %18, 28554752517431671
%20 = select i1 %16, i1 true, i1 %19
%21 = sext i1 %20 to i32
ret i32 %21
}