#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ timer_t;
struct timespec {
  int tv_sec;
  int /*<<< orphan*/ tv_nsec;
};
struct sigevent {
  int /*<<< orphan*/ sigev_signo;
  int /*<<< orphan*/ sigev_notify;
};
struct TYPE_4__ {
  int tv_sec;
  int /*<<< orphan*/ tv_nsec;
};
struct TYPE_3__ {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};
struct itimerspec {
  TYPE_2__ it_value;
  TYPE_1__ it_interval;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ MYperror(char *, int, char *);
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIGEV_SIGNAL;
int /*<<< orphan*/ SIG_BLOCK;
int TIMER_ABSTIME;
int clock_gettime(int /*<<< orphan*/, struct timespec *);
int clock_settime(int /*<<< orphan*/, struct timespec *);
scalar_t__ getuid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int sigwait(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ sleep(int);
scalar_t__ timer_create(int /*<<< orphan*/, struct sigevent *,
                        int /*<<< orphan*/ *);
scalar_t__ timer_settime(int /*<<< orphan*/, int, struct itimerspec *,
                         int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  struct sigevent ev;
  struct timespec tpT0, tpT2, tpreset;
  struct itimerspec its;
  timer_t tid;
  int delta;
  int sig;
  sigset_t set;
  int flags = 0;
  if (getuid() != 0) {
    printf("Run this test as ROOT, not as a Regular User\n");
    return 3;
  }
  ev.sigev_notify = SIGEV_SIGNAL;
  ev.sigev_signo = SIGALRM;
  if (sigemptyset(&set) != 0) {
    perror("sigemptyset() was not successful\n");
    return 2;
  }
  if (sigaddset(&set, SIGALRM) != 0) {
    perror("sigaddset() was not successful\n");
    return 2;
  }
  if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
    perror("sigprocmask() failed\n");
    return 2;
  }
  if (clock_gettime(CLOCK_REALTIME, &tpT0) != 0) {
    perror("clock_gettime() was not successful\n");
    return 2;
  }
  if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {
    perror("timer_create() did not return success\n");
    return 2;
  }
  flags |= TIMER_ABSTIME;
  its.it_interval.tv_sec = 0;
  its.it_interval.tv_nsec = 0;
  its.it_value.tv_sec = tpT0.tv_sec + 9;
  its.it_value.tv_nsec = tpT0.tv_nsec;
  if (timer_settime(tid, flags, &its, NULL) != 0) {
    perror("timer_settime() did not return success\n");
    return 2;
  }
  sleep(3);
  ({
    int foobas = (clock_gettime(CLOCK_REALTIME, &tpreset));
    if (foobas == -1)
      MYperror("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/fzqing/linux-2.6/refs/heads/"
               "master/Documentation/high-res-timers/tests/4-1.c",
               103, "clock_gettime(CLOCK_REALTIME, &tpreset)");
    foobas;
  });
  if (clock_settime(CLOCK_REALTIME, &tpT0) != 0) {
    printf("clock_settime() was not successful\n");
    return 2;
  }
  if (sigwait(&set, &sig) == -1) {
    perror("sigwait() was not successful\n");
    return 2;
  }
  if (clock_gettime(CLOCK_REALTIME, &tpT2) != 0) {
    printf("clock_gettime() was not successful\n");
    return 2;
  }
  delta = tpT2.tv_sec - its.it_value.tv_sec;
  tpreset.tv_sec += tpT2.tv_sec - tpT0.tv_sec;
  ({
    int foobas = (clock_settime(CLOCK_REALTIME, &tpreset));
    if (foobas == -1)
      MYperror("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/fzqing/linux-2.6/refs/heads/"
               "master/Documentation/high-res-timers/tests/4-1.c",
               123, "clock_settime(CLOCK_REALTIME, &tpreset)");
    foobas;
  });
  if ((delta <= 1) && (delta >= 0)) {
    printf("Test PASSED\n");
    return 0;
  } else {
    printf("FAIL:  Ended %d, not %d\n", (int)tpT2.tv_sec,
           (int)its.it_value.tv_sec);
    return 1;
  }
  printf("This code should not be executed.\n");
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
cmp    $0x0,%rax
je     1218 <main+0x48>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0x58(%rbp),%rdi
call   1090 <sigemptyset@plt>
cmp    $0x0,%rax
je     125b <main+0x8b>
lea    0xde4(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
lea    -0x58(%rbp),%rdi
call   10f0 <sigaddset@plt>
cmp    $0x0,%rax
je     128f <main+0xbf>
lea    0xdd2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    -0x58(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    12c6 <main+0xf6>
lea    0xdbb(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1050 <clock_gettime@plt>
cmp    $0x0,%eax
je     12f9 <main+0x129>
lea    0xd9e(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1070 <timer_create@plt>
cmp    $0x0,%rax
je     1331 <main+0x161>
lea    0xd8a(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2ca8(%rip),%rax
mov    (%rax),%eax
or     -0x5c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x48(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x5c(%rbp),%esi
lea    -0x48(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <timer_settime@plt>
cmp    $0x0,%rax
je     1394 <main+0x1c4>
lea    0xd4e(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    $0x3,%edi
call   10e0 <sleep@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0xffffffff,-0x60(%rbp)
jne    13d5 <main+0x205>
lea    0xd35(%rip),%rdi
mov    $0x67,%esi
lea    0xdd0(%rip),%rdx
call   10c0 <MYperror@plt>
mov    -0x60(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   10a0 <clock_settime@plt>
cmp    $0x0,%eax
je     1410 <main+0x240>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
lea    -0x58(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   10d0 <sigwait@plt>
cmp    $0xffffffff,%eax
jne    143e <main+0x26e>
lea    0xdbf(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1050 <clock_gettime@plt>
cmp    $0x0,%eax
je     1473 <main+0x2a3>
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    -0x28(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%eax
sub    -0x20(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   10a0 <clock_settime@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    14bf <main+0x2ef>
lea    0xc4b(%rip),%rdi
mov    $0x7b,%esi
lea    0xd50(%rip),%rdx
call   10c0 <MYperror@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x1,-0x50(%rbp)
jg     14f3 <main+0x323>
cmpl   $0x0,-0x50(%rbp)
jl     14f3 <main+0x323>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    150e <main+0x33e>
mov    -0x28(%rbp),%esi
mov    -0x48(%rbp),%edx
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1070 <getuid@plt>
test   %rax,%rax
je     1208 <main+0x28>
lea    0x1052(%rip),%rdi
call   1050 <puts@plt>
mov    $0x3,%eax
jmp    1413 <main+0x233>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    0x2dcc(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x30(%rsp)
lea    0xc(%rsp),%rdi
call   10a0 <sigemptyset@plt>
test   %rax,%rax
jne    13af <main+0x1cf>
mov    (%rbx),%esi
lea    0xc(%rsp),%rdi
call   1100 <sigaddset@plt>
test   %rax,%rax
jne    13b8 <main+0x1d8>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1040 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     13c1 <main+0x1e1>
mov    0x2d51(%rip),%rbx
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   1060 <clock_gettime@plt>
test   %eax,%eax
jne    13ca <main+0x1ea>
mov    (%rbx),%edi
lea    0x30(%rsp),%rsi
lea    0x1c(%rsp),%rdx
call   1080 <timer_create@plt>
test   %rax,%rax
jne    13d3 <main+0x1f3>
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
xorps  %xmm0,%xmm0
movups %xmm0,0x40(%rsp)
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%ecx
add    $0x9,%eax
mov    %eax,0x38(%rsp)
mov    %ecx,0x3c(%rsp)
mov    0x1c(%rsp),%edi
lea    0x38(%rsp),%rdx
xor    %ecx,%ecx
call   1030 <timer_settime@plt>
test   %rax,%rax
jne    13f9 <main+0x219>
mov    $0x3,%edi
call   10f0 <sleep@plt>
mov    (%rbx),%edi
lea    0x20(%rsp),%rsi
call   1060 <clock_gettime@plt>
cmp    $0xffffffff,%eax
jne    130d <main+0x12d>
lea    0xdcf(%rip),%rdi
lea    0xe6f(%rip),%rdx
mov    $0x67,%esi
call   10d0 <MYperror@plt>
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   10b0 <clock_settime@plt>
test   %eax,%eax
je     1326 <main+0x146>
lea    0xf04(%rip),%rdi
jmp    1355 <main+0x175>
lea    0xc(%rsp),%rdi
lea    0x54(%rsp),%rsi
call   10e0 <sigwait@plt>
cmp    $0xffffffff,%eax
je     1402 <main+0x222>
mov    (%rbx),%edi
lea    0x28(%rsp),%rsi
call   1060 <clock_gettime@plt>
test   %eax,%eax
je     135f <main+0x17f>
lea    0xeb0(%rip),%rdi
call   1050 <puts@plt>
jmp    140e <main+0x22e>
mov    0x28(%rsp),%eax
mov    %eax,%ebp
sub    0x38(%rsp),%ebp
sub    0x10(%rsp),%eax
add    %eax,0x20(%rsp)
mov    (%rbx),%edi
lea    0x20(%rsp),%rsi
call   10b0 <clock_settime@plt>
cmp    $0xffffffff,%eax
jne    139a <main+0x1ba>
lea    0xd42(%rip),%rdi
lea    0xe28(%rip),%rdx
mov    $0x7b,%esi
call   10d0 <MYperror@plt>
cmp    $0x1,%ebp
ja     13dc <main+0x1fc>
lea    0xe53(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
jmp    1413 <main+0x233>
lea    0xc4a(%rip),%rdi
jmp    1409 <main+0x229>
lea    0xc63(%rip),%rdi
jmp    1409 <main+0x229>
lea    0xc7a(%rip),%rdi
jmp    1409 <main+0x229>
lea    0xc87(%rip),%rdi
jmp    1409 <main+0x229>
lea    0xca2(%rip),%rdi
jmp    1409 <main+0x229>
mov    0x28(%rsp),%esi
mov    0x38(%rsp),%edx
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%eax
jmp    1413 <main+0x233>
lea    0xca3(%rip),%rdi
jmp    1409 <main+0x229>
lea    0xd91(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x2,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sigevent = type { i32, i32 }
%struct.timespec = type { i32, i32 }
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i64, i64 }
@.str = [46 x i8] c"Run this test as ROOT, not as a Regular User\0A\00"
@SIGEV_SIGNAL = global i32 0
@SIGALRM = global i32 0
@.str.1 = [34 x i8] c"sigemptyset() was not successful\0A\00"
@.str.2 = [32 x i8] c"sigaddset() was not successful\0A\00"
@SIG_BLOCK = global i32 0
@.str.3 = [22 x i8] c"sigprocmask() failed\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.4 = [36 x i8] c"clock_gettime() was not successful\0A\00"
@.str.5 = [39 x i8] c"timer_create() did not return success\0A\00"
@TIMER_ABSTIME = global i32 0
@.str.6 = [40 x i8] c"timer_settime() did not return success\0A\00"
@.str.7 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fzqing/linux-2.6/refs/heads/master/Documentation/high-res-timers/tests/4-1.c\00"
@.str.8 = [40 x i8] c"clock_gettime(CLOCK_REALTIME, &tpreset)\00"
@.str.9 = [36 x i8] c"clock_settime() was not successful\0A\00"
@.str.10 = [30 x i8] c"sigwait() was not successful\0A\00"
@.str.11 = [40 x i8] c"clock_settime(CLOCK_REALTIME, &tpreset)\00"
@.str.12 = [13 x i8] c"Test PASSED\0A\00"
@.str.13 = [25 x i8] c"FAIL: Ended %d, not %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sigevent
%7 = alloca %struct.timespec
%8 = alloca %struct.timespec
%9 = alloca %struct.timespec
%10 = alloca %struct.itimerspec
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %15
%20 = call i64 (...) @getuid()
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 3, i32* %3
br label %145
24: ; preds = %2
%25 = load i32, i32* @SIGEV_SIGNAL
%26 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %6, i32 0, i32 1
store i32 %25, i32* %26
%27 = load i32, i32* @SIGALRM
%28 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %6, i32 0, i32 0
store i32 %27, i32* %28
%29 = call i64 @sigemptyset(i32* %14)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %145
33: ; preds = %24
%34 = load i32, i32* @SIGALRM
%35 = call i64 @sigaddset(i32* %14, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %145
39: ; preds = %33
%40 = load i32, i32* @SIG_BLOCK
%41 = call i32 @sigprocmask(i32 %40, i32* %14, i32* null)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %145
45: ; preds = %39
%46 = load i32, i32* @CLOCK_REALTIME
%47 = call i32 @clock_gettime(i32 %46, %struct.timespec* %7)
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %145
51: ; preds = %45
%52 = load i32, i32* @CLOCK_REALTIME
%53 = call i64 @timer_create(i32 %52, %struct.sigevent* %6, i32* %11)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %145
57: ; preds = %51
%58 = load i32, i32* @TIMER_ABSTIME
%59 = load i32, i32* %15
%60 = or i32 %59, %58
store i32 %60, i32* %15
%61 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 1
%62 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %61, i32 0, i32 1
store i64 0, i64* %62
%63 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 1
%64 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %63, i32 0, i32 0
store i64 0, i64* %64
%65 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 9
%68 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 0
%69 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %68, i32 0, i32 0
store i32 %67, i32* %69
%70 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%71 = load i32, i32* %70
%72 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 0
%73 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %72, i32 0, i32 1
store i32 %71, i32* %73
%74 = load i32, i32* %11
%75 = load i32, i32* %15
%76 = call i64 @timer_settime(i32 %74, i32 %75, %struct.itimerspec* %10, i32* null)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %57
%79 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
store i32 2, i32* %3
br label %145
80: ; preds = %57
%81 = call i32 @sleep(i32 3)
%82 = load i32, i32* @CLOCK_REALTIME
%83 = call i32 @clock_gettime(i32 %82, %struct.timespec* %9)
store i32 %83, i32* %16
%84 = load i32, i32* %16
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %80
%87 = call i32 @MYperror(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.7, i64 0, i64 0), i32 103, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
br label %88
88: ; preds = %86, %80
%89 = load i32, i32* %16
store i32 %89, i32* %17
%90 = load i32, i32* %17
%91 = load i32, i32* @CLOCK_REALTIME
%92 = call i32 @clock_settime(i32 %91, %struct.timespec* %7)
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %88
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
store i32 2, i32* %3
br label %145
96: ; preds = %88
%97 = call i32 @sigwait(i32* %14, i32* %13)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
store i32 2, i32* %3
br label %145
101: ; preds = %96
%102 = load i32, i32* @CLOCK_REALTIME
%103 = call i32 @clock_gettime(i32 %102, %struct.timespec* %8)
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %145
107: ; preds = %101
%108 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%109 = load i32, i32* %108
%110 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 0
%111 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = sub nsw i32 %109, %112
store i32 %113, i32* %12
%114 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%115 = load i32, i32* %114
%116 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%117 = load i32, i32* %116
%118 = sub nsw i32 %115, %117
%119 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
%120 = load i32, i32* %119
%121 = add nsw i32 %120, %118
store i32 %121, i32* %119
%122 = load i32, i32* @CLOCK_REALTIME
%123 = call i32 @clock_settime(i32 %122, %struct.timespec* %9)
store i32 %123, i32* %18
%124 = load i32, i32* %18
%125 = icmp eq i32 %124, -1
br i1 %125, label %126, label %128
126: ; preds = %107
%127 = call i32 @MYperror(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.7, i64 0, i64 0), i32 123, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
br label %128
128: ; preds = %126, %107
%129 = load i32, i32* %18
store i32 %129, i32* %19
%130 = load i32, i32* %19
%131 = load i32, i32* %12
%132 = icmp sle i32 %131, 1
br i1 %132, label %133, label %138
133: ; preds = %128
%134 = load i32, i32* %12
%135 = icmp sge i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %133
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %3
br label %145
138: ; preds = %133, %128
%139 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%140 = load i32, i32* %139
%141 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %10, i32 0, i32 0
%142 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %141, i32 0, i32 0
%143 = load i32, i32* %142
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %140, i32 %143)
store i32 1, i32* %3
br label %145
145: ; preds = %138, %136, %105, %99, %94, %78, %55, %49, %43, %37, %31, %22
%146 = load i32, i32* %3
ret i32 %146
}

LLVM IR (-O2):
%struct.sigevent = type { i32, i32 }
%struct.timespec = type { i32, i32 }
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i64, i64 }
@SIGEV_SIGNAL = global i32 0
@SIGALRM = global i32 0
@.str.1 = [34 x i8] c"sigemptyset() was not successful\0A\00"
@.str.2 = [32 x i8] c"sigaddset() was not successful\0A\00"
@SIG_BLOCK = global i32 0
@.str.3 = [22 x i8] c"sigprocmask() failed\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.4 = [36 x i8] c"clock_gettime() was not successful\0A\00"
@.str.5 = [39 x i8] c"timer_create() did not return success\0A\00"
@TIMER_ABSTIME = global i32 0
@.str.6 = [40 x i8] c"timer_settime() did not return success\0A\00"
@.str.7 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fzqing/linux-2.6/refs/heads/master/Documentation/high-res-timers/tests/4-1.c\00"
@.str.8 = [40 x i8] c"clock_gettime(CLOCK_REALTIME, &tpreset)\00"
@.str.10 = [30 x i8] c"sigwait() was not successful\0A\00"
@.str.11 = [40 x i8] c"clock_settime(CLOCK_REALTIME, &tpreset)\00"
@.str.13 = [25 x i8] c"FAIL: Ended %d, not %d\0A\00"
@str = [12 x i8] c"Test PASSED\00"
@str.14 = [35 x i8] c"clock_gettime() was not successful\00"
@str.15 = [35 x i8] c"clock_settime() was not successful\00"
@str.16 = [45 x i8] c"Run this test as ROOT, not as a Regular User\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sigevent
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca %struct.itimerspec
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast %struct.sigevent* %3 to i8*
%12 = bitcast %struct.timespec* %4 to i8*
%13 = bitcast %struct.timespec* %5 to i8*
%14 = bitcast %struct.timespec* %6 to i8*
%15 = bitcast %struct.itimerspec* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = tail call i64 (...) @getuid()
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %2
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.16, i64 0, i64 0))
br label %119
23: ; preds = %2
%24 = load i32, i32* @SIGEV_SIGNAL
%25 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %3, i64 0, i32 1
store i32 %24, i32* %25
%26 = load i32, i32* @SIGALRM
%27 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %3, i64 0, i32 0
store i32 %26, i32* %27
%28 = call i64 @sigemptyset(i32* %10)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %23
%31 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %119
32: ; preds = %23
%33 = load i32, i32* @SIGALRM
%34 = call i64 @sigaddset(i32* %10, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %119
38: ; preds = %32
%39 = load i32, i32* @SIG_BLOCK
%40 = call i32 @sigprocmask(i32 %39, i32* %10, i32* null)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %119
44: ; preds = %38
%45 = load i32, i32* @CLOCK_REALTIME
%46 = call i32 @clock_gettime(i32 %45, %struct.timespec* %4)
%47 = icmp eq i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %119
50: ; preds = %44
%51 = load i32, i32* @CLOCK_REALTIME
%52 = call i64 @timer_create(i32 %51, %struct.sigevent* %3, i32* %8)
%53 = icmp eq i64 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %119
56: ; preds = %50
%57 = load i32, i32* @TIMER_ABSTIME
%58 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %7, i64 0, i32 1, i32 0
%59 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%60 = bitcast i64* %58 to i8*
%61 = load i32, i32* %59
%62 = add nsw i32 %61, 9
%63 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %7, i64 0, i32 0, i32 0
store i32 %62, i32* %63
%64 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%65 = load i32, i32* %64
%66 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %7, i64 0, i32 0, i32 1
store i32 %65, i32* %66
%67 = load i32, i32* %8
%68 = call i64 @timer_settime(i32 %67, i32 %57, %struct.itimerspec* %7, i32* null)
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %56
%71 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
br label %119
72: ; preds = %56
%73 = call i32 @sleep(i32 3)
%74 = load i32, i32* @CLOCK_REALTIME
%75 = call i32 @clock_gettime(i32 %74, %struct.timespec* %6)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = call i32 @MYperror(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.7, i64 0, i64 0), i32 103, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
br label %79
79: ; preds = %77, %72
%80 = load i32, i32* @CLOCK_REALTIME
%81 = call i32 @clock_settime(i32 %80, %struct.timespec* %4)
%82 = icmp eq i32 %81, 0
br i1 %82, label %85, label %83
83: ; preds = %79
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0))
br label %119
85: ; preds = %79
%86 = call i32 @sigwait(i32* %10, i32* %9)
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
br label %119
90: ; preds = %85
%91 = load i32, i32* @CLOCK_REALTIME
%92 = call i32 @clock_gettime(i32 %91, %struct.timespec* %5)
%93 = icmp eq i32 %92, 0
br i1 %93, label %96, label %94
94: ; preds = %90
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
br label %119
96: ; preds = %90
%97 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%98 = load i32, i32* %97
%99 = load i32, i32* %63
%100 = sub nsw i32 %98, %99
%101 = load i32, i32* %59
%102 = sub i32 %98, %101
%103 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%104 = load i32, i32* %103
%105 = add nsw i32 %102, %104
store i32 %105, i32* %103
%106 = load i32, i32* @CLOCK_REALTIME
%107 = call i32 @clock_settime(i32 %106, %struct.timespec* %6)
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %111
109: ; preds = %96
%110 = call i32 @MYperror(i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.7, i64 0, i64 0), i32 123, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
br label %111
111: ; preds = %109, %96
%112 = icmp ult i32 %100, 2
br i1 %112, label %113, label %115
113: ; preds = %111
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %119
115: ; preds = %111
%116 = load i32, i32* %97
%117 = load i32, i32* %63
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 %116, i32 %117)
br label %119
119: ; preds = %115, %113, %94, %88, %83, %70, %54, %48, %42, %36, %30, %21
%120 = phi i32 [ 3, %21 ], [ 2, %30 ], [ 2, %36 ], [ 2, %42 ], [ 2, %48 ], [ 2, %54 ], [ 2, %70 ], [ 2, %83 ], [ 2, %88 ], [ 2, %94 ], [ 0, %113 ], [ 1, %115 ]
ret i32 %120
}