#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 timespec {
  long long tv_sec;
  long long tv_nsec;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ atoll(char const *);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
char *malloc(int);
int nanosleep(struct timespec *, int /*<<< orphan*/ *);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
int pollFileContent(int fd, const char *lim, long long interval, int type,
                    char **content) {
  long long seconds = interval / 10e9;
  long long nanoseconds = interval - seconds;
  struct timespec req;
  req.tv_sec = seconds;
  req.tv_nsec = nanoseconds;
  int content_max_size = 20;
  *content = malloc(sizeof(char) * content_max_size);
  ssize_t bytes_read;
  while (1) {
    if ((bytes_read = read(fd, *content, content_max_size - 1)) == -1) {
      do {
        if (1) {
          fprintf(stderr, "%s: %d: ",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/"
                  "heads/development/src/resource_limits.c",
                  169);
          fprintf(stderr, "read failed: errno: %d", errno);
          fprintf(stderr, "\n");
        }
      } while (0);
      return -1;
    }
    (*content)[bytes_read - 1] = '\0';
    if (type == 1) {
      if (atoll(*content) > atoll(lim)) {
        return 0;
      }
    } else {
      if (strcmp(*content, lim) > 0) {
        return 0;
      }
    }
    if (lseek(fd, 0, SEEK_SET) == -1) {
      do {
        if (1) {
          fprintf(stderr, "%s: %d: ",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/"
                  "heads/development/src/resource_limits.c",
                  185);
          fprintf(stderr, "lseek failed: errno: %d", errno);
          fprintf(stderr, "\n");
        }
      } while (0);
      return -1;
    }
    if (nanosleep(&req, NULL) == -1) {
      do {
        if (1) {
          fprintf(stderr, "%s: %d: ",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/"
                  "heads/development/src/resource_limits.c",
                  190);
          fprintf(stderr,
                  "nanosleep interrupted by a signal handler or encountered an "
                  "error: errno: %d",
                  errno);
          fprintf(stderr, "\n");
        }
      } while (0);
      return -1;
    }
  }
}


x86 assembly (clang, -O0):
<pollFileContent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x14,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
mov    -0x4c(%rbp),%edx
sub    $0x1,%edx
call   1050 <read@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
jne    126d <pollFileContent+0xfd>
jmp    1207 <pollFileContent+0x97>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
lea    0xdf3(%rip),%rdx
mov    $0xa9,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    0x2d9e(%rip),%rax
mov    (%rax),%edx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13fd <pollFileContent+0x28d>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    -0x50(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x1,-0x1c(%rbp)
jne    12c5 <pollFileContent+0x155>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1060 <atoll@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoll@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jle    12c0 <pollFileContent+0x150>
movl   $0x0,-0x4(%rbp)
jmp    13fd <pollFileContent+0x28d>
jmp    12f0 <pollFileContent+0x180>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jle    12eb <pollFileContent+0x17b>
movl   $0x0,-0x4(%rbp)
jmp    13fd <pollFileContent+0x28d>
jmp    12f0 <pollFileContent+0x180>
mov    -0x8(%rbp),%edi
mov    0x2cd6(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1377 <pollFileContent+0x207>
jmp    1311 <pollFileContent+0x1a1>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
lea    0xce7(%rip),%rsi
lea    0xce9(%rip),%rdx
mov    $0xb9,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
mov    0x2c94(%rip),%rax
mov    (%rax),%edx
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13fd <pollFileContent+0x28d>
lea    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <nanosleep@plt>
cmp    $0xffffffff,%eax
jne    13f8 <pollFileContent+0x288>
jmp    1392 <pollFileContent+0x222>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    0xc66(%rip),%rsi
lea    0xc68(%rip),%rdx
mov    $0xbe,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
mov    0x2c13(%rip),%rax
mov    (%rax),%edx
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13fd <pollFileContent+0x28d>
jmp    11e1 <pollFileContent+0x71>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pollFileContent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cvtsi2sd %rdx,%xmm0
divsd  0xe75(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %r8,%r12
mov    %ecx,%r13d
mov    %rsi,(%rsp)
mov    %edi,%r14d
sub    %rax,%rdx
mov    %rax,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    $0x14,%edi
call   1090 <malloc@plt>
mov    %rax,(%r12)
mov    %r14d,%edi
mov    %rax,%rsi
mov    $0x13,%edx
call   1050 <read@plt>
lea    0xede(%rip),%rbp
mov    $0xa9,%ecx
cmp    $0xffffffff,%eax
je     1290 <pollFileContent+0x120>
mov    0x2dec(%rip),%rbx
lea    0x8(%rsp),%rbp
nopl   0x0(%rax)
mov    (%r12),%rcx
cltq
movb   $0x0,-0x1(%rax,%rcx,1)
mov    (%r12),%rdi
cmp    $0x1,%r13d
jne    1220 <pollFileContent+0xb0>
call   1060 <atoll@plt>
mov    %rax,%r15
mov    (%rsp),%rdi
call   1060 <atoll@plt>
cmp    %rax,%r15
jle    122e <pollFileContent+0xbe>
jmp    1272 <pollFileContent+0x102>
nopl   (%rax)
mov    (%rsp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jg     1272 <pollFileContent+0x102>
mov    (%rbx),%edx
mov    %r14d,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
je     1276 <pollFileContent+0x106>
mov    %rbp,%rdi
xor    %esi,%esi
call   1030 <nanosleep@plt>
cmp    $0xffffffff,%eax
je     1284 <pollFileContent+0x114>
mov    (%r12),%rsi
mov    %r14d,%edi
mov    $0x13,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
jne    11f0 <pollFileContent+0x80>
lea    0xe42(%rip),%rbp
mov    $0xa9,%ecx
jmp    1290 <pollFileContent+0x120>
xor    %eax,%eax
jmp    12d8 <pollFileContent+0x168>
mov    $0xb9,%ecx
lea    0xe44(%rip),%rbp
jmp    1290 <pollFileContent+0x120>
mov    $0xbe,%ecx
lea    0xe4e(%rip),%rbp
mov    0x2d49(%rip),%rbx
mov    (%rbx),%edi
lea    0xd68(%rip),%rsi
lea    0xd6a(%rip),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@stderr = global i32 0
@.str = [9 x i8] c"%s: %d: \00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/heads/development/src/resource_limits.c\00"
@.str.2 = [23 x i8] c"read failed: errno: %d\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [24 x i8] c"lseek failed: errno: %d\00"
@.str.5 = [77 x i8] c"nanosleep interrupted by a signal handler or encountered an error: errno: %d\00"
define i32 @pollFileContent(i32 %0, i8* %1, i64 %2, i32 %3, i8** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i64
%13 = alloca i64
%14 = alloca %struct.timespec
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i8** %4, i8*** %11
%17 = load i64, i64* %9
%18 = sitofp i64 %17 to double
%19 = fdiv double %18, 1.000000e+10
%20 = fptosi double %19 to i64
store i64 %20, i64* %12
%21 = load i64, i64* %9
%22 = load i64, i64* %12
%23 = sub nsw i64 %21, %22
store i64 %23, i64* %13
%24 = load i64, i64* %12
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
store i64 %24, i64* %25
%26 = load i64, i64* %13
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
store i64 %26, i64* %27
store i32 20, i32* %15
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = mul i64 1, %29
%31 = trunc i64 %30 to i32
%32 = call i8* @malloc(i32 %31)
%33 = load i8**, i8*** %11
store i8* %32, i8** %33
br label %34
34: ; preds = %5, %106
%35 = load i32, i32* %7
%36 = load i8**, i8*** %11
%37 = load i8*, i8** %36
%38 = load i32, i32* %15
%39 = sub nsw i32 %38, 1
%40 = call i32 @read(i32 %35, i8* %37, i32 %39)
store i32 %40, i32* %16
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %52
42: ; preds = %34
br label %43
43: ; preds = %42
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 169)
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %43
store i32 -1, i32* %6
br label %107
52: ; preds = %34
%53 = load i8**, i8*** %11
%54 = load i8*, i8** %53
%55 = load i32, i32* %16
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %54, i64 %57
store i8 0, i8* %58
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %70
61: ; preds = %52
%62 = load i8**, i8*** %11
%63 = load i8*, i8** %62
%64 = call i64 @atoll(i8* %63)
%65 = load i8*, i8** %8
%66 = call i64 @atoll(i8* %65)
%67 = icmp sgt i64 %64, %66
br i1 %67, label %68, label %69
68: ; preds = %61
store i32 0, i32* %6
br label %107
69: ; preds = %61
br label %78
70: ; preds = %52
%71 = load i8**, i8*** %11
%72 = load i8*, i8** %71
%73 = load i8*, i8** %8
%74 = call i64 @strcmp(i8* %72, i8* %73)
%75 = icmp sgt i64 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %70
store i32 0, i32* %6
br label %107
77: ; preds = %70
br label %78
78: ; preds = %77, %69
%79 = load i32, i32* %7
%80 = load i32, i32* @SEEK_SET
%81 = call i32 @lseek(i32 %79, i32 0, i32 %80)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %93
83: ; preds = %78
br label %84
84: ; preds = %83
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 185)
%87 = load i32, i32* @stderr
%88 = load i32, i32* @errno
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %88)
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %92
92: ; preds = %84
store i32 -1, i32* %6
br label %107
93: ; preds = %78
%94 = call i32 @nanosleep(%struct.timespec* %14, i32* null)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %106
96: ; preds = %93
br label %97
97: ; preds = %96
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 190)
%100 = load i32, i32* @stderr
%101 = load i32, i32* @errno
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), i32 %101)
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %105
105: ; preds = %97
store i32 -1, i32* %6
br label %107
106: ; preds = %93
br label %34
107: ; preds = %105, %92, %76, %68, %51
%108 = load i32, i32* %6
ret i32 %108
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@stderr = global i32 0
@.str = [9 x i8] c"%s: %d: \00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/heads/development/src/resource_limits.c\00"
@.str.2 = [23 x i8] c"read failed: errno: %d\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [24 x i8] c"lseek failed: errno: %d\00"
@.str.5 = [77 x i8] c"nanosleep interrupted by a signal handler or encountered an error: errno: %d\00"
define i32 @pollFileContent(i32 %0, i8* %1, i64 %2, i32 %3, i8** nocapture %4) {
%6 = alloca %struct.timespec
%7 = sitofp i64 %2 to double
%8 = fdiv double %7, 1.000000e+10
%9 = fptosi double %8 to i64
%10 = sub nsw i64 %2, %9
%11 = bitcast %struct.timespec* %6 to i8*
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
store i64 %9, i64* %12
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
store i64 %10, i64* %13
%14 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
store i8* %14, i8** %4
%15 = icmp eq i32 %3, 1
%16 = call i32 @read(i32 %0, i8* %14, i32 19)
%17 = icmp eq i32 %16, -1
br i1 %17, label %43, label %18
18: ; preds = %5, %39
%19 = phi i32 [ %41, %39 ], [ %16, %5 ]
%20 = load i8*, i8** %4
%21 = add nsw i32 %19, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %4
br i1 %15, label %25, label %29
25: ; preds = %18
%26 = call i64 @atoll(i8* %24)
%27 = call i64 @atoll(i8* %1)
%28 = icmp sgt i64 %26, %27
br i1 %28, label %53, label %32
29: ; preds = %18
%30 = call i64 @strcmp(i8* %24, i8* %1)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %53, label %32
32: ; preds = %29, %25
%33 = load i32, i32* @SEEK_SET
%34 = call i32 @lseek(i32 %0, i32 0, i32 %33)
%35 = icmp eq i32 %34, -1
br i1 %35, label %43, label %36
36: ; preds = %32
%37 = call i32 @nanosleep(%struct.timespec* %6, i32* null)
%38 = icmp eq i32 %37, -1
br i1 %38, label %43, label %39
39: ; preds = %36
%40 = load i8*, i8** %4
%41 = call i32 @read(i32 %0, i8* %40, i32 19)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %18
43: ; preds = %39, %32, %36, %5
%44 = phi i32 [ 169, %5 ], [ 169, %39 ], [ 185, %32 ], [ 190, %36 ]
%45 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %39 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), %32 ], [ getelementptr inbounds ([77 x i8], [77 x i8]* @.str.5, i64 0, i64 0), %36 ]
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* %45, i32 %49)
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %29, %25, %43
%54 = phi i32 [ -1, %43 ], [ 0, %25 ], [ 0, %29 ]
ret i32 %54
}