#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 size_t uint8_t;

/* Variables and functions */
int /*<<< orphan*/ overflowme(size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, size_t);
int main(int argc, char *argv[]) {
  uint8_t a = 11;
  uint8_t b = 22;
  size_t c[10];
  printf("Stack location (a):     %zx\n", (size_t)&a);
  printf("Stack location (b):     %zx\n", (size_t)&b);
  printf("Stack location (c[0]):  %zx\n", (size_t)&c[0]);
  printf("Stack location (c[10]): %zx\n", (size_t)&c[10]);
  printf("Stack location (c[-1]): %zx\n", ((size_t)&c[-25]));
  printf("before (a):    %hhx\n", a);
  overflowme(c, 0);
  printf("after (a):     %hhx\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xb,-0x18(%rbp)
movq   $0x16,-0x20(%rbp)
lea    -0x18(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
add    $0x50,%rsi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
add    $0xffffffffffffff38,%rsi
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
call   1040 <overflowme@plt>
mov    -0x18(%rbp),%rsi
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movq   $0xb,(%rsp)
movq   $0x16,0x8(%rsp)
lea    0xec3(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x60(%rsp),%rsi
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    -0xb8(%rsp),%rsi
ff
lea    0xeea(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%rsi
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <overflowme@plt>
mov    (%rsp),%rsi
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Stack location (a): %zx\0A\00"
@.str.1 = [29 x i8] c"Stack location (b): %zx\0A\00"
@.str.2 = [29 x i8] c"Stack location (c[0]): %zx\0A\00"
@.str.3 = [29 x i8] c"Stack location (c[10]): %zx\0A\00"
@.str.4 = [29 x i8] c"Stack location (c[-1]): %zx\0A\00"
@.str.5 = [21 x i8] c"before (a): %hhx\0A\00"
@.str.6 = [21 x i8] c"after (a): %hhx\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca [10 x i64]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 11, i64* %6
store i64 22, i64* %7
%9 = ptrtoint i64* %6 to i64
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = ptrtoint i64* %7 to i64
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = getelementptr inbounds [10 x i64], [10 x i64]* %8, i64 0, i64 0
%14 = ptrtoint i64* %13 to i64
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = getelementptr inbounds [10 x i64], [10 x i64]* %8, i64 0, i64 10
%17 = ptrtoint i64* %16 to i64
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %17)
%19 = getelementptr inbounds [10 x i64], [10 x i64]* %8, i64 0, i64 -25
%20 = ptrtoint i64* %19 to i64
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 %22)
%24 = getelementptr inbounds [10 x i64], [10 x i64]* %8, i64 0, i64 0
%25 = call i32 @overflowme(i64* %24, i32 0)
%26 = load i64, i64* %6
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i64 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Stack location (a): %zx\0A\00"
@.str.1 = [29 x i8] c"Stack location (b): %zx\0A\00"
@.str.2 = [29 x i8] c"Stack location (c[0]): %zx\0A\00"
@.str.3 = [29 x i8] c"Stack location (c[10]): %zx\0A\00"
@.str.4 = [29 x i8] c"Stack location (c[-1]): %zx\0A\00"
@.str.5 = [21 x i8] c"before (a): %hhx\0A\00"
@.str.6 = [21 x i8] c"after (a): %hhx\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [10 x i64]
%6 = bitcast i64* %3 to i8*
store i64 11, i64* %3
%7 = bitcast i64* %4 to i8*
store i64 22, i64* %4
%8 = bitcast [10 x i64]* %5 to i8*
%9 = ptrtoint i64* %3 to i64
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = ptrtoint i64* %4 to i64
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = getelementptr inbounds [10 x i64], [10 x i64]* %5, i64 0, i64 0
%14 = ptrtoint [10 x i64]* %5 to i64
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = getelementptr inbounds [10 x i64], [10 x i64]* %5, i64 0, i64 10
%17 = ptrtoint i64* %16 to i64
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %17)
%19 = getelementptr inbounds [10 x i64], [10 x i64]* %5, i64 0, i64 -25
%20 = ptrtoint i64* %19 to i64
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 %22)
%24 = call i32 @overflowme(i64* %13, i32 0)
%25 = load i64, i64* %3
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i64 %25)
ret i32 0
}