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

/* Variables and functions */
int RLIM_INFINITY;
int RLIM_NLIMITS;
int /*<<< orphan*/ errno;
scalar_t__ getrlimit(int, struct rlimit *);
scalar_t__ setrlimit(int, struct rlimit *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int main(int argc, char **argv) {
  int r, changed = 0;
  struct rlimit rlims[RLIM_NLIMITS], trlim;
  test_init(argc, argv);
  for (r = 0; r < RLIM_NLIMITS; r++) {
    if (getrlimit(r, &rlims[r])) {
      test_msg("ERR: %s:%d: "
               "Can't get rlimit"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/static/rlimits00.c",
               20, errno, strerror(errno));
      goto out;
    }
    if (rlims[r].rlim_cur > 1 && rlims[r].rlim_cur != RLIM_INFINITY) {
      rlims[r].rlim_cur--;
      if (setrlimit(r, &rlims[r])) {
        test_msg("ERR: %s:%d: "
                 "Can't set rlimit"
                 " (errno = %d (%s))\n",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/"
                 "master/test/zdtm/live/static/rlimits00.c",
                 29, errno, strerror(errno));
        goto out;
      }
      changed = 1;
    }
  }
  if (!changed) {
    test_msg("ERR: %s:%d: "
             "Can't change any rlimir"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/"
             "live/static/rlimits00.c",
             38, errno, strerror(errno));
    goto out;
  }
  test_daemon();
  test_waitsig();
  for (r = 0; r < RLIM_NLIMITS; r++) {
    if (getrlimit(r, &trlim)) {
      test_msg("FAIL: %s:%d: "
               "Can't get rlimit after rst"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/static/rlimits00.c",
               47, errno, strerror(errno));
      goto out;
    }
    if (rlims[r].rlim_cur != trlim.rlim_cur) {
      test_msg("FAIL: %s:%d: "
               "Cur changed"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/static/rlimits00.c",
               52, errno, strerror(errno));
      goto out;
    }
    if (rlims[r].rlim_max != trlim.rlim_max) {
      test_msg("FAIL: %s:%d: "
               "Max changed"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/static/rlimits00.c",
               57, errno, strerror(errno));
      goto out;
    }
  }
  test_msg("PASS\n");
out:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
shl    $0x4,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%eax
jge    1301 <main+0x191>
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edi
movslq -0x14(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rsi
call   1080 <getrlimit@plt>
cmp    $0x0,%rax
je     123a <main+0xca>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%ecx
mov    %eax,%r8d
lea    0xdde(%rip),%rdi
lea    0xe07(%rip),%rsi
mov    $0x14,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
cmpl   $0x1,(%rax)
jle    12ee <main+0x17e>
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
mov    0x2d66(%rip),%rcx
cmp    (%rcx),%eax
je     12ee <main+0x17e>
mov    -0x40(%rbp),%rsi
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
mov    %rsi,%rax
add    %rcx,%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x14(%rbp),%edi
movslq -0x14(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rsi
call   1070 <setrlimit@plt>
cmp    $0x0,%rax
je     12e7 <main+0x177>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x48(%rbp),%ecx
mov    %eax,%r8d
lea    0xdfa(%rip),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x1d,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
movl   $0x1,-0x18(%rbp)
jmp    12f3 <main+0x183>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c8 <main+0x58>
cmpl   $0x0,-0x18(%rbp)
jne    134a <main+0x1da>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x4c(%rbp),%ecx
mov    %eax,%r8d
lea    0xdc7(%rip),%rdi
lea    0xcf7(%rip),%rsi
mov    $0x26,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
mov    $0x0,%al
call   1040 <test_daemon@plt>
mov    $0x0,%al
call   1060 <test_waitsig@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2c6f(%rip),%rcx
cmp    (%rcx),%eax
jge    148e <main+0x31e>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1080 <getrlimit@plt>
cmp    $0x0,%rax
je     13c6 <main+0x256>
mov    0x2c52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x50(%rbp),%ecx
mov    %eax,%r8d
lea    0xd82(%rip),%rdi
lea    0xc7b(%rip),%rsi
mov    $0x2f,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0x38(%rbp),%eax
je     141f <main+0x2af>
mov    0x2bf9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x54(%rbp),%ecx
mov    %eax,%r8d
lea    0xd64(%rip),%rdi
lea    0xc22(%rip),%rsi
mov    $0x34,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
mov    -0x40(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
cmp    -0x30(%rbp),%rax
je     147b <main+0x30b>
mov    0x2b9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x58(%rbp),%ecx
mov    %eax,%r8d
lea    0xd34(%rip),%rdi
lea    0xbc6(%rip),%rsi
mov    $0x39,%edx
mov    $0x0,%al
call   1050 <test_msg@plt>
jmp    149c <main+0x32c>
jmp    1480 <main+0x310>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    135f <main+0x1ef>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1050 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e50(%rip),%rbx
mov    (%rbx),%eax
mov    %rsp,%r12
shl    $0x4,%rax
sub    %rax,%r12
mov    %r12,%rsp
call   1030 <test_init@plt>
cmpl   $0x0,(%rbx)
jle    12e6 <main+0x176>
xor    %r14d,%r14d
mov    0x2e21(%rip),%r13
mov    %r12,%rbx
xor    %r15d,%r15d
jmp    11db <main+0x6b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    0x2e0d(%rip),%rax
movslq (%rax),%rax
add    $0x10,%rbx
cmp    %rax,%r14
jge    1263 <main+0xf3>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1080 <getrlimit@plt>
test   %rax,%rax
jne    123b <main+0xcb>
mov    (%rbx),%eax
cmp    $0x2,%eax
jl     11c0 <main+0x50>
cmp    0x0(%r13),%eax
je     11c0 <main+0x50>
add    $0xffffffff,%eax
mov    %eax,(%rbx)
mov    %r14d,%edi
mov    %rbx,%rsi
call   1070 <setrlimit@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     11c0 <main+0x50>
mov    0x2dc6(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe9f(%rip),%rdi
lea    0xdff(%rip),%rsi
mov    $0x1d,%edx
jmp    1309 <main+0x199>
mov    0x2d9e(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xdae(%rip),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x14,%edx
jmp    1309 <main+0x199>
test   %r15d,%r15d
je     12e6 <main+0x176>
xor    %eax,%eax
call   1040 <test_daemon@plt>
xor    %eax,%eax
call   1060 <test_waitsig@plt>
mov    0x2d5b(%rip),%rax
cmpl   $0x0,(%rax)
jle    12d6 <main+0x166>
add    $0x8,%r12
xor    %ebx,%ebx
lea    -0x38(%rbp),%r14
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
call   1080 <getrlimit@plt>
test   %rax,%rax
jne    1326 <main+0x1b6>
mov    -0x8(%r12),%eax
cmp    -0x38(%rbp),%eax
jne    134b <main+0x1db>
mov    (%r12),%rax
cmp    -0x30(%rbp),%rax
jne    1370 <main+0x200>
add    $0x1,%rbx
mov    0x2d0e(%rip),%rax
movslq (%rax),%rax
add    $0x10,%r12
cmp    %rax,%rbx
jl     1290 <main+0x120>
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1050 <test_msg@plt>
jmp    1315 <main+0x1a5>
mov    0x2cf3(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xdfc(%rip),%rdi
lea    0xd2c(%rip),%rsi
mov    $0x26,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <test_msg@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cb3(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xdf3(%rip),%rdi
lea    0xcec(%rip),%rsi
mov    $0x2f,%edx
jmp    1309 <main+0x199>
mov    0x2c8e(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe09(%rip),%rdi
lea    0xcc7(%rip),%rsi
mov    $0x34,%edx
jmp    1309 <main+0x199>
mov    0x2c69(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe10(%rip),%rdi
lea    0xca2(%rip),%rsi
mov    $0x39,%edx
jmp    1309 <main+0x199>

LLVM IR (-O0):
%struct.rlimit = type { i32, i64 }
@RLIM_NLIMITS = global i32 0
@.str = [48 x i8] c"ERR: %s:%d: Can't get rlimit (errno = %d (%s))\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/live/static/rlimits00.c\00"
@errno = global i32 0
@RLIM_INFINITY = global i32 0
@.str.2 = [48 x i8] c"ERR: %s:%d: Can't set rlimit (errno = %d (%s))\0A\00"
@.str.3 = [55 x i8] c"ERR: %s:%d: Can't change any rlimir (errno = %d (%s))\0A\00"
@.str.4 = [59 x i8] c"FAIL: %s:%d: Can't get rlimit after rst (errno = %d (%s))\0A\00"
@.str.5 = [44 x i8] c"FAIL: %s:%d: Cur changed (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: Max changed (errno = %d (%s))\0A\00"
@.str.7 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.rlimit
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%11 = load i32, i32* @RLIM_NLIMITS
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca %struct.rlimit, i64 %12
store i64 %12, i64* %9
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @test_init(i32 %15, i8** %16)
store i32 0, i32* %6
br label %18
18: ; preds = %69, %2
%19 = load i32, i32* %6
%20 = load i32, i32* @RLIM_NLIMITS
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %72
22: ; preds = %18
%23 = load i32, i32* %6
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %25
%27 = call i64 @getrlimit(i32 %23, %struct.rlimit* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i32, i32* @errno
%31 = load i32, i32* @errno
%32 = call i32 @strerror(i32 %31)
%33 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %30, i32 %32)
br label %130
34: ; preds = %22
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %36
%38 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %37, i32 0, i32 0
%39 = load i32, i32* %38
%40 = icmp sgt i32 %39, 1
br i1 %40, label %41, label %68
41: ; preds = %34
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %43
%45 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = load i32, i32* @RLIM_INFINITY
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %68
49: ; preds = %41
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %51
%53 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = add nsw i32 %54, -1
store i32 %55, i32* %53
%56 = load i32, i32* %6
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %58
%60 = call i64 @setrlimit(i32 %56, %struct.rlimit* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %49
%63 = load i32, i32* @errno
%64 = load i32, i32* @errno
%65 = call i32 @strerror(i32 %64)
%66 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 29, i32 %63, i32 %65)
br label %130
67: ; preds = %49
store i32 1, i32* %7
br label %68
68: ; preds = %67, %41, %34
br label %69
69: ; preds = %68
%70 = load i32, i32* %6
%71 = add nsw i32 %70, 1
store i32 %71, i32* %6
br label %18
72: ; preds = %18
%73 = load i32, i32* %7
%74 = icmp ne i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %72
%76 = load i32, i32* @errno
%77 = load i32, i32* @errno
%78 = call i32 @strerror(i32 %77)
%79 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 38, i32 %76, i32 %78)
br label %130
80: ; preds = %72
%81 = call i32 (...) @test_daemon()
%82 = call i32 (...) @test_waitsig()
store i32 0, i32* %6
br label %83
83: ; preds = %125, %80
%84 = load i32, i32* %6
%85 = load i32, i32* @RLIM_NLIMITS
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %128
87: ; preds = %83
%88 = load i32, i32* %6
%89 = call i64 @getrlimit(i32 %88, %struct.rlimit* %10)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %87
%92 = load i32, i32* @errno
%93 = load i32, i32* @errno
%94 = call i32 @strerror(i32 %93)
%95 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 47, i32 %92, i32 %94)
br label %130
96: ; preds = %87
%97 = load i32, i32* %6
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %98
%100 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %99, i32 0, i32 0
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %10, i32 0, i32 0
%103 = load i32, i32* %102
%104 = icmp ne i32 %101, %103
br i1 %104, label %105, label %110
105: ; preds = %96
%106 = load i32, i32* @errno
%107 = load i32, i32* @errno
%108 = call i32 @strerror(i32 %107)
%109 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 %106, i32 %108)
br label %130
110: ; preds = %96
%111 = load i32, i32* %6
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 %112
%114 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %113, i32 0, i32 1
%115 = load i64, i64* %114
%116 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %10, i32 0, i32 1
%117 = load i64, i64* %116
%118 = icmp ne i64 %115, %117
br i1 %118, label %119, label %124
119: ; preds = %110
%120 = load i32, i32* @errno
%121 = load i32, i32* @errno
%122 = call i32 @strerror(i32 %121)
%123 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 57, i32 %120, i32 %122)
br label %130
124: ; preds = %110
br label %125
125: ; preds = %124
%126 = load i32, i32* %6
%127 = add nsw i32 %126, 1
store i32 %127, i32* %6
br label %83
128: ; preds = %83
%129 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %130
130: ; preds = %128, %119, %105, %91, %75, %62, %29
store i32 0, i32* %3
%131 = load i8*, i8** %8
%132 = load i32, i32* %3
ret i32 %132
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i64 }
@RLIM_NLIMITS = global i32 0
@.str = [48 x i8] c"ERR: %s:%d: Can't get rlimit (errno = %d (%s))\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/live/static/rlimits00.c\00"
@errno = global i32 0
@RLIM_INFINITY = global i32 0
@.str.2 = [48 x i8] c"ERR: %s:%d: Can't set rlimit (errno = %d (%s))\0A\00"
@.str.3 = [55 x i8] c"ERR: %s:%d: Can't change any rlimir (errno = %d (%s))\0A\00"
@.str.4 = [59 x i8] c"FAIL: %s:%d: Can't get rlimit after rst (errno = %d (%s))\0A\00"
@.str.5 = [44 x i8] c"FAIL: %s:%d: Cur changed (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: Max changed (errno = %d (%s))\0A\00"
@.str.7 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.rlimit
%4 = load i32, i32* @RLIM_NLIMITS
%5 = zext i32 %4 to i64
%6 = alloca %struct.rlimit, i64 %5
%7 = bitcast %struct.rlimit* %3 to i8*
%8 = tail call i32 @test_init(i32 %0, i8** %1)
%9 = load i32, i32* @RLIM_NLIMITS
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %45
11: ; preds = %2, %37
%12 = phi i64 [ %39, %37 ], [ 0, %2 ]
%13 = phi i32 [ %38, %37 ], [ 0, %2 ]
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i64 %12
%15 = trunc i64 %12 to i32
%16 = call i64 @getrlimit(i32 %15, %struct.rlimit* %14)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %11
%19 = load i32, i32* @errno
%20 = call i32 @strerror(i32 %19)
%21 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %19, i32 %20)
br label %91
22: ; preds = %11
%23 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %14, i64 0, i32 0
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, 2
%26 = load i32, i32* @RLIM_INFINITY
%27 = icmp eq i32 %24, %26
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %37, label %29
29: ; preds = %22
%30 = add nsw i32 %24, -1
store i32 %30, i32* %23
%31 = call i64 @setrlimit(i32 %15, %struct.rlimit* %14)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 29, i32 %34, i32 %35)
br label %91
37: ; preds = %29, %22
%38 = phi i32 [ %13, %22 ], [ 1, %29 ]
%39 = add nuw nsw i64 %12, 1
%40 = load i32, i32* @RLIM_NLIMITS
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %11, label %43
43: ; preds = %37
%44 = icmp eq i32 %38, 0
br i1 %44, label %45, label %49
45: ; preds = %2, %43
%46 = load i32, i32* @errno
%47 = call i32 @strerror(i32 %46)
%48 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 38, i32 %46, i32 %47)
br label %91
49: ; preds = %43
%50 = call i32 (...) @test_daemon()
%51 = call i32 (...) @test_waitsig()
%52 = load i32, i32* @RLIM_NLIMITS
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %89
54: ; preds = %49
%55 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%56 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
br label %61
57: ; preds = %79
%58 = load i32, i32* @RLIM_NLIMITS
%59 = sext i32 %58 to i64
%60 = icmp slt i64 %84, %59
br i1 %60, label %61, label %89
61: ; preds = %54, %57
%62 = phi i64 [ 0, %54 ], [ %84, %57 ]
%63 = trunc i64 %62 to i32
%64 = call i64 @getrlimit(i32 %63, %struct.rlimit* %3)
%65 = icmp eq i64 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %61
%67 = load i32, i32* @errno
%68 = call i32 @strerror(i32 %67)
%69 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 47, i32 %67, i32 %68)
br label %91
70: ; preds = %61
%71 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i64 %62, i32 0
%72 = load i32, i32* %71
%73 = load i32, i32* %55
%74 = icmp eq i32 %72, %73
br i1 %74, label %79, label %75
75: ; preds = %70
%76 = load i32, i32* @errno
%77 = call i32 @strerror(i32 %76)
%78 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 %76, i32 %77)
br label %91
79: ; preds = %70
%80 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i64 %62, i32 1
%81 = load i64, i64* %80
%82 = load i64, i64* %56
%83 = icmp eq i64 %81, %82
%84 = add nuw nsw i64 %62, 1
br i1 %83, label %57, label %85
85: ; preds = %79
%86 = load i32, i32* @errno
%87 = call i32 @strerror(i32 %86)
%88 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 57, i32 %86, i32 %87)
br label %91
89: ; preds = %57, %49
%90 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %91
91: ; preds = %89, %85, %75, %66, %45, %33, %18
ret i32 0
}