#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;
};
typedef scalar_t__ rlim_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_NOFILE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int getrlimit(int /*<<< orphan*/, struct rlimit *);
scalar_t__ max_open_files();
int /*<<< orphan*/ stderr;
int check_system_limits_sanity(int expected_sockets, int workers) {
  int return_value = 0;
  struct rlimit rlp;
  int ret;
  ret = getrlimit(RLIMIT_NOFILE, &rlp);
  assert(ret == 0);
  if (rlp.rlim_cur < (rlim_t)(expected_sockets + 4 + workers)) {
    fprintf(stderr,
            "WARNING: Open files limit (`ulimit -n`) %ld "
            "is too low for the expected load (-c %d).\n",
            (long)rlp.rlim_cur, expected_sockets);
    return_value = -1;
  } else if (max_open_files() < (rlim_t)(expected_sockets + 4 + workers)) {
    fprintf(stderr,
            "WARNING: System-wide open files limit %ld "
            "is too low for the expected load (-c %d).\n"
            "Consider adjusting fs.file-max or kern.maxfiles sysctl.\n",
            (long)rlp.rlim_cur, expected_sockets);
    return_value = -1;
  }
  const char *portrange_filename = "/proc/sys/net/ipv4/ip_local_port_range";
  FILE *f = fopen(portrange_filename, "r");
  if (f) {
    int lo, hi;
    if (fscanf(f, "%d %d", &lo, &hi) == 2) {
      if (hi - lo < expected_sockets) {
        fprintf(stderr,
                "WARNING: Will not be able to open "
                "%d simultaneous connections "
                "since \"%s\" specifies too narrow range [%d..%d].\n",
                expected_sockets, portrange_filename, lo, hi);
        return_value = -1;
      }
    }
    fclose(f);
  }
  const char *time_wait_reuse_filename = "/proc/sys/net/ipv4/tcp_tw_reuse";
  f = fopen(time_wait_reuse_filename, "r");
  if (f) {
    int flag;
    if (fscanf(f, "%d", &flag) == 1) {
      if (flag != 1 && expected_sockets > 10) {
        fprintf(stderr,
                "WARNING: Not reusing TIME_WAIT sockets, "
                "might not open %d simultaneous connections. "
                "Adjust \"%s\" value.\n",
                expected_sockets, time_wait_reuse_filename);
        return_value = -1;
      }
    }
    fclose(f);
  }
  const char *nf_conntrack_filename =
      "/proc/sys/net/netfilter/nf_conntrack_max";
  f = fopen(nf_conntrack_filename, "r");
  if (f) {
    int n;
    if (fscanf(f, "%d", &n) == 1) {
      if (expected_sockets > n) {
        fprintf(stderr,
                "WARNING: IP filter might not allow "
                "opening %d simultaneous connections."
                "Adjust \"%s\" value.\n",
                expected_sockets, nf_conntrack_filename);
        return_value = -1;
      }
    }
    fclose(f);
  }
  return return_value;
}


x86 assembly (clang, -O0):
<check_system_limits_sanity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1090 <getrlimit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x4,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    11f0 <check_system_limits_sanity+0x80>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
mov    -0x4(%rbp),%ecx
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    1238 <check_system_limits_sanity+0xc8>
mov    $0x0,%al
call   1040 <max_open_files@plt>
mov    -0x4(%rbp),%ecx
add    $0x4,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    1233 <check_system_limits_sanity+0xc3>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
mov    -0x4(%rbp),%ecx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    1238 <check_system_limits_sanity+0xc8>
lea    0xea5(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12cf <check_system_limits_sanity+0x15f>
mov    -0x30(%rbp),%rdi
lea    0xea0(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
cmp    $0x2,%eax
jne    12c6 <check_system_limits_sanity+0x156>
mov    -0x38(%rbp),%eax
sub    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c1 <check_system_limits_sanity+0x151>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    12c6 <check_system_limits_sanity+0x156>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xeac(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     135f <check_system_limits_sanity+0x1ef>
mov    -0x30(%rbp),%rdi
lea    0xe0c(%rip),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    1356 <check_system_limits_sanity+0x1e6>
cmpl   $0x1,-0x44(%rbp)
je     1351 <check_system_limits_sanity+0x1e1>
cmpl   $0xa,-0x4(%rbp)
jle    1351 <check_system_limits_sanity+0x1e1>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x40(%rbp),%rcx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    1356 <check_system_limits_sanity+0x1e6>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xea4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     13e7 <check_system_limits_sanity+0x277>
mov    -0x30(%rbp),%rdi
lea    0xd7c(%rip),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    13de <check_system_limits_sanity+0x26e>
mov    -0x4(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    13d9 <check_system_limits_sanity+0x269>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    -0x50(%rbp),%rcx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    13de <check_system_limits_sanity+0x26e>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_system_limits_sanity>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1090 <getrlimit@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rdx
lea    (%rbx,%rbp,1),%eax
add    $0x4,%eax
movslq %eax,%rbp
cmp    %rbp,%rdx
jge    11c1 <check_system_limits_sanity+0x51>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
jmp    11e4 <check_system_limits_sanity+0x74>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <max_open_files@plt>
cmp    %rbp,%rax
jge    11f3 <check_system_limits_sanity+0x83>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%edx
lea    0xe73(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r14d
lea    0xeea(%rip),%rdi
lea    0xf0a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     126d <check_system_limits_sanity+0xfd>
mov    %rax,%rbp
lea    0xef8(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    $0x2,%eax
jne    1265 <check_system_limits_sanity+0xf5>
mov    0x4(%rsp),%r9d
mov    (%rsp),%r8d
mov    %r9d,%eax
sub    %r8d,%eax
cmp    %ebx,%eax
jge    1265 <check_system_limits_sanity+0xf5>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
lea    0xe8e(%rip),%rcx
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xf0e(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12da <check_system_limits_sanity+0x16a>
mov    %rax,%rbp
lea    0xe81(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    12d2 <check_system_limits_sanity+0x162>
cmp    $0xb,%ebx
jl     12d2 <check_system_limits_sanity+0x162>
cmpl   $0x1,(%rsp)
je     12d2 <check_system_limits_sanity+0x162>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xee6(%rip),%rsi
lea    0xebf(%rip),%rcx
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xf29(%rip),%rdi
lea    0xe23(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1341 <check_system_limits_sanity+0x1d1>
mov    %rax,%rbp
lea    0xe14(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    1339 <check_system_limits_sanity+0x1c9>
cmp    %ebx,(%rsp)
jge    1339 <check_system_limits_sanity+0x1c9>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xf10(%rip),%rsi
lea    0xee0(%rip),%rcx
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.rlimit = type { i64 }
@RLIMIT_NOFILE = global i32 0
@stderr = global i32 0
@.str = [87 x i8] c"WARNING: Open files limit (`ulimit -n`) %ld is too low for the expected load (-c %d).\0A\00"
@.str.1 = [141 x i8] c"WARNING: System-wide open files limit %ld is too low for the expected load (-c %d).\0AConsider adjusting fs.file-max or kern.maxfiles sysctl.\0A\00"
@.str.2 = [39 x i8] c"/proc/sys/net/ipv4/ip_local_port_range\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [111 x i8] c"WARNING: Will not be able to open %d simultaneous connections since \22%s\22 specifies too narrow range [%d..%d].\0A\00"
@.str.6 = [32 x i8] c"/proc/sys/net/ipv4/tcp_tw_reuse\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [104 x i8] c"WARNING: Not reusing TIME_WAIT sockets, might not open %d simultaneous connections. Adjust \22%s\22 value.\0A\00"
@.str.9 = [41 x i8] c"/proc/sys/net/netfilter/nf_conntrack_max\00"
@.str.10 = [91 x i8] c"WARNING: IP filter might not allow opening %d simultaneous connections.Adjust \22%s\22 value.\0A\00"
define i32 @check_system_limits_sanity(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.rlimit
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%16 = load i32, i32* @RLIMIT_NOFILE
%17 = call i32 @getrlimit(i32 %16, %struct.rlimit* %6)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%23 = load i64, i64* %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 4
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %23, %28
br i1 %29, label %30, label %37
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = load i32, i32* %3
%36 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %35)
store i32 -1, i32* %5
br label %53
37: ; preds = %2
%38 = call i64 (...) @max_open_files()
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 4
%41 = load i32, i32* %4
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %38, %43
br i1 %44, label %45, label %52
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%48 = load i64, i64* %47
%49 = trunc i64 %48 to i32
%50 = load i32, i32* %3
%51 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %50)
store i32 -1, i32* %5
br label %52
52: ; preds = %45, %37
br label %53
53: ; preds = %52, %30
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8** %8
%54 = load i8*, i8** %8
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %55, i32** %9
%56 = load i32*, i32** %9
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %79
58: ; preds = %53
%59 = load i32*, i32** %9
%60 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11)
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %76
62: ; preds = %58
%63 = load i32, i32* %11
%64 = load i32, i32* %10
%65 = sub nsw i32 %63, %64
%66 = load i32, i32* %3
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %75
68: ; preds = %62
%69 = load i32, i32* @stderr
%70 = load i32, i32* %3
%71 = load i8*, i8** %8
%72 = load i32, i32* %10
%73 = load i32, i32* %11
%74 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.5, i64 0, i64 0), i32 %70, i8* %71, i32 %72, i32 %73)
store i32 -1, i32* %5
br label %75
75: ; preds = %68, %62
br label %76
76: ; preds = %75, %58
%77 = load i32*, i32** %9
%78 = call i32 @fclose(i32* %77)
br label %79
79: ; preds = %76, %53
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8** %12
%80 = load i8*, i8** %12
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %81, i32** %9
%82 = load i32*, i32** %9
%83 = icmp ne i32* %82, null
br i1 %83, label %84, label %103
84: ; preds = %79
%85 = load i32*, i32** %9
%86 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %13)
%87 = icmp eq i32 %86, 1
br i1 %87, label %88, label %100
88: ; preds = %84
%89 = load i32, i32* %13
%90 = icmp ne i32 %89, 1
br i1 %90, label %91, label %99
91: ; preds = %88
%92 = load i32, i32* %3
%93 = icmp sgt i32 %92, 10
br i1 %93, label %94, label %99
94: ; preds = %91
%95 = load i32, i32* @stderr
%96 = load i32, i32* %3
%97 = load i8*, i8** %12
%98 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.8, i64 0, i64 0), i32 %96, i8* %97)
store i32 -1, i32* %5
br label %99
99: ; preds = %94, %91, %88
br label %100
100: ; preds = %99, %84
%101 = load i32*, i32** %9
%102 = call i32 @fclose(i32* %101)
br label %103
103: ; preds = %100, %79
store i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8** %14
%104 = load i8*, i8** %14
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %105, i32** %9
%106 = load i32*, i32** %9
%107 = icmp ne i32* %106, null
br i1 %107, label %108, label %125
108: ; preds = %103
%109 = load i32*, i32** %9
%110 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %109, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %15)
%111 = icmp eq i32 %110, 1
br i1 %111, label %112, label %122
112: ; preds = %108
%113 = load i32, i32* %3
%114 = load i32, i32* %15
%115 = icmp sgt i32 %113, %114
br i1 %115, label %116, label %121
116: ; preds = %112
%117 = load i32, i32* @stderr
%118 = load i32, i32* %3
%119 = load i8*, i8** %14
%120 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.10, i64 0, i64 0), i32 %118, i8* %119)
store i32 -1, i32* %5
br label %121
121: ; preds = %116, %112
br label %122
122: ; preds = %121, %108
%123 = load i32*, i32** %9
%124 = call i32 @fclose(i32* %123)
br label %125
125: ; preds = %122, %103
%126 = load i32, i32* %5
ret i32 %126
}

LLVM IR (-O2):
%struct.rlimit = type { i64 }
@RLIMIT_NOFILE = global i32 0
@stderr = global i32 0
@.str = [87 x i8] c"WARNING: Open files limit (`ulimit -n`) %ld is too low for the expected load (-c %d).\0A\00"
@.str.1 = [141 x i8] c"WARNING: System-wide open files limit %ld is too low for the expected load (-c %d).\0AConsider adjusting fs.file-max or kern.maxfiles sysctl.\0A\00"
@.str.2 = [39 x i8] c"/proc/sys/net/ipv4/ip_local_port_range\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [111 x i8] c"WARNING: Will not be able to open %d simultaneous connections since \22%s\22 specifies too narrow range [%d..%d].\0A\00"
@.str.6 = [32 x i8] c"/proc/sys/net/ipv4/tcp_tw_reuse\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [104 x i8] c"WARNING: Not reusing TIME_WAIT sockets, might not open %d simultaneous connections. Adjust \22%s\22 value.\0A\00"
@.str.9 = [41 x i8] c"/proc/sys/net/netfilter/nf_conntrack_max\00"
@.str.10 = [91 x i8] c"WARNING: IP filter might not allow opening %d simultaneous connections.Adjust \22%s\22 value.\0A\00"
define i32 @check_system_limits_sanity(i32 %0, i32 %1) {
%3 = alloca %struct.rlimit
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast %struct.rlimit* %3 to i8*
%9 = load i32, i32* @RLIMIT_NOFILE
%10 = call i32 @getrlimit(i32 %9, %struct.rlimit* %3)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%15 = load i64, i64* %14
%16 = add nsw i32 %0, 4
%17 = add nsw i32 %16, %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %15, %18
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = trunc i64 %15 to i32
%23 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %0)
br label %32
24: ; preds = %2
%25 = call i64 (...) @max_open_files()
%26 = icmp slt i64 %25, %18
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i64, i64* %14
%30 = trunc i64 %29 to i32
%31 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %0)
br label %32
32: ; preds = %24, %27, %20
%33 = phi i32 [ -1, %20 ], [ -1, %27 ], [ 0, %24 ]
%34 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %52, label %36
36: ; preds = %32
%37 = bitcast i32* %4 to i8*
%38 = bitcast i32* %5 to i8*
%39 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5)
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %49
41: ; preds = %36
%42 = load i32, i32* %5
%43 = load i32, i32* %4
%44 = sub nsw i32 %42, %43
%45 = icmp slt i32 %44, %0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.5, i64 0, i64 0), i32 %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %42)
br label %49
49: ; preds = %41, %46, %36
%50 = phi i32 [ -1, %46 ], [ %33, %41 ], [ %33, %36 ]
%51 = call i32 @fclose(i32* %34)
br label %52
52: ; preds = %49, %32
%53 = phi i32 [ %50, %49 ], [ %33, %32 ]
%54 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%55 = icmp eq i32* %54, null
br i1 %55, label %71, label %56
56: ; preds = %52
%57 = bitcast i32* %6 to i8*
%58 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %6)
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %68
60: ; preds = %56
%61 = load i32, i32* %6
%62 = icmp ne i32 %61, 1
%63 = icmp sgt i32 %0, 10
%64 = and i1 %63, %62
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.8, i64 0, i64 0), i32 %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %68
68: ; preds = %60, %65, %56
%69 = phi i32 [ -1, %65 ], [ %53, %60 ], [ %53, %56 ]
%70 = call i32 @fclose(i32* %54)
br label %71
71: ; preds = %68, %52
%72 = phi i32 [ %69, %68 ], [ %53, %52 ]
%73 = call i32* @fopen(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%74 = icmp eq i32* %73, null
br i1 %74, label %88, label %75
75: ; preds = %71
%76 = bitcast i32* %7 to i8*
%77 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%78 = icmp eq i32 %77, 1
%79 = load i32, i32* %7
%80 = icmp slt i32 %79, %0
%81 = select i1 %78, i1 %80, i1 false
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.10, i64 0, i64 0), i32 %0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
br label %85
85: ; preds = %82, %75
%86 = phi i32 [ -1, %82 ], [ %72, %75 ]
%87 = call i32 @fclose(i32* %73)
br label %88
88: ; preds = %85, %71
%89 = phi i32 [ %86, %85 ], [ %72, %71 ]
ret i32 %89
}