#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*/ elevprompt;
typedef int /*<<< orphan*/ answer1;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
void elev1() {
  char elevprompt[30];
  char elevpass[40];
  char answer1[20];
  int len;
  fgets(elevprompt, sizeof(elevprompt) - 10, stdin);
  strncpy(elevpass, "00110001", 7);
  strcat(elevpass, elevprompt);
  len = strlen(elevpass);
  fgets(answer1, sizeof(answer1), stdin);
  if (len == atoi(answer1)) {
    memset(answer1, 0, sizeof(answer1));
    fgets(answer1, sizeof(answer1), stdin);
    if (strncmp(elevpass, answer1, len) == 0) {
      puts("Lazy researchers like you will never figure out the final "
           "elevator.");
    } else {
      exit(0);
    }
  } else {
    exit(0);
  }
}


x86 assembly (clang, -O0):
<elev1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x20(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1080 <fgets@plt>
lea    -0x50(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1080 <fgets@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cmp    %ecx,%eax
jne    1271 <elev1+0xe1>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1070 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    0x2dba(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1080 <fgets@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1265 <elev1+0xd5>
lea    0xdae(%rip),%rdi
call   1050 <puts@plt>
jmp    126c <elev1+0xdc>
xor    %edi,%edi
call   10b0 <exit@plt>
jmp    1278 <elev1+0xe8>
xor    %edi,%edi
call   10b0 <exit@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elev1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    0x2e47(%rip),%r15
mov    (%r15),%edx
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
lea    0xe43(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    (%r15),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
cmp    %eax,%ebp
jne    1250 <elev1+0xc0>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1070 <memset@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1080 <fgets@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1250 <elev1+0xc0>
lea    0xdc9(%rip),%rdi
call   1050 <puts@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [9 x i8] c"00110001\00"
@.str.1 = [68 x i8] c"Lazy researchers like you will never figure out the final elevator.\00"
define void @elev1() {
%1 = alloca [30 x i8]
%2 = alloca [40 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 20, i32 %6)
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%9 = call i32 @strncpy(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %4
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 20, i32 %16)
%18 = load i32, i32* %4
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%20 = call i32 @atoi(i8* %19)
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %38
22: ; preds = %0
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 20)
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 20, i32 %26)
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%30 = load i32, i32* %4
%31 = call i64 @strncmp(i8* %28, i8* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %22
%34 = call i32 @puts(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
br label %37
35: ; preds = %22
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %33
br label %40
38: ; preds = %0
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %37
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [9 x i8] c"00110001\00"
@.str.1 = [68 x i8] c"Lazy researchers like you will never figure out the final elevator.\00"
define void @elev1() {
%1 = alloca [30 x i8]
%2 = alloca [40 x i8]
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %4, i32 20, i32 %7)
%9 = call i32 @strncpy(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = call i32 @strcat(i8* %5, i8* %4)
%11 = call i32 @strlen(i8* %5)
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %6, i32 20, i32 %12)
%14 = call i32 @atoi(i8* %6)
%15 = icmp eq i32 %11, %14
br i1 %15, label %16, label %26
16: ; preds = %0
%17 = call i32 @memset(i8* %6, i32 0, i32 20)
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %6, i32 20, i32 %18)
%20 = call i64 @strncmp(i8* %5, i8* %6, i32 %11)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
ret void
24: ; preds = %16
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %0
%27 = call i32 @exit(i32 0)
unreachable
}