#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*/ printf(char *, ...);
int main(void) {
  char *badstring = 0;
  const char *s = "gdbgui";
  int myvar = 100;
  unsigned int myvar2 = 200;
  printf(
      "The next function call will cause a segfault. With gdbgui, the state of "
      "the program\n"
      "can be debugged at the time the program exited by running the command\n"
      "\"backtrace\" or \"bt\" in the gdb console.\n\n"
      "It will re-enter the state the\n"
      "program was in, including the stack trace: you'll end up in `main -> "
      "_IO_puts -> strlen`.\n"
      "If you click on the `main` function in the call stack, gdbgui will put "
      "you in the main function\n"
      "where you can inspect your local\n"
      "variables and determine how the segfault occured.\n\n");
  printf("%s\n", badstring);
  printf(
      "This line is never reached because the above line causes a segfault\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x64,-0x1c(%rbp)
movl   $0xc8,-0x20(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0x109f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0x1095(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1030 <puts@plt>
lea    0x10c5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"gdbgui\00"
@.str.1 = [497 x i8] c"The next function call will cause a segfault. With gdbgui, the state of the program\0Acan be debugged at the time the program exited by running the command\0A\22backtrace\22 or \22bt\22 in the gdb console.\0A\0AIt will re-enter the state the\0Aprogram was in, including the stack trace: you'll end up in `main -> _IO_puts -> strlen`.\0AIf you click on the `main` function in the call stack, gdbgui will put you in the main function\0Awhere you can inspect your local\0Avariables and determine how the segfault occured.\0A\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [69 x i8] c"This line is never reached because the above line causes a segfault\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 100, i32* %4
store i32 200, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([497 x i8], [497 x i8]* @.str.1, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [496 x i8] c"The next function call will cause a segfault. With gdbgui, the state of the program\0Acan be debugged at the time the program exited by running the command\0A\22backtrace\22 or \22bt\22 in the gdb console.\0A\0AIt will re-enter the state the\0Aprogram was in, including the stack trace: you'll end up in `main -> _IO_puts -> strlen`.\0AIf you click on the `main` function in the call stack, gdbgui will put you in the main function\0Awhere you can inspect your local\0Avariables and determine how the segfault occured.\0A\00"
@str.4 = [68 x i8] c"This line is never reached because the above line causes a segfault\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([496 x i8], [496 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) null)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}