#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 */
struct rlimit {
  scalar_t__ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CORE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ stderr;
void ulimit_core_check(void) {
  struct rlimit limit;
  if (getrlimit(RLIMIT_CORE, &limit) != 0)
    return;
  if (limit.rlim_cur != 0)
    return;
  fprintf(stderr, "Core dump size is zero. To get a full core dump use 'ulimit "
                  "-c unlimited'.\n");
}


x86 assembly (clang, -O0):
<ulimit_core_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1040 <getrlimit@plt>
cmp    $0x0,%rax
je     1149 <ulimit_core_check+0x29>
jmp    116e <ulimit_core_check+0x4e>
cmpq   $0x0,-0x8(%rbp)
je     1159 <ulimit_core_check+0x39>
jmp    116e <ulimit_core_check+0x4e>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulimit_core_check>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <getrlimit@plt>
or     (%rsp),%rax
jne    114d <ulimit_core_check+0x2d>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.rlimit = type { i64 }
@RLIMIT_CORE = global i32 0
@stderr = global i32 0
@.str = [76 x i8] c"Core dump size is zero. To get a full core dump use 'ulimit -c unlimited'.\0A\00"
define void @ulimit_core_check() {
%1 = alloca %struct.rlimit
%2 = load i32, i32* @RLIMIT_CORE
%3 = call i64 @getrlimit(i32 %2, %struct.rlimit* %1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
br label %14
6: ; preds = %0
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
%8 = load i64, i64* %7
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %10, %5
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i64 }
@RLIMIT_CORE = global i32 0
@stderr = global i32 0
@.str = [76 x i8] c"Core dump size is zero. To get a full core dump use 'ulimit -c unlimited'.\0A\00"
define void @ulimit_core_check() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = load i32, i32* @RLIMIT_CORE
%4 = call i64 @getrlimit(i32 %3, %struct.rlimit* %1)
%5 = icmp eq i64 %4, 0
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = icmp eq i64 %7, 0
%9 = select i1 %5, i1 %8, i1 false
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %0, %10
ret void
}