#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ enableCoreDump();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  (void)argc;
  enableCoreDump();
  printf("\n");
  printf("Getting ready to crash...\n");
  printf("If a core dump gets created, it will create a file named 'core' in "
         "the current directory.\n");
  printf("To debug using coredump file, run: gdb %s core\n", argv[0]);
  ssize_t *x = (ssize_t *)0xdeadbeef;
  int sum = 0;
  while (1) {
    sum += *x;
    x++;
  }
  printf("Sum: %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <enableCoreDump@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xdeadbeef,%eax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x18(%rbp)
jmp    118c <main+0x6c>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
call   1060 <enableCoreDump@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
lea    0xee2(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%rsi
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xchg   %ax,%ax
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [27 x i8] c"Getting ready to crash...\0A\00"
@.str.2 = [91 x i8] c"If a core dump gets created, it will create a file named 'core' in the current directory.\0A\00"
@.str.3 = [48 x i8] c"To debug using coredump file, run: gdb %s core\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = call i32 (...) @enableCoreDump()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %15)
store i64* inttoptr (i64 3735928559 to i64*), i64** %6
store i32 0, i32* %7
br label %17
17: ; preds = %2, %17
%18 = load i64*, i64** %6
%19 = load i64, i64* %18
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = add nsw i64 %21, %19
%23 = trunc i64 %22 to i32
store i32 %23, i32* %7
%24 = load i64*, i64** %6
%25 = getelementptr inbounds i64, i64* %24, i32 1
store i64* %25, i64** %6
br label %17
}

LLVM IR (-O2):
@.str.3 = [48 x i8] c"To debug using coredump file, run: gdb %s core\0A\00"
@str = [26 x i8] c"Getting ready to crash...\00"
@str.4 = [90 x i8] c"If a core dump gets created, it will create a file named 'core' in the current directory.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @enableCoreDump()
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @str.4, i64 0, i64 0))
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %9, %2
br label %9
}