#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;
  scalar_t__ rlim_max;
};

/* Variables and functions */
scalar_t__ RLIM_INFINITY;
int getrlimit(int, struct rlimit *);
int /*<<< orphan*/ printf(char *, ...);
int printRlimit(const char *msg, int resource) {
  struct rlimit rlim;
  if (getrlimit(resource, &rlim) == -1)
    return -1;
  printf("%s soft=", msg);
  if (rlim.rlim_cur == RLIM_INFINITY)
    printf("infinite");
  else
    printf("%lld", (long long)rlim.rlim_cur);
  printf("; hard=");
  if (rlim.rlim_max == RLIM_INFINITY)
    printf("infinite\n");
  else
    printf("%lld\n", (long long)rlim.rlim_max);
  return 0;
}


x86 assembly (clang, -O0):
<printRlimit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1040 <getrlimit@plt>
cmp    $0xffffffff,%eax
jne    1150 <printRlimit+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e9 <printRlimit+0xc9>
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
jne    1189 <printRlimit+0x69>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119b <printRlimit+0x7b>
mov    -0x28(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <printRlimit+0xb0>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <printRlimit+0xc2>
mov    -0x20(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printRlimit>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%eax
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1050 <getrlimit@plt>
cmp    $0xffffffff,%eax
je     117f <printRlimit+0x4f>
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
mov    0x2e76(%rip),%r14
cmp    (%r14),%rsi
jne    1186 <printRlimit+0x56>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1194 <printRlimit+0x64>
mov    $0xffffffff,%ebx
jmp    11ca <printRlimit+0x9a>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rsi
cmp    (%r14),%rsi
jne    11bc <printRlimit+0x8c>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
jmp    11ca <printRlimit+0x9a>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.rlimit = type { i64, i64 }
@.str = [9 x i8] c"%s soft=\00"
@RLIM_INFINITY = global i64 0
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [8 x i8] c"; hard=\00"
@.str.5 = [6 x i8] c"%lld\0A\00"
@str = [9 x i8] c"infinite\00"
define i32 @printRlimit(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 %27, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @RLIM_INFINITY
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %7
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %10)
br label %17
17: ; preds = %15, %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
%20 = load i64, i64* %19
%21 = load i64, i64* @RLIM_INFINITY
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %27
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 %20)
br label %27
27: ; preds = %23, %25, %2
%28 = phi i32 [ -1, %2 ], [ 0, %25 ], [ 0, %23 ]
ret i32 %28
}