#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 */

/* Variables and functions */
int RLIMIT_AS;
int RLIMIT_CORE;
int RLIMIT_CPU;
int RLIMIT_DATA;
int RLIMIT_FSIZE;
int RLIMIT_LOCKS;
int RLIMIT_MEMLOCK;
int RLIMIT_MSGQUEUE;
int RLIMIT_NICE;
int RLIMIT_NOFILE;
int RLIMIT_NPROC;
int RLIMIT_RSS;
int RLIMIT_RTPRIO;
int RLIMIT_SIGPENDING;
int RLIMIT_STACK;
int /*<<< orphan*/ die(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ setlimit(int, char *);
void parselim(char *opt) {
  char c;
  int key;
  switch (c = *(opt++)) {
  case 'a':
    key = RLIMIT_AS;
    break;
  case 'c':
    key = RLIMIT_CORE;
    break;
  case 'd':
    key = RLIMIT_DATA;
    break;
  case 'e':
    key = RLIMIT_NICE;
    break;
  case 'f':
    key = RLIMIT_FSIZE;
    break;
  case 'i':
    key = RLIMIT_SIGPENDING;
    break;
  case 'l':
    key = RLIMIT_MEMLOCK;
    break;
  case 'm':
    key = RLIMIT_RSS;
    break;
  case 'n':
    key = RLIMIT_NOFILE;
    break;
  case 'q':
    key = RLIMIT_MSGQUEUE;
    break;
  case 'r':
    key = RLIMIT_RTPRIO;
    break;
  case 's':
    key = RLIMIT_STACK;
    break;
  case 't':
    key = RLIMIT_CPU;
    break;
  case 'x':
    key = RLIMIT_LOCKS;
    break;
  case 'T':
    key = RLIMIT_NPROC;
    break;
  default:
    *opt = '\0';
    die("Unrecognized ulimit key +", (opt - 1), NULL);
  }
  setlimit(key, opt);
}


x86 assembly (clang, -O0):
<parselim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %al,%cl
mov    %cl,-0x9(%rbp)
add    $0xffffffac,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x24,%eax
ja     1268 <parselim+0x148>
mov    -0x18(%rbp),%rax
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1287 <parselim+0x167>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <die@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <setlimit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parselim>:
push   %rax
mov    %rdi,%rsi
movsbl (%rdi),%eax
lea    -0x54(%rax),%ecx
cmp    $0x25,%ecx
jae    115c <parselim+0x3c>
movabs $0x11e727a001,%rdx
bt     %rcx,%rdx
jae    115c <parselim+0x3c>
add    $0x1,%rsi
cltq
lea    0x2bac(%rip),%rcx
mov    -0x2a0(%rcx,%rax,8),%rax
ff
mov    (%rax),%edi
pop    %rax
jmp    1030 <setlimit@plt>
movb   $0x0,0x1(%rsi)
lea    0xe99(%rip),%rdi
xor    %edx,%edx
call   1040 <die@plt>

LLVM IR (-O0):
@RLIMIT_AS = global i32 0
@RLIMIT_CORE = global i32 0
@RLIMIT_DATA = global i32 0
@RLIMIT_NICE = global i32 0
@RLIMIT_FSIZE = global i32 0
@RLIMIT_SIGPENDING = global i32 0
@RLIMIT_MEMLOCK = global i32 0
@RLIMIT_RSS = global i32 0
@RLIMIT_NOFILE = global i32 0
@RLIMIT_MSGQUEUE = global i32 0
@RLIMIT_RTPRIO = global i32 0
@RLIMIT_STACK = global i32 0
@RLIMIT_CPU = global i32 0
@RLIMIT_LOCKS = global i32 0
@RLIMIT_NPROC = global i32 0
@.str = [26 x i8] c"Unrecognized ulimit key +\00"
define void @parselim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i32 1
store i8* %6, i8** %2
%7 = load i8, i8* %5
store i8 %7, i8* %3
%8 = sext i8 %7 to i32
switch i32 %8, label %39 [
i32 97, label %9
i32 99, label %11
i32 100, label %13
i32 101, label %15
i32 102, label %17
i32 105, label %19
i32 108, label %21
i32 109, label %23
i32 110, label %25
i32 113, label %27
i32 114, label %29
i32 115, label %31
i32 116, label %33
i32 120, label %35
i32 84, label %37
]
9: ; preds = %1
%10 = load i32, i32* @RLIMIT_AS
store i32 %10, i32* %4
br label %44
11: ; preds = %1
%12 = load i32, i32* @RLIMIT_CORE
store i32 %12, i32* %4
br label %44
13: ; preds = %1
%14 = load i32, i32* @RLIMIT_DATA
store i32 %14, i32* %4
br label %44
15: ; preds = %1
%16 = load i32, i32* @RLIMIT_NICE
store i32 %16, i32* %4
br label %44
17: ; preds = %1
%18 = load i32, i32* @RLIMIT_FSIZE
store i32 %18, i32* %4
br label %44
19: ; preds = %1
%20 = load i32, i32* @RLIMIT_SIGPENDING
store i32 %20, i32* %4
br label %44
21: ; preds = %1
%22 = load i32, i32* @RLIMIT_MEMLOCK
store i32 %22, i32* %4
br label %44
23: ; preds = %1
%24 = load i32, i32* @RLIMIT_RSS
store i32 %24, i32* %4
br label %44
25: ; preds = %1
%26 = load i32, i32* @RLIMIT_NOFILE
store i32 %26, i32* %4
br label %44
27: ; preds = %1
%28 = load i32, i32* @RLIMIT_MSGQUEUE
store i32 %28, i32* %4
br label %44
29: ; preds = %1
%30 = load i32, i32* @RLIMIT_RTPRIO
store i32 %30, i32* %4
br label %44
31: ; preds = %1
%32 = load i32, i32* @RLIMIT_STACK
store i32 %32, i32* %4
br label %44
33: ; preds = %1
%34 = load i32, i32* @RLIMIT_CPU
store i32 %34, i32* %4
br label %44
35: ; preds = %1
%36 = load i32, i32* @RLIMIT_LOCKS
store i32 %36, i32* %4
br label %44
37: ; preds = %1
%38 = load i32, i32* @RLIMIT_NPROC
store i32 %38, i32* %4
br label %44
39: ; preds = %1
%40 = load i8*, i8** %2
store i8 0, i8* %40
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i64 -1
%43 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %42, i32* null)
br label %44
44: ; preds = %39, %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9
%45 = load i32, i32* %4
%46 = load i8*, i8** %2
%47 = call i32 @setlimit(i32 %45, i8* %46)
ret void
}

LLVM IR (-O2):
@RLIMIT_AS = global i32 0
@RLIMIT_CORE = global i32 0
@RLIMIT_DATA = global i32 0
@RLIMIT_NICE = global i32 0
@RLIMIT_FSIZE = global i32 0
@RLIMIT_SIGPENDING = global i32 0
@RLIMIT_MEMLOCK = global i32 0
@RLIMIT_RSS = global i32 0
@RLIMIT_NOFILE = global i32 0
@RLIMIT_MSGQUEUE = global i32 0
@RLIMIT_RTPRIO = global i32 0
@RLIMIT_STACK = global i32 0
@RLIMIT_CPU = global i32 0
@RLIMIT_LOCKS = global i32 0
@RLIMIT_NPROC = global i32 0
@.str = [26 x i8] c"Unrecognized ulimit key +\00"
@switch.table.parselim = [37 x i32*] [i32* @RLIMIT_NPROC, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_CORE, i32* @RLIMIT_DATA, i32* @RLIMIT_NICE, i32* @RLIMIT_FSIZE, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_SIGPENDING, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_MEMLOCK, i32* @RLIMIT_RSS, i32* @RLIMIT_NOFILE, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_MSGQUEUE, i32* @RLIMIT_RTPRIO, i32* @RLIMIT_STACK, i32* @RLIMIT_CPU, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_AS, i32* @RLIMIT_LOCKS]
define void @parselim(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
%5 = add nsw i32 %4, -84
%6 = icmp ult i32 %5, 37
br i1 %6, label %9, label %7
7: ; preds = %9, %1
store i8 0, i8* %2
%8 = tail call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, i32* null)
unreachable
9: ; preds = %1
%10 = zext i32 %5 to i64
%11 = lshr i64 76892577793, %10
%12 = and i64 %11, 1
%13 = icmp eq i64 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %9
%15 = sext i32 %5 to i64
%16 = getelementptr inbounds [37 x i32*], [37 x i32*]* @switch.table.parselim, i64 0, i64 %15
%17 = load i32*, i32** %16
%18 = load i32, i32* %17
%19 = tail call i32 @setlimit(i32 %18, i8* %2)
ret void
}