#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 /*<<< orphan*/ changeToSehllEnvironment();
int /*<<< orphan*/ changeToUserEnvirnment();
void *malloc(int);
int /*<<< orphan*/ parser(char *);
int /*<<< orphan*/ printFF(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ printShellComand();
int /*<<< orphan*/ putchar(char);
scalar_t__ scanFF(char *, char **, int /*<<< orphan*/);
int main() {
  char **ss = malloc(sizeof(char *));
  char *sos = malloc(2500);
  ss[0] = sos;
  while (1) {
    putchar('\n');
    changeToSehllEnvironment();
    printShellComand();
    changeToUserEnvirnment();
    if (scanFF("%s", ss, 0) == 0) {
      changeToSehllEnvironment();
      parser(sos);
    } else {
      char **s = malloc(sizeof(char *));
      char *help = "ScanFF Buffer OverFlow";
      s[0] = help;
      putchar('\n');
      printFF("%s", s, 0);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x9c4,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    $0x0,%al
call   1080 <changeToSehllEnvironment@plt>
mov    $0x0,%al
call   1030 <printShellComand@plt>
mov    $0x0,%al
call   1070 <changeToUserEnvirnment@plt>
mov    -0x10(%rbp),%rsi
lea    0xe20(%rip),%rdi
xor    %edx,%edx
call   1040 <scanFF@plt>
cmp    $0x0,%rax
jne    1206 <main+0x86>
mov    $0x0,%al
call   1080 <changeToSehllEnvironment@plt>
mov    -0x18(%rbp),%rdi
call   1090 <parser@plt>
jmp    1246 <main+0xc6>
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xde8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    -0x20(%rbp),%rsi
lea    0xdc1(%rip),%rdi
xor    %edx,%edx
call   1060 <printFF@plt>
jmp    11b6 <main+0x36>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    $0x9c4,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%r12)
lea    0xe52(%rip),%r15
lea    0xe4e(%rip),%r13
jmp    11e7 <main+0x67>
nopw   0x0(%rax,%rax,1)
mov    $0x8,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %r13,(%rax)
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1060 <printFF@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
xor    %eax,%eax
call   1080 <changeToSehllEnvironment@plt>
xor    %eax,%eax
call   1030 <printShellComand@plt>
xor    %eax,%eax
call   1070 <changeToUserEnvirnment@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <scanFF@plt>
test   %rax,%rax
jne    11c0 <main+0x40>
xor    %eax,%eax
call   1080 <changeToSehllEnvironment@plt>
mov    %r14,%rdi
call   1090 <parser@plt>
jmp    11e7 <main+0x67>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [23 x i8] c"ScanFF Buffer OverFlow\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* @malloc(i32 8)
%7 = bitcast i8* %6 to i8**
store i8** %7, i8*** %2
%8 = call i8* @malloc(i32 2500)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 0
store i8* %9, i8** %11
br label %12
12: ; preds = %0, %33
%13 = call i32 @putchar(i8 signext 10)
%14 = call i32 (...) @changeToSehllEnvironment()
%15 = call i32 (...) @printShellComand()
%16 = call i32 (...) @changeToUserEnvirnment()
%17 = load i8**, i8*** %2
%18 = call i64 @scanFF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %17, i32 0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %12
%21 = call i32 (...) @changeToSehllEnvironment()
%22 = load i8*, i8** %3
%23 = call i32 @parser(i8* %22)
br label %33
24: ; preds = %12
%25 = call i8* @malloc(i32 8)
%26 = bitcast i8* %25 to i8**
store i8** %26, i8*** %4
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %5
%27 = load i8*, i8** %5
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 0
store i8* %27, i8** %29
%30 = call i32 @putchar(i8 signext 10)
%31 = load i8**, i8*** %4
%32 = call i32 @printFF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %31, i32 0)
br label %33
33: ; preds = %24, %20
br label %12
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [23 x i8] c"ScanFF Buffer OverFlow\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%2 = bitcast i8* %1 to i8**
%3 = tail call dereferenceable_or_null(2500) i8* @malloc(i32 2500)
store i8* %3, i8** %2
br label %4
4: ; preds = %19, %0
%5 = tail call i32 @putchar(i8 signext 10)
%6 = tail call i32 (...) @changeToSehllEnvironment()
%7 = tail call i32 (...) @printShellComand()
%8 = tail call i32 (...) @changeToUserEnvirnment()
%9 = tail call i64 @scanFF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2, i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = tail call i32 (...) @changeToSehllEnvironment()
%13 = tail call i32 @parser(i8* %3)
br label %19
14: ; preds = %4
%15 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%16 = bitcast i8* %15 to i8**
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %16
%17 = tail call i32 @putchar(i8 signext 10)
%18 = tail call i32 @printFF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %16, i32 0)
br label %19
19: ; preds = %14, %11
br label %4
}