#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 */
scalar_t__ EOF;
int EXIT_FAILURE;
int atoi(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ scrn_passwd(int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int scr, position, mpw = 0;
  char pass[20];
  char pw[100];
  if (argc < 2) {
    printf("Usage: %s screen1 screen2 ...\n", argv[0]);
    exit(-1);
  }
  position = 0;
  while (++position < argc) {
    if (atoi(argv[position]) < 1) {
      printf("Option not known: %s.\n", argv[position]);
      continue;
    }
    scr = atoi(argv[position]);
    if ((scr < 100) && (mpw == 0)) {
      printf("You need clearance to see passwords below 100.\n");
      printf("Enter master password:");
      if (scanf("%s", pw) == EOF && errno != 0) {
        fprintf(stderr, "scanf error\n");
        exit(EXIT_FAILURE);
      }
      if (strncmp(pw, "poppycrash", strlen("poppycrash"))) {
        printf("Foo, charlatan!\n");
        exit(-1);
      }
      mpw = 1;
    }
    if (!scrn_passwd((scr - 1), pass)) {
      printf("%s: Cannot access %s.\n", argv[0], "/usr/share/dict/words");
      exit(-1);
    }
    printf("Screen %d password is '%s'.\n", scr, pass);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c9 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    -0x8(%rbp),%eax
jge    1366 <main+0x1e6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <atoi@plt>
cmp    $0x1,%eax
jge    121b <main+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11d0 <main+0x50>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    130e <main+0x18e>
cmpl   $0x0,-0x1c(%rbp)
jne    130e <main+0x18e>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1080 <scanf@plt>
mov    0x2d6f(%rip),%rcx
cmp    (%rcx),%rax
jne    12b6 <main+0x136>
mov    0x2d47(%rip),%rax
cmpq   $0x0,(%rax)
je     12b6 <main+0x136>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    0xdc2(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%edx
lea    0xdad(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1307 <main+0x187>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
lea    -0x30(%rbp),%rsi
call   1070 <scrn_passwd@plt>
cmp    $0x0,%eax
jne    134c <main+0x1cc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd75(%rip),%rdi
lea    0xd85(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11d0 <main+0x50>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     12e9 <main+0x159>
mov    %edi,0xc(%rsp)
mov    %edi,%r13d
mov    $0x1,%r14d
movl   $0x0,0x8(%rsp)
movslq %r14d,%rbp
lea    0x1(%rbp),%r14d
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%r15
mov    %r15,%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
jg     1210 <main+0x80>
lea    0xe38(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
add    $0x1,%r14d
cmp    %r13,%rbp
jl     11d0 <main+0x40>
jmp    12d5 <main+0x145>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%r12d
cmp    $0x63,%eax
ja     12a0 <main+0x110>
cmpl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%r15
jne    12a5 <main+0x115>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe04(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x2d8e(%rip),%rcx
cmp    (%rcx),%rax
jne    1270 <main+0xe0>
mov    0x2d6a(%rip),%rax
cmpq   $0x0,(%rax)
jne    1326 <main+0x196>
lea    0xde6(%rip),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x30(%rsp),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
movl   $0x1,0x8(%rsp)
test   %rax,%rax
je     12a5 <main+0x115>
jmp    1349 <main+0x1b9>
lea    0x10(%rsp),%r15
lea    -0x1(%r12),%edi
mov    %r15,%rsi
call   1080 <scrn_passwd@plt>
test   %eax,%eax
je     1304 <main+0x174>
lea    0xdd8(%rip),%rdi
mov    %r12d,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
cmp    0xc(%rsp),%r14d
jl     11c2 <main+0x32>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd0d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    (%rbx),%rsi
lea    0xd5a(%rip),%rdi
lea    0xd6a(%rip),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xd1a(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    0xd91(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: %s screen1 screen2 ...\0A\00"
@.str.1 = [23 x i8] c"Option not known: %s.\0A\00"
@.str.2 = [48 x i8] c"You need clearance to see passwords below 100.\0A\00"
@.str.3 = [23 x i8] c"Enter master password:\00"
@.str.4 = [3 x i8] c"%s\00"
@EOF = global i64 0
@errno = global i64 0
@stderr = global i32 0
@.str.5 = [13 x i8] c"scanf error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [11 x i8] c"poppycrash\00"
@.str.7 = [17 x i8] c"Foo, charlatan!\0A\00"
@.str.8 = [23 x i8] c"%s: Cannot access %s.\0A\00"
@.str.9 = [22 x i8] c"/usr/share/dict/words\00"
@.str.10 = [29 x i8] c"Screen %d password is '%s'.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [20 x i8]
%10 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
store i32 0, i32* %7
br label %20
20: ; preds = %88, %33, %19
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %92
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = icmp slt i32 %31, 1
br i1 %32, label %33, label %40
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %38)
br label %20
40: ; preds = %25
%41 = load i8**, i8*** %5
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = icmp slt i32 %47, 100
br i1 %48, label %49, label %76
49: ; preds = %40
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %76
52: ; preds = %49
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%56 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %67
59: ; preds = %52
%60 = load i64, i64* @errno
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %59, %52
%68 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%69 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%70 = call i64 @strncmp(i8* %68, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%74 = call i32 @exit(i32 -1)
unreachable
75: ; preds = %67
store i32 1, i32* %8
br label %76
76: ; preds = %75, %49, %40
%77 = load i32, i32* %6
%78 = sub nsw i32 %77, 1
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%80 = call i32 @scrn_passwd(i32 %78, i8* %79)
%81 = icmp ne i32 %80, 0
br i1 %81, label %88, label %82
82: ; preds = %76
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %85, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%87 = call i32 @exit(i32 -1)
unreachable
88: ; preds = %76
%89 = load i32, i32* %6
%90 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %89, i8* %90)
br label %20
92: ; preds = %20
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: %s screen1 screen2 ...\0A\00"
@.str.1 = [23 x i8] c"Option not known: %s.\0A\00"
@.str.3 = [23 x i8] c"Enter master password:\00"
@.str.4 = [3 x i8] c"%s\00"
@EOF = global i64 0
@errno = global i64 0
@stderr = global i32 0
@.str.5 = [13 x i8] c"scanf error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [11 x i8] c"poppycrash\00"
@.str.8 = [23 x i8] c"%s: Cannot access %s.\0A\00"
@.str.9 = [22 x i8] c"/usr/share/dict/words\00"
@.str.10 = [29 x i8] c"Screen %d password is '%s'.\0A\00"
@str = [47 x i8] c"You need clearance to see passwords below 100.\00"
@str.11 = [16 x i8] c"Foo, charlatan!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %63
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %63, %20
%15 = phi i64 [ %66, %63 ], [ %22, %20 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = icmp slt i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%22 = add nsw i64 %15, 1
%23 = icmp slt i64 %22, %9
br i1 %23, label %14, label %67
24: ; preds = %14
%25 = trunc i64 %15 to i32
%26 = icmp ult i32 %18, 100
%27 = icmp eq i32 %65, 0
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %29, label %50
29: ; preds = %24
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%32 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
%35 = load i64, i64* @errno
%36 = icmp ne i64 %35, 0
%37 = select i1 %34, i1 %36, i1 false
br i1 %37, label %38, label %43
38: ; preds = %29
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %29
%44 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%45 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %43
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %43, %24
%51 = phi i32 [ %65, %24 ], [ 1, %43 ]
%52 = add nsw i32 %18, -1
%53 = call i32 @scrn_passwd(i32 %52, i8* %5)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i8*, i8** %1
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %50
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %18, i8* %5)
%61 = add nsw i32 %25, 1
%62 = icmp slt i32 %61, %0
br i1 %62, label %63, label %67
63: ; preds = %8, %59
%64 = phi i32 [ %61, %59 ], [ 1, %8 ]
%65 = phi i32 [ %51, %59 ], [ 0, %8 ]
%66 = sext i32 %64 to i64
br label %14
67: ; preds = %59, %20
ret i32 0
}