#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 spwd {
  int /*<<< orphan*/ sp_pwdp;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ STDIN_FILENO;
char *crypt(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct spwd *getspnam(char *);
scalar_t__ isatty(int /*<<< orphan*/);
int parse_typtop_output(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char const *, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  struct spwd *sp;
  if (isatty(STDIN_FILENO) || argc != 2) {
    fprintf(stderr, "This binary is not designed for running in this way\n"
                    "-- the system administrator has been informed\n");
    sleep(10);
    return EXIT_FAILURE;
  }
  if (argc < 2) {
    fprintf(stderr, "%s username \n", argv[0]);
    return (EXIT_FAILURE);
  }
  if ((sp = getspnam(argv[1])) == (struct spwd *)0) {
    fprintf(stderr, "ERROR (getspnam): Unknown user: <%s>\n", argv[1]);
    return (EXIT_FAILURE);
  }
  char pw[1000 + 1];
  int failed = 1;
  while (fgets(pw, 1000, stdin) != NULL) {
    pw[strlen(pw) - 1] = '\0';
    const char *crypt_password;
    printf("Trying: <%s>\n", pw);
    if (((crypt_password = crypt(pw, sp->sp_pwdp)) != NULL) &&
        strcmp(crypt_password, sp->sp_pwdp) == 0) {
      printf("This one worked! %s\n", pw);
      failed = 0;
      break;
    }
  }
  char cmd[1000];
  sprintf(cmd, "/usr/local/bin/typtop --check %d %s %s", failed, argv[1], pw);
  failed = parse_typtop_output(cmd);
  if (failed == 1)
    return (EXIT_FAILURE);
  else {
    system(
        "nohup /usr/local/bin/send_typo_log.py >> /var/log/typtop.log 2>&1 &");
    return (EXIT_SUCCESS);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
jne    11fb <main+0x3b>
cmpl   $0x2,-0x8(%rbp)
je     122d <main+0x6d>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xa,%edi
call   10e0 <sleep@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e1 <main+0x221>
cmpl   $0x2,-0x8(%rbp)
jge    1266 <main+0xa6>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e1 <main+0x221>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <getspnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12b1 <main+0xf1>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e1 <main+0x221>
movl   $0x1,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2d1f(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1371 <main+0x1b1>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xd91(%rip),%rdi
call   1070 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1040 <crypt@plt>
mov    %rax,-0x420(%rbp)
cmp    $0x0,%rax
je     136c <main+0x1ac>
mov    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    136c <main+0x1ac>
lea    -0x410(%rbp),%rsi
lea    0xd4d(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x414(%rbp)
jmp    1371 <main+0x1b1>
jmp    12bb <main+0xfb>
lea    -0x810(%rbp),%rdi
mov    -0x414(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    -0x410(%rbp),%r8
lea    0xd26(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x810(%rbp),%rdi
call   10c0 <parse_typtop_output@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x1,-0x414(%rbp)
jne    13c9 <main+0x209>
mov    0x2c11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e1 <main+0x221>
lea    0xd11(%rip),%rdi
call   1060 <system@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x2,%ebx
jne    12d9 <main+0x119>
test   %rax,%rax
jne    12d9 <main+0x119>
mov    0x8(%r15),%rdi
call   10b0 <getspnam@plt>
test   %rax,%rax
je     1303 <main+0x143>
mov    %rax,%rbp
mov    0x2dd6(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1080 <fgets@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     12a2 <main+0xe2>
lea    0xe51(%rip),%r12
jmp    1256 <main+0x96>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     12a2 <main+0xe2>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1040 <crypt@plt>
test   %rax,%rax
je     1240 <main+0x80>
mov    0x0(%rbp),%esi
mov    %rax,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0x80>
lea    0xe00(%rip),%rdi
mov    %rsp,%rsi
call   1070 <printf@plt>
xor    %r14d,%r14d
mov    0x8(%r15),%rcx
lea    0xdff(%rip),%rsi
lea    0x3f0(%rsp),%rbx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %r14d,%edx
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   10c0 <parse_typtop_output@plt>
cmp    $0x1,%eax
jne    1327 <main+0x167>
mov    0x2cf9(%rip),%rax
jmp    133a <main+0x17a>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xa,%edi
call   10e0 <sleep@plt>
mov    0x2ccf(%rip),%rax
jmp    133a <main+0x17a>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xd4c(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2cab(%rip),%rax
jmp    133a <main+0x17a>
lea    0xda5(%rip),%rdi
call   1060 <system@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.spwd = type { i32 }
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [99 x i8] c"This binary is not designed for running in this way\0A-- the system administrator has been informed\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [14 x i8] c"%s username \0A\00"
@.str.2 = [38 x i8] c"ERROR (getspnam): Unknown user: <%s>\0A\00"
@stdin = global i32 0
@.str.3 = [14 x i8] c"Trying: <%s>\0A\00"
@.str.4 = [21 x i8] c"This one worked! %s\0A\00"
@.str.5 = [39 x i8] c"/usr/local/bin/typtop --check %d %s %s\00"
@.str.6 = [68 x i8] c"nohup /usr/local/bin/send_typo_log.py >> /var/log/typtop.log 2>&1 &\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.spwd*
%7 = alloca [1001 x i8]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @STDIN_FILENO
%12 = call i64 @isatty(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %14, %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @sleep(i32 10)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %93
22: ; preds = %14
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %93
32: ; preds = %22
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call %struct.spwd* @getspnam(i8* %35)
store %struct.spwd* %36, %struct.spwd** %6
%37 = icmp eq %struct.spwd* %36, null
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
store i32 %44, i32* %3
br label %93
45: ; preds = %32
store i32 1, i32* %8
br label %46
46: ; preds = %75, %45
%47 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%48 = load i32, i32* @stdin
%49 = call i32* @fgets(i8* %47, i32 1000, i32 %48)
%50 = icmp ne i32* %49, null
br i1 %50, label %51, label %76
51: ; preds = %46
%52 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%58 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %57)
%59 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%60 = load %struct.spwd*, %struct.spwd** %6
%61 = getelementptr inbounds %struct.spwd, %struct.spwd* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = call i8* @crypt(i8* %59, i32 %62)
store i8* %63, i8** %9
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %75
65: ; preds = %51
%66 = load i8*, i8** %9
%67 = load %struct.spwd*, %struct.spwd** %6
%68 = getelementptr inbounds %struct.spwd, %struct.spwd* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i64 @strcmp(i8* %66, i32 %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%74 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %73)
store i32 0, i32* %8
br label %76
75: ; preds = %65, %51
br label %46
76: ; preds = %72, %46
%77 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%78 = load i32, i32* %8
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = getelementptr inbounds [1001 x i8], [1001 x i8]* %7, i64 0, i64 0
%83 = call i32 @sprintf(i8* %77, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %78, i8* %81, i8* %82)
%84 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%85 = call i32 @parse_typtop_output(i8* %84)
store i32 %85, i32* %8
%86 = load i32, i32* %8
%87 = icmp eq i32 %86, 1
br i1 %87, label %88, label %90
88: ; preds = %76
%89 = load i32, i32* @EXIT_FAILURE
store i32 %89, i32* %3
br label %93
90: ; preds = %76
%91 = call i32 @system(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
%92 = load i32, i32* @EXIT_SUCCESS
store i32 %92, i32* %3
br label %93
93: ; preds = %90, %88, %38, %25, %17
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
%struct.spwd = type { i32 }
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [99 x i8] c"This binary is not designed for running in this way\0A-- the system administrator has been informed\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"ERROR (getspnam): Unknown user: <%s>\0A\00"
@stdin = global i32 0
@.str.3 = [14 x i8] c"Trying: <%s>\0A\00"
@.str.4 = [21 x i8] c"This one worked! %s\0A\00"
@.str.5 = [39 x i8] c"/usr/local/bin/typtop --check %d %s %s\00"
@.str.6 = [68 x i8] c"nohup /usr/local/bin/send_typo_log.py >> /var/log/typtop.log 2>&1 &\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1001 x i8]
%4 = alloca [1000 x i8]
%5 = load i32, i32* @STDIN_FILENO
%6 = tail call i64 @isatty(i32 %5)
%7 = icmp ne i64 %6, 0
%8 = icmp ne i32 %0, 2
%9 = or i1 %8, %7
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @sleep(i32 10)
%14 = load i32, i32* @EXIT_FAILURE
br label %63
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call %struct.spwd* @getspnam(i8* %17)
%19 = icmp eq %struct.spwd* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %16
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
br label %63
25: ; preds = %15
%26 = getelementptr inbounds [1001 x i8], [1001 x i8]* %3, i64 0, i64 0
%27 = load i32, i32* @stdin
%28 = call i32* @fgets(i8* %26, i32 1000, i32 %27)
%29 = icmp eq i32* %28, null
br i1 %29, label %51, label %30
30: ; preds = %25
%31 = getelementptr inbounds %struct.spwd, %struct.spwd* %18, i64 0, i32 0
br label %32
32: ; preds = %30, %47
%33 = call i32 @strlen(i8* %26)
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1001 x i8], [1001 x i8]* %3, i64 0, i64 %35
store i8 0, i8* %36
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%38 = load i32, i32* %31
%39 = call i8* @crypt(i8* %26, i32 %38)
%40 = icmp eq i8* %39, null
br i1 %40, label %47, label %41
41: ; preds = %32
%42 = load i32, i32* %31
%43 = call i64 @strcmp(i8* %39, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %26)
br label %51
47: ; preds = %32, %41
%48 = load i32, i32* @stdin
%49 = call i32* @fgets(i8* %26, i32 1000, i32 %48)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %32
51: ; preds = %47, %25, %45
%52 = phi i32 [ 0, %45 ], [ 1, %25 ], [ 1, %47 ]
%53 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%54 = load i8*, i8** %16
%55 = call i32 @sprintf(i8* %53, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %52, i8* %54, i8* %26)
%56 = call i32 @parse_typtop_output(i8* %53)
%57 = icmp eq i32 %56, 1
br i1 %57, label %60, label %58
58: ; preds = %51
%59 = call i32 @system(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %51, %58
%61 = phi i32* [ @EXIT_SUCCESS, %58 ], [ @EXIT_FAILURE, %51 ]
%62 = load i32, i32* %61
br label %63
63: ; preds = %60, %20, %10
%64 = phi i32 [ %14, %10 ], [ %24, %20 ], [ %62, %60 ]
ret i32 %64
}