#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_value;
  TYPE_1__ it_interval;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int setitimer(int /*<<< orphan*/, struct itimerval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void setup_timer() {
  struct itimerval timer;
  timer.it_value.tv_sec = 10;
  timer.it_value.tv_usec = 0;
  timer.it_interval = timer.it_value;
  int retval = setitimer(ITIMER_REAL, &timer, NULL);
  if (retval != 0) {
    fputs("set timer failed\n", stderr);
    return;
  }
  printf("timer is ready\n");
}


x86 assembly (clang, -O0):
<setup_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xa,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <setitimer@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1194 <setup_timer+0x64>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
call   1040 <fputs@plt>
jmp    11a0 <setup_timer+0x70>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_timer>:
sub    $0x28,%rsp
movl   $0xa,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    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <setitimer@plt>
test   %eax,%eax
je     1191 <setup_timer+0x61>
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
lea    0xe78(%rip),%rdi
add    $0x28,%rsp
jmp    1040 <fputs@plt>
lea    0xe7a(%rip),%rdi
add    $0x28,%rsp
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_2__, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@ITIMER_REAL = global i32 0
@.str = [18 x i8] c"set timer failed\0A\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"timer is ready\0A\00"
define void @setup_timer() {
%1 = alloca %struct.itimerval
%2 = alloca i32
%3 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 0
%4 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %3, i32 0, i32 0
store i32 10, i32* %4
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 0
%6 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %5, i32 0, i32 1
store i64 0, i64* %6
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 1
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 0
%9 = bitcast %struct.TYPE_2__* %7 to i8*
%10 = bitcast %struct.TYPE_2__* %8 to i8*
%11 = load i32, i32* @ITIMER_REAL
%12 = call i32 @setitimer(i32 %11, %struct.itimerval* %1, i32* null)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %20
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_2__, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@ITIMER_REAL = global i32 0
@.str = [18 x i8] c"set timer failed\0A\00"
@stderr = global i32 0
@str = [15 x i8] c"timer is ready\00"
define void @setup_timer() {
%1 = alloca %struct.itimerval
%2 = bitcast %struct.itimerval* %1 to i8*
%3 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 0
store i32 10, i32* %3
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 1
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 1
%6 = bitcast %struct.TYPE_2__* %5 to i8*
%7 = load i32, i32* @ITIMER_REAL
%8 = call i32 @setitimer(i32 %7, %struct.itimerval* %1, i32* null)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = tail call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %15
13: ; preds = %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
ret void
}