#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 {
  unsigned long long rlim_cur;
  unsigned long long rlim_max;
};

/* Variables and functions */
unsigned long long RLIM_INFINITY;
int /*<<< orphan*/ err_sys(char *, char *);
scalar_t__ getrlimit(int, struct rlimit *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
void pr_limits(char *name, int resource) {
  struct rlimit limit;
  unsigned long long lim;
  if (getrlimit(resource, &limit) < 0)
    err_sys("getrlimit error for %s", name);
  printf("%-14s ", name);
  if (limit.rlim_cur == RLIM_INFINITY) {
    printf("(infinite)  ");
  } else {
    lim = limit.rlim_cur;
    printf("%10lld ", lim);
  }
  if (limit.rlim_max == RLIM_INFINITY) {
    printf("(infinite)  ");
  } else {
    lim = limit.rlim_max;
    printf("%10lld ", lim);
  }
  putchar((int)'\n');
}


x86 assembly (clang, -O0):
<pr_limits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <getrlimit@plt>
cmp    $0x0,%rax
jge    1175 <pr_limits+0x35>
mov    -0x8(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1040 <err_sys@plt>
mov    -0x8(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
jne    11ae <pr_limits+0x6e>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c8 <pr_limits+0x88>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x2e0d(%rip),%rcx
cmp    (%rcx),%rax
jne    11ef <pr_limits+0xaf>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1209 <pr_limits+0xc9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_limits>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%eax
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    %eax,%edi
call   1060 <getrlimit@plt>
test   %rax,%rax
jns    1168 <pr_limits+0x28>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1040 <err_sys@plt>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rsi
mov    0x2e5c(%rip),%rbx
cmp    (%rbx),%rsi
jne    1199 <pr_limits+0x59>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a7 <pr_limits+0x67>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
cmp    (%rbx),%rsi
jne    11c1 <pr_limits+0x81>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cf <pr_limits+0x8f>
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.rlimit = type { i64, i64 }
@.str = [23 x i8] c"getrlimit error for %s\00"
@.str.1 = [7 x i8] c"%-14s \00"
@RLIM_INFINITY = global i64 0
@.str.2 = [13 x i8] c"(infinite) \00"
@.str.3 = [8 x i8] c"%10lld \00"
define void @pr_limits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.rlimit
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i64 @getrlimit(i32 %7, %struct.rlimit* %5)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @err_sys(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @RLIM_INFINITY
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %27
22: ; preds = %13
%23 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
%24 = load i64, i64* %23
store i64 %24, i64* %6
%25 = load i64, i64* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %22, %20
%28 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
%29 = load i64, i64* %28
%30 = load i64, i64* @RLIM_INFINITY
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %39
34: ; preds = %27
%35 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
%36 = load i64, i64* %35
store i64 %36, i64* %6
%37 = load i64, i64* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %37)
br label %39
39: ; preds = %34, %32
%40 = call i32 @putchar(i32 10)
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i64, i64 }
@.str = [23 x i8] c"getrlimit error for %s\00"
@.str.1 = [7 x i8] c"%-14s \00"
@RLIM_INFINITY = global i64 0
@.str.2 = [13 x i8] c"(infinite) \00"
@.str.3 = [8 x i8] c"%10lld \00"
define void @pr_limits(i8* %0, i32 %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = call i64 @getrlimit(i32 %1, %struct.rlimit* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @err_sys(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%12 = load i64, i64* %11
%13 = load i64, i64* @RLIM_INFINITY
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %19
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %12)
br label %19
19: ; preds = %17, %15
%20 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
%21 = load i64, i64* %20
%22 = load i64, i64* @RLIM_INFINITY
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %21)
br label %28
28: ; preds = %26, %24
%29 = call i32 @putchar(i32 10)
ret void
}