#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 {
  int dummy;
};

/* Variables and functions */
scalar_t__ EINVAL;
int /*<<< orphan*/ RLIMIT_NPROC;
int /*<<< orphan*/ abort();
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct rlimit *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int setrlimit(int /*<<< orphan*/, struct rlimit *);
int main(void) {
  struct rlimit lim;
  memset(&lim, 0, sizeof lim);
  if (setrlimit(RLIMIT_NPROC, &lim) != -1 || errno != EINVAL)
    abort();
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1060 <setrlimit@plt>
cmp    $0xffffffff,%eax
jne    11a4 <main+0x54>
mov    0x2e47(%rip),%rax
mov    (%rax),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
je     11ab <main+0x5b>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <setrlimit@plt>
cmp    $0xffffffff,%eax
jne    11a8 <main+0x58>
mov    0x2e52(%rip),%rax
mov    (%rax),%rax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11a8 <main+0x58>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32 }
@RLIMIT_NPROC = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@.str = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.rlimit
store i32 0, i32* %1
%3 = call i32 @memset(%struct.rlimit* %2, i32 0, i32 4)
%4 = load i32, i32* @RLIMIT_NPROC
%5 = call i32 @setrlimit(i32 %4, %struct.rlimit* %2)
%6 = icmp ne i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINVAL
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7, %0
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.rlimit = type { i32 }
@RLIMIT_NPROC = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@str = [5 x i8] c"pass\00"
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = call i32 @memset(%struct.rlimit* %1, i32 0, i32 4)
%4 = load i32, i32* @RLIMIT_NPROC
%5 = call i32 @setrlimit(i32 %4, %struct.rlimit* %1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINVAL
%10 = icmp eq i64 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %7, %0
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
}