#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 */
struct TYPE_3__ {
  int tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_4__ {
  int tv_usec;
  scalar_t__ tv_sec;
};
struct itimerval {
  TYPE_1__ it_value;
  TYPE_2__ it_interval;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ EINTR;
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ setitimer(int /*<<< orphan*/, struct itimerval *,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int sigwait(int /*<<< orphan*/ *, int *);
int write(int /*<<< orphan*/, char *, int);
int main(void) {
  sigset_t blocked;
  struct itimerval t;
  int sig;
  sigemptyset(&blocked);
  sigaddset(&blocked, SIGALRM);
  sigprocmask(SIG_BLOCK, &blocked, NULL);
  t.it_interval.tv_sec = t.it_value.tv_sec = 0;
  t.it_interval.tv_usec = t.it_value.tv_usec = 10000;
  setitimer(ITIMER_REAL, &t, NULL);
  for (;;) {
    switch (sigwait(&blocked, &sig)) {
    case 0:
      if (write(0, "T", 1) != -1)
        continue;
    case -1:
      if (errno != EINTR)
        return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1080 <sigaddset@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x2710,-0x28(%rbp)
movl   $0x2710,-0x18(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <setitimer@plt>
lea    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <sigwait@plt>
mov    %eax,%ecx
mov    %ecx,-0x30(%rbp)
sub    $0xffffffff,%eax
je     122a <main+0xca>
jmp    11f4 <main+0x94>
mov    -0x30(%rbp),%eax
test   %eax,%eax
jne    1252 <main+0xf2>
jmp    1204 <main+0xa4>
xor    %edi,%edi
lea    0xdf3(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     1225 <main+0xc5>
jmp    11d4 <main+0x74>
jmp    122a <main+0xca>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
mov    0x2d86(%rip),%rcx
cmp    (%rcx),%eax
je     124d <main+0xed>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    1252 <main+0xf2>
jmp    11d4 <main+0x74>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <sigaddset@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
movq   $0x0,0x18(%rsp)
movq   $0x0,0x28(%rsp)
movl   $0x2710,0x10(%rsp)
movl   $0x2710,0x20(%rsp)
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1060 <setitimer@plt>
lea    0x8(%rsp),%rbx
mov    0x2def(%rip),%r12
mov    0x2dd8(%rip),%r13
lea    0xe11(%rip),%r15
jmp    120a <main+0xaa>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%eax
cmp    0x0(%r13),%eax
jne    1234 <main+0xd4>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <sigwait@plt>
cmp    $0xffffffff,%eax
je     1200 <main+0xa0>
test   %eax,%eax
jne    120a <main+0xaa>
xor    %edi,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    120a <main+0xaa>
jmp    1200 <main+0xa0>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i32, i64 }
%struct.TYPE_4__ = type { i32, i64 }
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@ITIMER_REAL = global i32 0
@.str = [2 x i8] c"T\00"
@errno = global i32 0
@EINTR = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.itimerval
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @sigemptyset(i32* %2)
%6 = load i32, i32* @SIGALRM
%7 = call i32 @sigaddset(i32* %2, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* %2, i32* null)
%10 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
store i64 0, i64* %11
%12 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 1
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %14, i32 0, i32 0
store i32 10000, i32* %15
%16 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 0
store i32 10000, i32* %17
%18 = load i32, i32* @ITIMER_REAL
%19 = call i32 @setitimer(i32 %18, %struct.itimerval* %3, i32* null)
br label %20
20: ; preds = %33, %25, %0
%21 = call i32 @sigwait(i32* %2, i32* %4)
switch i32 %21, label %33 [
i32 0, label %22
i32 -1, label %27
]
22: ; preds = %20
%23 = call i32 @write(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %22
br label %20
26: ; preds = %22
br label %27
27: ; preds = %20, %26
%28 = load i32, i32* @errno
%29 = load i32, i32* @EINTR
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
ret i32 1
32: ; preds = %27
br label %33
33: ; preds = %32, %20
br label %20
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i32, i64 }
%struct.TYPE_4__ = type { i32, i64 }
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@ITIMER_REAL = global i32 0
@.str = [2 x i8] c"T\00"
@errno = global i32 0
@EINTR = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.itimerval
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast %struct.itimerval* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @sigemptyset(i32* %1)
%8 = load i32, i32* @SIGALRM
%9 = call i32 @sigaddset(i32* %1, i32 %8)
%10 = load i32, i32* @SIG_BLOCK
%11 = call i32 @sigprocmask(i32 %10, i32* %1, i32* null)
%12 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 1
store i64 0, i64* %12
%13 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 1
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 0
store i32 10000, i32* %14
%15 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 0
store i32 10000, i32* %15
%16 = load i32, i32* @ITIMER_REAL
%17 = call i32 @setitimer(i32 %16, %struct.itimerval* %2, i32* null)
br label %18
18: ; preds = %20, %0
%19 = call i32 @sigwait(i32* %1, i32* %3)
switch i32 %19, label %20 [
i32 0, label %21
i32 -1, label %24
]
20: ; preds = %18, %24, %21
br label %18
21: ; preds = %18
%22 = call i32 @write(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %20
24: ; preds = %21, %18
%25 = load i32, i32* @errno
%26 = load i32, i32* @EINTR
%27 = icmp eq i32 %25, %26
br i1 %27, label %20, label %28
28: ; preds = %24
ret i32 1
}