#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 {
  char const *rlim_cur;
  char const *rlim_max;
};

/* Variables and functions */
char const *RLIM_INFINITY;
int /*<<< orphan*/ err_sys(char *, char const *);
int getrlimit(int, struct rlimit *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void pr_limits(char const *name, int res) {
  struct rlimit lmt;
  if (getrlimit(res, &lmt) == -1)
    err_sys("getrlimit error for %s", name);
  printf("%-14s  ", name);
  if (lmt.rlim_cur == RLIM_INFINITY)
    printf("(infinite)  ");
  else
    printf("%10ld  ", lmt.rlim_cur);
  if (lmt.rlim_max == RLIM_INFINITY)
    printf("(infinite)  ");
  else
    printf("%10ld  ", lmt.rlim_max);
  putchar('\n');
}


x86 assembly (clang, -O0):
<pr_limits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <getrlimit@plt>
cmp    $0xffffffff,%eax
jne    1174 <pr_limits+0x34>
mov    -0x8(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1040 <err_sys@plt>
mov    -0x8(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%rax
jne    11ad <pr_limits+0x6d>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11bf <pr_limits+0x7f>
mov    -0x20(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%rax
jne    11e6 <pr_limits+0xa6>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f8 <pr_limits+0xb8>
mov    -0x18(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%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>
cmp    $0xffffffff,%eax
jne    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
je     1199 <pr_limits+0x59>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a7 <pr_limits+0x67>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
cmp    (%rbx),%rsi
je     11c1 <pr_limits+0x81>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cf <pr_limits+0x8f>
lea    0xe57(%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 { i8*, i8* }
@.str = [23 x i8] c"getrlimit error for %s\00"
@.str.1 = [8 x i8] c"%-14s \00"
@RLIM_INFINITY = global i8* null
@.str.2 = [13 x i8] c"(infinite) \00"
@.str.3 = [8 x i8] c"%10ld \00"
define void @pr_limits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.rlimit
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @getrlimit(i32 %6, %struct.rlimit* %5)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @err_sys(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = load i8*, i8** @RLIM_INFINITY
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %25
21: ; preds = %12
%22 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %21, %19
%26 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
%27 = load i8*, i8** %26
%28 = load i8*, i8** @RLIM_INFINITY
%29 = icmp eq i8* %27, %28
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %36
32: ; preds = %25
%33 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %32, %30
%37 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i8*, i8* }
@.str = [23 x i8] c"getrlimit error for %s\00"
@.str.1 = [8 x i8] c"%-14s \00"
@RLIM_INFINITY = global i8* null
@.str.2 = [13 x i8] c"(infinite) \00"
@.str.3 = [8 x i8] c"%10ld \00"
define void @pr_limits(i8* %0, i32 %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = call i32 @getrlimit(i32 %1, %struct.rlimit* %3)
%6 = icmp eq i32 %5, -1
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 ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = load i8*, i8** @RLIM_INFINITY
%14 = icmp eq i8* %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), i8* %12)
br label %19
19: ; preds = %17, %15
%20 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
%21 = load i8*, i8** %20
%22 = load i8*, i8** @RLIM_INFINITY
%23 = icmp eq i8* %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), i8* %21)
br label %28
28: ; preds = %26, %24
%29 = call i32 @putchar(i8 signext 10)
ret void
}