#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ err_msg(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getrlimit(int, struct rlimit *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int Getrlimit(int resource, struct rlimit *rlim) {
  int ret;
  if ((ret = getrlimit(resource, rlim)) == -1) {
    err_msg("error getrlimit: %s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  return ret;
}


x86 assembly (clang, -O0):
<Getrlimit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1191 <Getrlimit+0x51>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1030 <err_msg@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Getrlimit>:
push   %rax
call   1050 <getrlimit@plt>
cmp    $0xffffffff,%eax
je     114d <Getrlimit+0xd>
pop    %rcx
ret
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe9e(%rip),%rdi
mov    %eax,%esi
call   1030 <err_msg@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32 }
@.str = [20 x i8] c"error getrlimit: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @Getrlimit(i32 %0, %struct.rlimit* %1) {
%3 = alloca i32
%4 = alloca %struct.rlimit*
%5 = alloca i32
store i32 %0, i32* %3
store %struct.rlimit* %1, %struct.rlimit** %4
%6 = load i32, i32* %3
%7 = load %struct.rlimit*, %struct.rlimit** %4
%8 = call i32 @getrlimit(i32 %6, %struct.rlimit* %7)
store i32 %8, i32* %5
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @err_msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i32, i32* %5
ret i32 %17
}

LLVM IR (-O2):
%struct.rlimit = type { i32 }
@.str = [20 x i8] c"error getrlimit: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @Getrlimit(i32 %0, %struct.rlimit* %1) {
%3 = tail call i32 @getrlimit(i32 %0, %struct.rlimit* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @errno
%7 = tail call i32 @strerror(i32 %6)
%8 = tail call i32 @err_msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
ret i32 %3
}