#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 */
struct passwd {
  int /*<<< orphan*/ pw_passwd;
};

/* Variables and functions */
scalar_t__ crypt(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
char *strtok(char *, char *);
int main() {
  char buf[256];
  struct passwd *pwd;
  char *user, *passwd, *p;
  setbuf(stdout, NULL);
  while (fgets(buf, 256, stdin) != NULL) {
    if ((p = strchr(buf, '\n')) != NULL)
      *p = '\0';
    if ((user = strtok(buf, " ")) == NULL) {
      printf("ERR\n");
      continue;
    }
    if ((passwd = strtok(NULL, "")) == NULL) {
      printf("ERR\n");
      continue;
    }
    pwd = getpwnam(user);
    if (pwd == NULL) {
      printf("ERR\n");
    } else {
      if (strcmp(pwd->pw_passwd, (char *)crypt(passwd, pwd->pw_passwd))) {
        printf("ERR\n");
      } else {
        printf("OK\n");
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1300 <main+0x170>
lea    -0x110(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
je     1204 <main+0x74>
mov    -0x130(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x110(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    1239 <main+0xa9>
lea    0xdd3(%rip),%rdi
call   1060 <printf@plt>
jmp    11b4 <main+0x24>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc6(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    126b <main+0xdb>
lea    0xda1(%rip),%rdi
call   1060 <printf@plt>
jmp    11b4 <main+0x24>
mov    -0x120(%rbp),%rdi
call   1090 <getpwnam@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    129d <main+0x10d>
lea    0xd6f(%rip),%rdi
call   1060 <printf@plt>
jmp    12fb <main+0x16b>
mov    -0x118(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x128(%rbp),%rdi
mov    -0x118(%rbp),%rax
mov    (%rax),%esi
call   1030 <crypt@plt>
mov    -0x134(%rbp),%edi
mov    %rax,%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12ea <main+0x15a>
lea    0xd22(%rip),%rdi
call   1060 <printf@plt>
jmp    12f6 <main+0x166>
lea    0xd16(%rip),%rdi
call   1060 <printf@plt>
jmp    12fb <main+0x16b>
jmp    11b4 <main+0x24>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x2e30(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
test   %rax,%rax
jne    11d4 <main+0x44>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    %rsp,%r12
lea    0xe22(%rip),%r14
lea    0xe20(%rip),%r15
jmp    120a <main+0x7a>
nopw   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11cd <main+0x3d>
mov    %r12,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     121f <main+0x8f>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <strtok@plt>
mov    %r15,%rdi
test   %rax,%rax
je     11f0 <main+0x60>
mov    %rax,%rbx
xor    %edi,%edi
lea    0xdc3(%rip),%rsi
call   10a0 <strtok@plt>
mov    %r15,%rdi
test   %rax,%rax
je     11f0 <main+0x60>
mov    %rax,%r13
mov    %rbx,%rdi
call   1090 <getpwnam@plt>
mov    %r15,%rdi
test   %rax,%rax
je     11f0 <main+0x60>
mov    (%rax),%ebx
mov    %r13,%rdi
mov    %ebx,%esi
call   1040 <crypt@plt>
mov    %ebx,%edi
mov    %rax,%rsi
call   1080 <strcmp@plt>
lea    0xd87(%rip),%rdi
test   %rax,%rax
je     11f0 <main+0x60>
mov    %r15,%rdi
jmp    11f0 <main+0x60>

LLVM IR (-O0):
%struct.passwd = type { i32 }
@stdout = global i32 0
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"ERR\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"OK\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca %struct.passwd*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = load i32, i32* @stdout
%8 = call i32 @setbuf(i32 %7, i32* null)
br label %9
9: ; preds = %55, %29, %24, %0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %10, i32 256, i32 %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %56
14: ; preds = %9
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%16 = call i8* @strchr(i8* %15, i8 signext 10)
store i8* %16, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i8*, i8** %6
store i8 0, i8* %19
br label %20
20: ; preds = %18, %14
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%22 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %4
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %9
26: ; preds = %20
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i8* %27, i8** %5
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %9
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = call %struct.passwd* @getpwnam(i8* %32)
store %struct.passwd* %33, %struct.passwd** %3
%34 = load %struct.passwd*, %struct.passwd** %3
%35 = icmp eq %struct.passwd* %34, null
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %55
38: ; preds = %31
%39 = load %struct.passwd*, %struct.passwd** %3
%40 = getelementptr inbounds %struct.passwd, %struct.passwd* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = load i8*, i8** %5
%43 = load %struct.passwd*, %struct.passwd** %3
%44 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = call i64 @crypt(i8* %42, i32 %45)
%47 = inttoptr i64 %46 to i8*
%48 = call i64 @strcmp(i32 %41, i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %38
%51 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %54
52: ; preds = %38
%53 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %36
br label %9
56: ; preds = %9
%57 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@stdout = global i32 0
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
@str = [3 x i8] c"OK\00"
@str.7 = [4 x i8] c"ERR\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32* null)
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %2, i32 256, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %35, label %8
8: ; preds = %0, %15
%9 = call i8* @strchr(i8* %2, i8 signext 10)
%10 = icmp eq i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8
store i8 0, i8* %9
br label %12
12: ; preds = %11, %8
%13 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %21
15: ; preds = %12, %27, %24, %21
%16 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0), %21 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0), %24 ], [ %34, %27 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0), %12 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
%18 = load i32, i32* @stdin
%19 = call i32* @fgets(i8* %2, i32 256, i32 %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %35, label %8
21: ; preds = %12
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %15, label %24
24: ; preds = %21
%25 = call %struct.passwd* @getpwnam(i8* %13)
%26 = icmp eq %struct.passwd* %25, null
br i1 %26, label %15, label %27
27: ; preds = %24
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %25, i64 0, i32 0
%29 = load i32, i32* %28
%30 = call i64 @crypt(i8* %22, i32 %29)
%31 = inttoptr i64 %30 to i8*
%32 = call i64 @strcmp(i32 %29, i8* %31)
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0)
br label %15
35: ; preds = %15, %0
%36 = call i32 @exit(i32 0)
unreachable
}