#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct itimerval {
  TYPE_1__ it_interval;
  TYPE_1__ it_value;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ daemon(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ setitimer(int /*<<< orphan*/, struct itimerval *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)());
int /*<<< orphan*/ sigsuspend(int /*<<< orphan*/ *);
main() {
  struct itimerval value;
  sigset_t set;
  void mysync();
  daemon(0, 0);
  (void)signal(SIGALRM, mysync);
  value.it_interval.tv_sec = 30;
  value.it_interval.tv_usec = 0;
  value.it_value = value.it_interval;
  if (setitimer(ITIMER_REAL, &value, NULL)) {
    perror("update: setitimer");
    exit(1);
  }
  (void)sigemptyset(&set);
  for (;;)
    sigsuspend(&set);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1050 <daemon@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    0x2e48(%rip),%rsi
call   1030 <signal@plt>
movl   $0x1e,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <setitimer@plt>
cmp    $0x0,%rax
je     11f2 <main+0x82>
lea    0xe1d(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x2c(%rbp),%rdi
call   1040 <sigemptyset@plt>
lea    -0x2c(%rbp),%rdi
call   1060 <sigsuspend@plt>
jmp    11fb <main+0x8b>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
xor    %esi,%esi
call   1050 <daemon@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e52(%rip),%rsi
call   1030 <signal@plt>
movl   $0x1e,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1070 <setitimer@plt>
test   %rax,%rax
jne    11fa <main+0x8a>
lea    0x2c(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <sigsuspend@plt>
jmp    11f0 <main+0x80>
lea    0xdff(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_2__, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@SIGALRM = global i32 0
@ITIMER_REAL = global i32 0
@.str = [18 x i8] c"update: setitimer\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.itimerval
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @daemon(i32 0, i32 0)
%5 = load i32, i32* @SIGALRM
%6 = call i32 @signal(i32 %5, void (...)* @mysync)
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i32 0, i32 0
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
store i32 30, i32* %8
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i32 0, i32 0
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 1
store i64 0, i64* %10
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i32 0, i32 1
%12 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i32 0, i32 0
%13 = bitcast %struct.TYPE_2__* %11 to i8*
%14 = bitcast %struct.TYPE_2__* %12 to i8*
%15 = load i32, i32* @ITIMER_REAL
%16 = call i64 @setitimer(i32 %15, %struct.itimerval* %2, i32* null)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
%22 = call i32 @sigemptyset(i32* %3)
br label %23
23: ; preds = %23, %21
%24 = call i32 @sigsuspend(i32* %3)
br label %23
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_2__, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@SIGALRM = global i32 0
@ITIMER_REAL = global i32 0
@.str = [18 x i8] c"update: setitimer\00"
define i32 @main() {
%1 = alloca %struct.itimerval
%2 = alloca i32
%3 = bitcast %struct.itimerval* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @daemon(i32 0, i32 0)
%6 = load i32, i32* @SIGALRM
%7 = tail call i32 @signal(i32 %6, void (...)* @mysync)
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 0
store i32 30, i32* %8
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 1
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 1
%11 = bitcast %struct.TYPE_2__* %10 to i8*
%12 = load i32, i32* @ITIMER_REAL
%13 = call i64 @setitimer(i32 %12, %struct.itimerval* %1, i32* null)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %0
%19 = call i32 @sigemptyset(i32* %2)
br label %20
20: ; preds = %20, %18
%21 = call i32 @sigsuspend(i32* %2)
br label %20
}