#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 {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};
struct sched_param {
  int sched_priority;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int MCL_CURRENT;
int MCL_FUTURE;
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ TIMER_ABSTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ clock_nanosleep(int /*<<< orphan*/, int /*<<< orphan*/,
                                   struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int mlockall(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                       struct sched_param *);
int /*<<< orphan*/ stack_prefault();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  struct timespec t;
  struct sched_param param;
  int interval = 2000000000;
  param.sched_priority = (49);
  if (sched_setscheduler(0, SCHED_FIFO, &param) == -1) {
    perror("sched_setscheduler failed");
    exit(-1);
  }
  if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
    perror("mlockall failed");
    exit(-2);
  }
  stack_prefault();
  FILE *fp1 = fopen("/proc/modules", "r");
  if (!fp1) {
    perror("Opening original module");
    exit(1);
  }
  char *line = NULL;
  char a[100][60];
  int i = 0;
  ssize_t read;
  size_t len = 0;
  while ((read = getline(&line, &len, fp1)) != -1) {
    printf("Retrieved line of length %zu :\n", read);
    printf("%s", line);
    strcpy(a[i], strtok(line, " "));
    printf("%s\n", a[i]);
    printf("i=%d", i);
    i++;
  }
  printf("i=%d", i);
  fclose(fp1);
  clock_gettime(CLOCK_MONOTONIC, &t);
  t.tv_sec++;
  while (1) {
    clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t, NULL);
    printf("loop starts");
    FILE *current_module = fopen("/proc/modules", "r");
    if (!current_module) {
      perror("Opening current");
      exit(1);
    }
    int j = 0;
    char *line2 = NULL;
    size_t len2 = 0;
    while (j < i) {
      printf("j=%d \n", j);
      printf("original %s\n", a[j]);
      if ((read = getline(&line2, &len2, current_module)) != -1) {
        printf("current %s\n", strtok(line2, " "));
        if (strcmp(a[j], strtok(line2, " ")) != 0) {
          system("reboot");
        }
      }
      j++;
    }
    if (line2)
      free(line2);
    fclose(current_module);
    t.tv_nsec += interval;
    while (t.tv_nsec >= (1000000000)) {
      t.tv_nsec -= (1000000000);
      t.tv_sec++;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x17f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x77359400,-0x24(%rbp)
movl   $0x31,-0x20(%rbp)
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x20(%rbp),%rdx
call   1090 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
jne    125a <main+0x5a>
lea    0xdb5(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    0x2d86(%rip),%rax
or     (%rax),%edi
call   10c0 <mlockall@plt>
cmp    $0xffffffff,%eax
jne    1290 <main+0x90>
lea    0xd99(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xfffffffe,%edi
call   1110 <exit@plt>
mov    $0x0,%al
call   10b0 <stack_prefault@plt>
lea    0xd8c(%rip),%rdi
lea    0xd93(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12cf <main+0xcf>
lea    0xd7a(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x17b4(%rbp)
movq   $0x0,-0x17c0(%rbp)
mov    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x17c0(%rbp),%rsi
call   1100 <getline@plt>
mov    %eax,-0x17b8(%rbp)
cmp    $0xffffffff,%eax
je     13bb <main+0x1bb>
mov    -0x17b8(%rbp),%esi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movslq -0x17b4(%rbp),%rcx
lea    -0x17b0(%rbp),%rax
imul   $0x3c,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x17e8(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   10f0 <strtok@plt>
mov    -0x17e8(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
movslq -0x17b4(%rbp),%rax
lea    -0x17b0(%rbp),%rsi
imul   $0x3c,%rax,%rax
add    %rax,%rsi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x17b4(%rbp),%esi
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x17b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17b4(%rbp)
jmp    12ec <main+0xec>
mov    -0x17b4(%rbp),%esi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
mov    0x2bdd(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1120 <clock_nanosleep@plt>
lea    0xc63(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc03(%rip),%rdi
lea    0xc0a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x17c8(%rbp)
cmpq   $0x0,-0x17c8(%rbp)
jne    145e <main+0x25e>
lea    0xc39(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x0,-0x17cc(%rbp)
movq   $0x0,-0x17d8(%rbp)
movq   $0x0,-0x17e0(%rbp)
mov    -0x17cc(%rbp),%eax
cmp    -0x17b4(%rbp),%eax
jge    1581 <main+0x381>
mov    -0x17cc(%rbp),%esi
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movslq -0x17cc(%rbp),%rax
lea    -0x17b0(%rbp),%rsi
imul   $0x3c,%rax,%rax
add    %rax,%rsi
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x17c8(%rbp),%rdx
lea    -0x17d8(%rbp),%rdi
lea    -0x17e0(%rbp),%rsi
call   1100 <getline@plt>
mov    %eax,-0x17b8(%rbp)
cmp    $0xffffffff,%eax
je     156d <main+0x36d>
mov    -0x17d8(%rbp),%rdi
lea    0xb77(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,%rsi
lea    0xb9f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movslq -0x17cc(%rbp),%rcx
lea    -0x17b0(%rbp),%rax
imul   $0x3c,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x17f0(%rbp)
mov    -0x17d8(%rbp),%rdi
lea    0xb37(%rip),%rsi
call   10f0 <strtok@plt>
mov    -0x17f0(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1568 <main+0x368>
lea    0xb55(%rip),%rdi
call   1070 <system@plt>
jmp    156d <main+0x36d>
mov    -0x17cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17cc(%rbp)
jmp    147e <main+0x27e>
cmpq   $0x0,-0x17d8(%rbp)
je     159b <main+0x39b>
mov    -0x17d8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x17c8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x24(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3b9aca00,-0x18(%rbp)
jl     15d6 <main+0x3d6>
mov    -0x18(%rbp),%eax
sub    $0x3b9aca00,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    15b0 <main+0x3b0>
jmp    13f3 <main+0x1f3>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x17a8,%rsp
movl   $0x31,0x18(%rsp)
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
xor    %edi,%edi
call   10a0 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
jne    1259 <main+0x49>
lea    0xdb6(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1120 <exit@plt>
mov    0x2d60(%rip),%rax
mov    0x2d89(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
call   10d0 <mlockall@plt>
cmp    $0xffffffff,%eax
jne    128b <main+0x7b>
lea    0xd9e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xfffffffe,%edi
call   1120 <exit@plt>
xor    %eax,%eax
call   10c0 <stack_prefault@plt>
lea    0xd91(%rip),%rdi
lea    0xd98(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    12b6 <main+0xa6>
lea    0xd89(%rip),%rdi
jmp    13f5 <main+0x1e5>
mov    %rax,%rbx
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    %rax,%rdx
call   1110 <getline@plt>
cmp    $0xffffffff,%eax
mov    $0x0,%r12d
je     137f <main+0x16f>
lea    0x30(%rsp),%rbp
lea    0xd7f(%rip),%r13
lea    0x10(%rsp),%r14
lea    0x20(%rsp),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd3b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xd46(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%rsp),%rdi
lea    0xd36(%rip),%rsi
call   1100 <strtok@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1110 <getline@plt>
add    $0x1,%r12d
add    $0x3c,%rbp
cmp    $0xffffffff,%eax
jne    1310 <main+0x100>
lea    0xcf1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x2c39(%rip),%rbp
mov    0x0(%rbp),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <clock_gettime@plt>
addl   $0x1,0x4(%rsp)
mov    0x0(%rbp),%edi
mov    0x2c24(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1130 <clock_nanosleep@plt>
lea    0xcad(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xc4d(%rip),%rdi
lea    0xc54(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    1404 <main+0x1f4>
lea    0xc93(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %rax,%rbx
mov    %r12d,%ebp
mov    %r12d,%r15d
lea    0x28(%rsp),%r12
lea    0xc5c(%rip),%r13
mov    %ebp,0x1c(%rsp)
jmp    1465 <main+0x255>
nop
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
mov    0x2bb0(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %ecx,%ecx
call   1130 <clock_nanosleep@plt>
lea    0xc39(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xbd9(%rip),%rdi
lea    0xbe0(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     13ee <main+0x1de>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x28(%rsp)
test   %ebp,%ebp
je     1543 <main+0x333>
lea    0x30(%rsp),%rbp
xor    %r14d,%r14d
jmp    14a1 <main+0x291>
nopl   0x0(%rax)
add    $0x1,%r14
add    $0x3c,%rbp
cmp    %r14,%r15
je     1530 <main+0x320>
lea    0xbf0(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xbe6(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1110 <getline@plt>
cmp    $0xffffffff,%eax
je     1490 <main+0x280>
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
call   1100 <strtok@plt>
lea    0xbc0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
call   1100 <strtok@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1490 <main+0x280>
lea    0xb9a(%rip),%rdi
call   1080 <system@plt>
jmp    1490 <main+0x280>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
mov    0x1c(%rsp),%ebp
je     1543 <main+0x333>
call   1030 <free@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    (%rsp),%eax
lea    0x77359400(%rax),%ecx
mov    %ecx,(%rsp)
cmp    $0xc4653600,%eax
jl     1420 <main+0x210>
mov    0x4(%rsp),%edx
cmp    $0x773593ff,%ecx
mov    $0x773593ff,%esi
cmovge %esi,%ecx
neg    %ecx
add    %eax,%ecx
add    $0xb2d05dff,%ecx
shr    $0x9,%ecx
imul   $0x44b83,%rcx,%rcx
shr    $0x27,%rcx
imul   $0xc4653600,%ecx,%esi
add    %esi,%eax
add    $0x3b9aca00,%eax
add    %edx,%ecx
add    $0x1,%ecx
mov    %eax,(%rsp)
mov    %ecx,0x4(%rsp)
jmp    1420 <main+0x210>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [26 x i8] c"sched_setscheduler failed\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.1 = [16 x i8] c"mlockall failed\00"
@.str.2 = [14 x i8] c"/proc/modules\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [24 x i8] c"Opening original module\00"
@.str.5 = [32 x i8] c"Retrieved line of length %zu :\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [4 x i8] c"%s\0A\00"
@.str.9 = [5 x i8] c"i=%d\00"
@CLOCK_MONOTONIC = global i32 0
@TIMER_ABSTIME = global i32 0
@.str.10 = [12 x i8] c"loop starts\00"
@.str.11 = [16 x i8] c"Opening current\00"
@.str.12 = [7 x i8] c"j=%d \0A\00"
@.str.13 = [13 x i8] c"original %s\0A\00"
@.str.14 = [12 x i8] c"current %s\0A\00"
@.str.15 = [7 x i8] c"reboot\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.sched_param
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca [100 x [60 x i8]]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2000000000, i32* %8
%19 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %7, i32 0, i32 0
store i32 49, i32* %19
%20 = load i32, i32* @SCHED_FIFO
%21 = call i32 @sched_setscheduler(i32 0, i32 %20, %struct.sched_param* %7)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %2
%27 = load i32, i32* @MCL_CURRENT
%28 = load i32, i32* @MCL_FUTURE
%29 = or i32 %27, %28
%30 = call i32 @mlockall(i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @exit(i32 -2)
unreachable
35: ; preds = %26
%36 = call i32 (...) @stack_prefault()
%37 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %37, i32** %9
%38 = load i32*, i32** %9
%39 = icmp ne i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %35
store i8* null, i8** %10
store i32 0, i32* %12
store i64 0, i64* %14
br label %44
44: ; preds = %48, %43
%45 = load i32*, i32** %9
%46 = call i32 @getline(i8** %10, i64* %14, i32* %45)
store i32 %46, i32* %13
%47 = icmp ne i32 %46, -1
br i1 %47, label %48, label %69
48: ; preds = %44
%49 = load i32, i32* %13
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i8*, i8** %10
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %51)
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %11, i64 0, i64 %54
%56 = getelementptr inbounds [60 x i8], [60 x i8]* %55, i64 0, i64 0
%57 = load i8*, i8** %10
%58 = call i8* @strtok(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%59 = call i32 @strcpy(i8* %56, i8* %58)
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %11, i64 0, i64 %61
%63 = getelementptr inbounds [60 x i8], [60 x i8]* %62, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %63)
%65 = load i32, i32* %12
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %44
69: ; preds = %44
%70 = load i32, i32* %12
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %70)
%72 = load i32*, i32** %9
%73 = call i32 @fclose(i32* %72)
%74 = load i32, i32* @CLOCK_MONOTONIC
%75 = call i32 @clock_gettime(i32 %74, %struct.timespec* %6)
%76 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 1
store i32 %78, i32* %76
br label %79
79: ; preds = %69, %148
%80 = load i32, i32* @CLOCK_MONOTONIC
%81 = load i32, i32* @TIMER_ABSTIME
%82 = call i32 @clock_nanosleep(i32 %80, i32 %81, %struct.timespec* %6, i32* null)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%84 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %84, i32** %15
%85 = load i32*, i32** %15
%86 = icmp ne i32* %85, null
br i1 %86, label %90, label %87
87: ; preds = %79
%88 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %79
store i32 0, i32* %16
store i8* null, i8** %17
store i64 0, i64* %18
br label %91
91: ; preds = %121, %90
%92 = load i32, i32* %16
%93 = load i32, i32* %12
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %124
95: ; preds = %91
%96 = load i32, i32* %16
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %96)
%98 = load i32, i32* %16
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %11, i64 0, i64 %99
%101 = getelementptr inbounds [60 x i8], [60 x i8]* %100, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %101)
%103 = load i32*, i32** %15
%104 = call i32 @getline(i8** %17, i64* %18, i32* %103)
store i32 %104, i32* %13
%105 = icmp ne i32 %104, -1
br i1 %105, label %106, label %121
106: ; preds = %95
%107 = load i8*, i8** %17
%108 = call i8* @strtok(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %108)
%110 = load i32, i32* %16
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %11, i64 0, i64 %111
%113 = getelementptr inbounds [60 x i8], [60 x i8]* %112, i64 0, i64 0
%114 = load i8*, i8** %17
%115 = call i8* @strtok(i8* %114, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%116 = call i64 @strcmp(i8* %113, i8* %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %106
%119 = call i32 @system(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
br label %120
120: ; preds = %118, %106
br label %121
121: ; preds = %120, %95
%122 = load i32, i32* %16
%123 = add nsw i32 %122, 1
store i32 %123, i32* %16
br label %91
124: ; preds = %91
%125 = load i8*, i8** %17
%126 = icmp ne i8* %125, null
br i1 %126, label %127, label %130
127: ; preds = %124
%128 = load i8*, i8** %17
%129 = call i32 @free(i8* %128)
br label %130
130: ; preds = %127, %124
%131 = load i32*, i32** %15
%132 = call i32 @fclose(i32* %131)
%133 = load i32, i32* %8
%134 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%135 = load i32, i32* %134
%136 = add nsw i32 %135, %133
store i32 %136, i32* %134
br label %137
137: ; preds = %141, %130
%138 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%139 = load i32, i32* %138
%140 = icmp sge i32 %139, 1000000000
br i1 %140, label %141, label %148
141: ; preds = %137
%142 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%143 = load i32, i32* %142
%144 = sub nsw i32 %143, 1000000000
store i32 %144, i32* %142
%145 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%146 = load i32, i32* %145
%147 = add nsw i32 %146, 1
store i32 %147, i32* %145
br label %137
148: ; preds = %137
br label %79
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [26 x i8] c"sched_setscheduler failed\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.1 = [16 x i8] c"mlockall failed\00"
@.str.2 = [14 x i8] c"/proc/modules\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [24 x i8] c"Opening original module\00"
@.str.5 = [32 x i8] c"Retrieved line of length %zu :\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c" \00"
@.str.9 = [5 x i8] c"i=%d\00"
@CLOCK_MONOTONIC = global i32 0
@TIMER_ABSTIME = global i32 0
@.str.10 = [12 x i8] c"loop starts\00"
@.str.11 = [16 x i8] c"Opening current\00"
@.str.12 = [7 x i8] c"j=%d \0A\00"
@.str.13 = [13 x i8] c"original %s\0A\00"
@.str.14 = [12 x i8] c"current %s\0A\00"
@.str.15 = [7 x i8] c"reboot\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.sched_param
%5 = alloca i8*
%6 = alloca [100 x [60 x i8]]
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = bitcast %struct.timespec* %3 to i8*
%11 = bitcast %struct.sched_param* %4 to i8*
%12 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %4, i64 0, i32 0
store i32 49, i32* %12
%13 = load i32, i32* @SCHED_FIFO
%14 = call i32 @sched_setscheduler(i32 0, i32 %13, %struct.sched_param* %4)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i32, i32* @MCL_CURRENT
%21 = load i32, i32* @MCL_FUTURE
%22 = or i32 %21, %20
%23 = call i32 @mlockall(i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 -2)
unreachable
28: ; preds = %19
%29 = call i32 (...) @stack_prefault()
%30 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%37 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %6, i64 0, i64 0, i64 0
%38 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%39 = call i32 @getline(i8** %5, i64* %7, i32* %30)
%40 = icmp eq i32 %39, -1
br i1 %40, label %59, label %41
41: ; preds = %35, %41
%42 = phi i64 [ %54, %41 ], [ 0, %35 ]
%43 = phi i32 [ %55, %41 ], [ %39, %35 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %5
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %6, i64 0, i64 %42, i64 0
%48 = load i8*, i8** %5
%49 = call i8* @strtok(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @strcpy(i8* %47, i8* %49)
%51 = call i32 @puts(i8* %47)
%52 = trunc i64 %42 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %52)
%54 = add nuw i64 %42, 1
%55 = call i32 @getline(i8** %5, i64* %7, i32* %30)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %41
57: ; preds = %41
%58 = trunc i64 %54 to i32
br label %59
59: ; preds = %57, %35
%60 = phi i32 [ 0, %35 ], [ %58, %57 ]
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %60)
%62 = call i32 @fclose(i32* %30)
%63 = load i32, i32* @CLOCK_MONOTONIC
%64 = call i32 @clock_gettime(i32 %63, %struct.timespec* %3)
%65 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 1
store i32 %67, i32* %65
%68 = load i32, i32* @CLOCK_MONOTONIC
%69 = load i32, i32* @TIMER_ABSTIME
%70 = call i32 @clock_nanosleep(i32 %68, i32 %69, %struct.timespec* %3, i32* null)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%72 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%73 = icmp eq i32* %72, null
br i1 %73, label %80, label %74
74: ; preds = %59
%75 = bitcast i8** %8 to i8*
%76 = bitcast i64* %9 to i8*
%77 = icmp eq i32 %60, 0
%78 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%79 = zext i32 %60 to i64
br label %83
80: ; preds = %127, %59
%81 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %74, %127
%84 = phi i32* [ %72, %74 ], [ %132, %127 ]
store i8* null, i8** %8
store i64 0, i64* %9
br i1 %77, label %111, label %85
85: ; preds = %83, %103
%86 = phi i64 [ %104, %103 ], [ 0, %83 ]
%87 = trunc i64 %86 to i32
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [100 x [60 x i8]], [100 x [60 x i8]]* %6, i64 0, i64 %86, i64 0
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* %89)
%91 = call i32 @getline(i8** %8, i64* %9, i32* %84)
%92 = icmp eq i32 %91, -1
br i1 %92, label %103, label %93
93: ; preds = %85
%94 = load i8*, i8** %8
%95 = call i8* @strtok(i8* %94, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* %95)
%97 = load i8*, i8** %8
%98 = call i8* @strtok(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%99 = call i64 @strcmp(i8* %89, i8* %98)
%100 = icmp eq i64 %99, 0
br i1 %100, label %103, label %101
101: ; preds = %93
%102 = call i32 @system(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
br label %103
103: ; preds = %93, %101, %85
%104 = add nuw nsw i64 %86, 1
%105 = icmp eq i64 %104, %79
br i1 %105, label %106, label %85
106: ; preds = %103
%107 = load i8*, i8** %8
%108 = icmp eq i8* %107, null
br i1 %108, label %111, label %109
109: ; preds = %106
%110 = call i32 @free(i8* %107)
br label %111
111: ; preds = %83, %109, %106
%112 = call i32 @fclose(i32* %84)
%113 = load i32, i32* %78
%114 = add i32 %113, 2000000000
store i32 %114, i32* %78
%115 = icmp sgt i32 %113, -1000000001
br i1 %115, label %116, label %127
116: ; preds = %111
%117 = load i32, i32* %65
%118 = add i32 %113, -1294967297
%119 = call i32 @llvm.smin.i32(i32 %114, i32 1999999999)
%120 = sub i32 %118, %119
%121 = udiv i32 %120, 1000000000
%122 = mul i32 %121, -1000000000
%123 = add i32 %117, 1
%124 = add i32 %113, 1000000000
%125 = add i32 %122, %124
%126 = add i32 %123, %121
store i32 %125, i32* %78
store i32 %126, i32* %65
br label %127
127: ; preds = %116, %111
%128 = load i32, i32* @CLOCK_MONOTONIC
%129 = load i32, i32* @TIMER_ABSTIME
%130 = call i32 @clock_nanosleep(i32 %128, i32 %129, %struct.timespec* %3, i32* null)
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%132 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%133 = icmp eq i32* %132, null
br i1 %133, label %80, label %83
}