#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*/ user;
typedef int /*<<< orphan*/ pass;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ jfauth_authenticate(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char **argv) {
  if (argc != 1) {
    fprintf(stderr,
            "Usage: %s\n"
            "  Reads two lines from stdin: username and password.\n"
            "  Returns 0 if password validation succeeds, otherwise 1.\n",
            argv[0]);
    return 1;
  }
  char user[200];
  char pass[200];
  fgets(user, sizeof(user), stdin);
  fgets(pass, sizeof(pass), stdin);
  user[sizeof(user) - 1] = 0;
  pass[sizeof(pass) - 1] = 0;
  if (strlen(user) < 1 || strlen(pass) < 1)
    return 1;
  user[strlen(user) - 1] = 0;
  pass[strlen(pass) - 1] = 0;
  return jfauth_authenticate(user, pass) == 0 ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     118b <main+0x4b>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe86(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1259 <main+0x119>
lea    -0xe0(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1050 <fgets@plt>
lea    -0x1b0(%rbp),%rdi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1050 <fgets@plt>
movb   $0x0,-0x19(%rbp)
movb   $0x0,-0xe9(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jl     11f4 <main+0xb4>
lea    -0x1b0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jge    1200 <main+0xc0>
movl   $0x1,-0x4(%rbp)
jmp    1259 <main+0x119>
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0x1b0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1b0(%rbp,%rax,1)
lea    -0xe0(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
call   1040 <jfauth_authenticate@plt>
mov    %rax,%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
cmp    $0x1,%edi
jne    11e8 <main+0xa8>
mov    0x2e8d(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xd0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc8,%esi
call   1050 <fgets@plt>
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0xc8,%esi
call   1050 <fgets@plt>
movb   $0x0,0x197(%rsp)
movb   $0x0,0xc7(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ebp
test   %eax,%eax
jle    1205 <main+0xc5>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1205 <main+0xc5>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <jfauth_authenticate@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
jmp    1205 <main+0xc5>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe05(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [122 x i8] c"Usage: %s\0A Reads two lines from stdin: username and password.\0A Returns 0 if password validation succeeds, otherwise 1.\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
%7 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %50
16: ; preds = %2
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 200, i32 %18)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%21 = load i32, i32* @stdin
%22 = call i32 @fgets(i8* %20, i32 200, i32 %21)
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 199
store i8 0, i8* %23
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 199
store i8 0, i8* %24
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = icmp slt i32 %26, 1
br i1 %27, label %32, label %28
28: ; preds = %16
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %28, %16
store i32 1, i32* %3
br label %50
33: ; preds = %28
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %37
store i8 0, i8* %38
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 %42
store i8 0, i8* %43
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%46 = call i64 @jfauth_authenticate(i8* %44, i8* %45)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 0, i32 1
store i32 %49, i32* %3
br label %50
50: ; preds = %33, %32, %10
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [122 x i8] c"Usage: %s\0A Reads two lines from stdin: username and password.\0A Returns 0 if password validation succeeds, otherwise 1.\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = icmp eq i32 %0, 1
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %38
10: ; preds = %2
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %11, i32 200, i32 %13)
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %12, i32 200, i32 %15)
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 199
store i8 0, i8* %17
%18 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 199
store i8 0, i8* %18
%19 = call i32 @strlen(i8* %11)
%20 = icmp slt i32 %19, 1
br i1 %20, label %36, label %21
21: ; preds = %10
%22 = call i32 @strlen(i8* %12)
%23 = icmp slt i32 %22, 1
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = call i32 @strlen(i8* %11)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i32 @strlen(i8* %12)
%30 = add nsw i32 %29, -1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i64 @jfauth_authenticate(i8* %11, i8* %12)
%34 = icmp ne i64 %33, 0
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %10, %21, %24
%37 = phi i32 [ %35, %24 ], [ 1, %21 ], [ 1, %10 ]
br label %38
38: ; preds = %36, %6
%39 = phi i32 [ 1, %6 ], [ %37, %36 ]
ret i32 %39
}