#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 */
int check_login(char *, char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ register_user(char *, char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char username[500];
  int is_admin = 0;
  char password[500];
  int logged_in = 0;
  char flag[250];
  char user[500];
  char pw[500];
  setbuf(stdout, NULL);
  printf("Welcome to the FlagStore!\n");
  while (1) {
    printf("Choose an action:\n");
    printf("> %s: 1\n> %s: 2\n> %s: 3\n> %s: 4\n", "regiser", "login",
           "get_flag", "store_flag");
    int answer = 0;
    scanf("%d", &answer);
    switch (answer) {
    case 1:
      printf("Enter an username:");
      scanf("%s", username);
      printf("Enter a password:");
      scanf("%s", password);
      if (strcmp(username, "admin") == 0) {
        printf("Sorry, admin user already registered\n");
        break;
      }
      if (strlen(password) < 6) {
        printf("Sorry, password too short\n");
        break;
      }
      register_user(username, password);
      printf("User %s successfully registered. You can login now!\n", username);
      break;
    case 2:
      printf("Username:");
      scanf("%499s", user);
      printf("Password:");
      scanf("%499s", pw);
      if (check_login(user, pw, username, password) == -1) {
        printf("Wrong credentials!\n");
        break;
      }
      logged_in = 1;
      printf("You're now authenticated!\n");
      break;
    case 3:
      if (logged_in == 0) {
        printf("Please login first!\n");
        break;
      }
      if (is_admin != 0) {
        strcpy(flag, "IW{Y_U_NO_HAZ_FLAG}");
      }
      printf("Your flag: %s\n", flag);
      break;
    case 4:
      if (logged_in == 0) {
        printf("Please login first!\n");
        break;
      }
      printf("Enter your flag:");
      scanf("%s", flag);
      printf("Flag saved!\n");
      break;
    default:
      printf("Wrong option\nGood bye\n");
      return -1;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x920,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x204(%rbp)
movl   $0x0,-0x404(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <setbuf@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x911(%rbp)
call   1070 <printf@plt>
mov    -0x911(%rbp),%al
lea    0xe57(%rip),%rdi
lea    0xe71(%rip),%rsi
lea    0xe72(%rip),%rdx
lea    0xe71(%rip),%rcx
lea    0xe73(%rip),%r8
call   1070 <printf@plt>
mov    -0x911(%rbp),%al
movl   $0x0,-0x904(%rbp)
lea    0xe62(%rip),%rdi
lea    -0x904(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x904(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x910(%rbp)
sub    $0x3,%eax
ja     1477 <main+0x2f7>
mov    -0x910(%rbp),%rax
lea    0xdac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x200(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x400(%rbp),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    -0x200(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12d2 <main+0x152>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
lea    -0x400(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x6,%eax
jge    12fa <main+0x17a>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1090 <register_user@plt>
lea    -0x200(%rbp),%rsi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x700(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x900(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    -0x700(%rbp),%rdi
lea    -0x900(%rbp),%rsi
lea    -0x200(%rbp),%rdx
lea    -0x400(%rbp),%rcx
call   1030 <check_login@plt>
cmp    $0xffffffff,%eax
jne    13aa <main+0x22a>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
movl   $0x1,-0x404(%rbp)
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
cmpl   $0x0,-0x404(%rbp)
jne    13e7 <main+0x267>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
cmpl   $0x0,-0x204(%rbp)
je     1407 <main+0x287>
lea    -0x500(%rbp),%rdi
lea    0xd84(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x500(%rbp),%rsi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
cmpl   $0x0,-0x404(%rbp)
jne    1441 <main+0x2c1>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x500(%rbp),%rsi
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1493 <main+0x313>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xffffffff,%eax
add    $0x920,%rsp
pop    %rbp
ret
jmp    11c6 <main+0x46>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x908,%rsp
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1060 <setbuf@plt>
lea    0xf5b(%rip),%rdi
call   1040 <puts@plt>
lea    0xea4(%rip),%r15
lea    0xea8(%rip),%r12
lea    0x8(%rsp),%r14
lea    0xe49(%rip),%rbx
jmp    11cc <main+0x5c>
nopl   0x0(%rax)
lea    0xf64(%rip),%rdi
call   1040 <puts@plt>
xor    %r13d,%r13d
nop
lea    0xf36(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2d(%rip),%rdi
lea    0xe47(%rip),%rsi
lea    0xe48(%rip),%rdx
lea    0xe47(%rip),%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x0,0x8(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1421 <main+0x2b1>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe24(%rip),%rbx
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
lea    0x310(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x10(%rsp),%eax
mov    $0x696d6461,%ecx
xor    %ecx,%eax
movzwl 0x14(%rsp),%ecx
xor    $0x6e,%ecx
or     %eax,%ecx
je     13c4 <main+0x254>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
jg     13ef <main+0x27f>
lea    0xec2(%rip),%rdi
jmp    13cb <main+0x25b>
nop
mov    %r13d,0xc(%rsp)
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf9(%rip),%r13
mov    %r13,%rdi
lea    0x710(%rsp),%r15
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
lea    0x510(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
lea    0x10(%rsp),%rdx
lea    0x310(%rsp),%rcx
call   1030 <check_login@plt>
cmp    $0xffffffff,%eax
je     13d2 <main+0x262>
lea    0xe15(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r13d
lea    0xd0c(%rip),%r15
jmp    11d0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %r13d,%r13d
je     11c0 <main+0x50>
lea    0xd73(%rip),%rdi
lea    0x210(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r13d
jmp    11d0 <main+0x60>
nopw   0x0(%rax,%rax,1)
test   %r13d,%r13d
je     11c0 <main+0x50>
lea    0xd52(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xccb(%rip),%rdi
lea    0x210(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xd6b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r13d
jmp    11d0 <main+0x60>
lea    0xdbb(%rip),%rdi
call   1040 <puts@plt>
jmp    1410 <main+0x2a0>
lea    0xd80(%rip),%rdi
call   1040 <puts@plt>
lea    0xc63(%rip),%r15
mov    0xc(%rsp),%r13d
jmp    11d0 <main+0x60>
mov    %rbx,%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <register_user@plt>
lea    0xc7e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x8(%rsp),%r14
lea    0xbe4(%rip),%rbx
jmp    11d0 <main+0x60>
lea    0xd83(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x908,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [27 x i8] c"Welcome to the FlagStore!\0A\00"
@.str.1 = [19 x i8] c"Choose an action:\0A\00"
@.str.2 = [33 x i8] c"> %s: 1\0A> %s: 2\0A> %s: 3\0A> %s: 4\0A\00"
@.str.3 = [8 x i8] c"regiser\00"
@.str.4 = [6 x i8] c"login\00"
@.str.5 = [9 x i8] c"get_flag\00"
@.str.6 = [11 x i8] c"store_flag\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [19 x i8] c"Enter an username:\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [18 x i8] c"Enter a password:\00"
@.str.11 = [6 x i8] c"admin\00"
@.str.12 = [38 x i8] c"Sorry, admin user already registered\0A\00"
@.str.13 = [27 x i8] c"Sorry, password too short\0A\00"
@.str.14 = [53 x i8] c"User %s successfully registered. You can login now!\0A\00"
@.str.15 = [10 x i8] c"Username:\00"
@.str.16 = [6 x i8] c"%499s\00"
@.str.17 = [10 x i8] c"Password:\00"
@.str.18 = [20 x i8] c"Wrong credentials!\0A\00"
@.str.19 = [27 x i8] c"You're now authenticated!\0A\00"
@.str.20 = [21 x i8] c"Please login first!\0A\00"
@.str.21 = [20 x i8] c"IW{Y_U_NO_HAZ_FLAG}\00"
@.str.22 = [15 x i8] c"Your flag: %s\0A\00"
@.str.23 = [17 x i8] c"Enter your flag:\00"
@.str.24 = [13 x i8] c"Flag saved!\0A\00"
@.str.25 = [23 x i8] c"Wrong option\0AGood bye\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = alloca i32
%4 = alloca [500 x i8]
%5 = alloca i32
%6 = alloca [250 x i8]
%7 = alloca [500 x i8]
%8 = alloca [500 x i8]
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
%10 = load i32, i32* @stdout
%11 = call i32 @setbuf(i32 %10, i32* null)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %0, %85
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %9
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %9)
%17 = load i32, i32* %9
switch i32 %17, label %83 [
i32 1, label %18
i32 2, label %42
i32 3, label %59
i32 4, label %73
]
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%23 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0))
br label %85
30: ; preds = %18
%31 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = icmp slt i32 %32, 6
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0))
br label %85
36: ; preds = %30
%37 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%39 = call i32 @register_user(i8* %37, i8* %38)
%40 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i8* %40)
br label %85
42: ; preds = %13
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%44 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0))
%47 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%50 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%51 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%52 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%53 = call i32 @check_login(i8* %49, i8* %50, i8* %51, i8* %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %42
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
br label %85
57: ; preds = %42
store i32 1, i32* %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.19, i64 0, i64 0))
br label %85
59: ; preds = %13
%60 = load i32, i32* %5
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
br label %85
64: ; preds = %59
%65 = load i32, i32* %3
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = getelementptr inbounds [250 x i8], [250 x i8]* %6, i64 0, i64 0
%69 = call i32 @strcpy(i8* %68, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.21, i64 0, i64 0))
br label %70
70: ; preds = %67, %64
%71 = getelementptr inbounds [250 x i8], [250 x i8]* %6, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0), i8* %71)
br label %85
73: ; preds = %13
%74 = load i32, i32* %5
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
br label %85
78: ; preds = %73
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.23, i64 0, i64 0))
%80 = getelementptr inbounds [250 x i8], [250 x i8]* %6, i64 0, i64 0
%81 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0))
br label %85
83: ; preds = %13
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.25, i64 0, i64 0))
ret i32 -1
85: ; preds = %78, %76, %70, %62, %57, %55, %36, %34, %28
br label %13
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.2 = [33 x i8] c"> %s: 1\0A> %s: 2\0A> %s: 3\0A> %s: 4\0A\00"
@.str.3 = [8 x i8] c"regiser\00"
@.str.4 = [6 x i8] c"login\00"
@.str.5 = [9 x i8] c"get_flag\00"
@.str.6 = [11 x i8] c"store_flag\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [19 x i8] c"Enter an username:\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [18 x i8] c"Enter a password:\00"
@.str.11 = [6 x i8] c"admin\00"
@.str.14 = [53 x i8] c"User %s successfully registered. You can login now!\0A\00"
@.str.15 = [10 x i8] c"Username:\00"
@.str.16 = [6 x i8] c"%499s\00"
@.str.17 = [10 x i8] c"Password:\00"
@.str.22 = [15 x i8] c"Your flag: %s\0A\00"
@.str.23 = [17 x i8] c"Enter your flag:\00"
@str = [26 x i8] c"Welcome to the FlagStore!\00"
@str.26 = [18 x i8] c"Choose an action:\00"
@str.27 = [12 x i8] c"Flag saved!\00"
@str.29 = [20 x i8] c"Please login first!\00"
@str.30 = [26 x i8] c"You're now authenticated!\00"
@str.31 = [19 x i8] c"Wrong credentials!\00"
@str.32 = [26 x i8] c"Sorry, password too short\00"
@str.33 = [37 x i8] c"Sorry, admin user already registered\00"
@str.34 = [22 x i8] c"Wrong option\0AGood bye\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = alloca [500 x i8]
%3 = alloca [250 x i8]
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%12 = load i32, i32* @stdout
%13 = tail call i32 @setbuf(i32 %12, i32* null)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%15 = bitcast i32* %6 to i8*
br label %16
16: ; preds = %64, %0
%17 = phi i32 [ 0, %0 ], [ %65, %64 ]
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.26, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %6
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %6)
%21 = load i32, i32* %6
switch i32 %21, label %66 [
i32 1, label %22
i32 2, label %39
i32 3, label %50
i32 4, label %56
]
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %7)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %8)
%27 = call i32 @bcmp(i8* dereferenceable(6) %7, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i64 6)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.33, i64 0, i64 0))
br label %64
31: ; preds = %22
%32 = call i32 @strlen(i8* %8)
%33 = icmp slt i32 %32, 6
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.32, i64 0, i64 0))
br label %64
36: ; preds = %31
%37 = call i32 @register_user(i8* %7, i8* %8)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i8* %7)
br label %64
39: ; preds = %16
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %10)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i8* %11)
%44 = call i32 @check_login(i8* %10, i8* %11, i8* %7, i8* %8)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.31, i64 0, i64 0))
br label %64
48: ; preds = %39
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.30, i64 0, i64 0))
br label %64
50: ; preds = %16
%51 = icmp eq i32 %17, 0
br i1 %51, label %52, label %54
52: ; preds = %50
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.29, i64 0, i64 0))
br label %64
54: ; preds = %50
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0), i8* %9)
br label %64
56: ; preds = %16
%57 = icmp eq i32 %17, 0
br i1 %57, label %58, label %60
58: ; preds = %56
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.29, i64 0, i64 0))
br label %64
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.23, i64 0, i64 0))
%62 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %9)
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.27, i64 0, i64 0))
br label %64
64: ; preds = %29, %34, %36, %46, %48, %52, %54, %58, %60
%65 = phi i32 [ 0, %58 ], [ 1, %60 ], [ 0, %52 ], [ 1, %54 ], [ %17, %46 ], [ 1, %48 ], [ %17, %29 ], [ %17, %34 ], [ %17, %36 ]
br label %16
66: ; preds = %16
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.34, i64 0, i64 0))
ret i32 -1
}