#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_stack_integrity(unsigned int *);
int /*<<< orphan*/ __fill_air_space(unsigned int *);
int /*<<< orphan*/ __print_error_message();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int __lets_play(char *param) {
  unsigned int air_space[20];
  __fill_air_space(air_space);
  char buffer[20];
  strcpy(buffer, param);
  if (__check_stack_integrity(air_space) == -1) {
    __print_error_message();
    printf("[!] The base stack has been modified\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<__lets_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
call   1060 <__fill_air_space@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
call   1070 <__check_stack_integrity@plt>
cmp    $0xffffffff,%eax
jne    11b4 <__lets_play+0x54>
mov    $0x0,%al
call   1040 <__print_error_message@plt>
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__lets_play>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rdi,%rbx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1060 <__fill_air_space@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1070 <__check_stack_integrity@plt>
cmp    $0xffffffff,%eax
je     1199 <__lets_play+0x39>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1050 <__print_error_message@plt>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"[!] The base stack has been modified\0A\00"
define i32 @__lets_play(i8* %0) {
%2 = alloca i8*
%3 = alloca [20 x i32]
%4 = alloca [20 x i8]
store i8* %0, i8** %2
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%6 = call i32 @__fill_air_space(i32* %5)
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%11 = call i32 @__check_stack_integrity(i32* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = call i32 (...) @__print_error_message()
%15 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %1
ret i32 0
}

LLVM IR (-O2):
@str = [37 x i8] c"[!] The base stack has been modified\00"
define i32 @__lets_play(i8* %0) {
%2 = alloca [20 x i32]
%3 = alloca [20 x i8]
%4 = bitcast [20 x i32]* %2 to i8*
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%6 = call i32 @__fill_air_space(i32* %5)
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i32 @__check_stack_integrity(i32* %5)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = call i32 (...) @__print_error_message()
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %1
ret i32 0
}