#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__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
scalar_t__ fork();
int /*<<< orphan*/ *getenv(char *);
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
void create_core(void) {
  if (getenv("LIBMEMCACHED_NO_COREDUMP") == NULL) {
    pid_t pid = fork();
    if (pid == 0) {
      abort();
    } else {
      while (waitpid(pid, NULL, 0) != pid) {
        ;
      }
    }
  }
}


x86 assembly (clang, -O0):
<create_core>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
jne    11a8 <create_core+0x68>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117b <create_core+0x3b>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    1180 <create_core+0x40>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
cmp    -0x8(%rbp),%rax
je     119e <create_core+0x5e>
jmp    1180 <create_core+0x40>
jmp    11a3 <create_core+0x63>
jmp    11a8 <create_core+0x68>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_core>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1181 <create_core+0x41>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1183 <create_core+0x43>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <waitpid@plt>
cmp    %rbx,%rax
jne    1170 <create_core+0x30>
pop    %rbx
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"LIBMEMCACHED_NO_COREDUMP\00"
define void @create_core() {
%1 = alloca i64
%2 = call i32* @getenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %19
4: ; preds = %0
%5 = call i64 (...) @fork()
store i64 %5, i64* %1
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %4
br label %11
11: ; preds = %16, %10
%12 = load i64, i64* %1
%13 = call i64 @waitpid(i64 %12, i32* null, i32 0)
%14 = load i64, i64* %1
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %11
br label %11
17: ; preds = %11
br label %18
18: ; preds = %17
br label %19
19: ; preds = %18, %0
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"LIBMEMCACHED_NO_COREDUMP\00"
define void @create_core() {
%1 = tail call i32* @getenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %11
3: ; preds = %0
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %3, %8
%9 = tail call i64 @waitpid(i64 %4, i32* null, i32 0)
%10 = icmp eq i64 %9, %4
br i1 %10, label %11, label %8
11: ; preds = %8, %0
ret void
}