#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int SIGINT;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
void SIGINT_handler(int signo) {
  if (signo == SIGINT) {
    static int change = 0;
    if (change % 2 == 0)
      system("date\n");
    else
      system("date -u\n");
    change++;
  } else {
    fprintf(stderr, "Se ha producido un error al manejar la señal.\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<SIGINT_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
jne    1195 <SIGINT_handler+0x65>
mov    0x2eed(%rip),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1175 <SIGINT_handler+0x45>
lea    0xe95(%rip),%rdi
call   1030 <system@plt>
jmp    1181 <SIGINT_handler+0x51>
lea    0xe8a(%rip),%rdi
call   1030 <system@plt>
mov    0x2eb9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb0(%rip)
jmp    11b8 <SIGINT_handler+0x88>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SIGINT_handler>:
push   %rax
mov    0x2eb0(%rip),%rax
cmp    %edi,(%rax)
jne    1163 <SIGINT_handler+0x33>
testb  $0x1,0x2efd(%rip)
lea    0xeb6(%rip),%rax
lea    0xeb5(%rip),%rdi
cmove  %rax,%rdi
call   1030 <system@plt>
addl   $0x1,0x2edf(%rip)
pop    %rax
ret
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@SIGINT_handler.change = internal global i32 0
@.str = [6 x i8] c"date\0A\00"
@.str.1 = [9 x i8] c"date -u\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Se ha producido un error al manejar la se\C3\B1al.\0A\00"
@EXIT_FAILURE = global i32 0
define void @SIGINT_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGINT
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load i32, i32* @SIGINT_handler.change
%8 = srem i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %14
12: ; preds = %6
%13 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
%15 = load i32, i32* @SIGINT_handler.change
%16 = add nsw i32 %15, 1
store i32 %16, i32* @SIGINT_handler.change
br label %22
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %14
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGINT_handler.change = internal unnamed_addr global i32 0
@.str = [6 x i8] c"date\0A\00"
@.str.1 = [9 x i8] c"date -u\0A\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"Se ha producido un error al manejar la se\C3\B1al.\0A\00"
@EXIT_FAILURE = global i32 0
define void @SIGINT_handler(i32 %0) {
%2 = load i32, i32* @SIGINT
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = load i32, i32* @SIGINT_handler.change
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 @system(i8* %8)
%10 = load i32, i32* @SIGINT_handler.change
%11 = add nsw i32 %10, 1
store i32 %11, i32* @SIGINT_handler.change
ret void
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
}