#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*/ SIG_DFL;
int /*<<< orphan*/ signal(int, int /*<<< orphan*/);
void my_isr_handler(int n) {
  static int c1, c2;
  if (n == 2) {
    c1++;
    if (c1 == 3) {
      signal(n, SIG_DFL);
    }
  } else if (n == 3) {
    c2++;
    if (c2 == 5) {
      signal(n, SIG_DFL);
    }
  }
}


x86 assembly (clang, -O0):
<my_isr_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    1157 <my_isr_handler+0x47>
mov    0x2f01(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ef8(%rip)
cmpl   $0x3,0x2ef1(%rip)
jne    1152 <my_isr_handler+0x42>
mov    -0x4(%rbp),%edi
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
jmp    1198 <my_isr_handler+0x88>
cmpl   $0x3,-0x4(%rbp)
jne    1193 <my_isr_handler+0x83>
mov    0x2ec9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ec0(%rip)
cmpl   $0x5,0x2eb9(%rip)
jne    118e <my_isr_handler+0x7e>
mov    -0x4(%rbp),%edi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
jmp    1193 <my_isr_handler+0x83>
jmp    1198 <my_isr_handler+0x88>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_isr_handler>:
cmp    $0x3,%edi
je     1134 <my_isr_handler+0x24>
cmp    $0x2,%edi
jne    1133 <my_isr_handler+0x23>
mov    0x2f0c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2f03(%rip)
mov    $0x2,%edi
cmp    $0x3,%eax
je     114d <my_isr_handler+0x3d>
ret
mov    0x2ef6(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eed(%rip)
mov    $0x3,%edi
cmp    $0x5,%eax
jne    1133 <my_isr_handler+0x23>
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
jmp    1030 <signal@plt>

LLVM IR (-O0):
@my_isr_handler.c1 = internal global i32 0
@my_isr_handler.c2 = internal global i32 0
@SIG_DFL = global i32 0
define void @my_isr_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 2
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = load i32, i32* @my_isr_handler.c1
%7 = add nsw i32 %6, 1
store i32 %7, i32* @my_isr_handler.c1
%8 = load i32, i32* @my_isr_handler.c1
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = load i32, i32* %2
%12 = load i32, i32* @SIG_DFL
%13 = call i32 @signal(i32 %11, i32 %12)
br label %14
14: ; preds = %10, %5
br label %29
15: ; preds = %1
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* @my_isr_handler.c2
%20 = add nsw i32 %19, 1
store i32 %20, i32* @my_isr_handler.c2
%21 = load i32, i32* @my_isr_handler.c2
%22 = icmp eq i32 %21, 5
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* %2
%25 = load i32, i32* @SIG_DFL
%26 = call i32 @signal(i32 %24, i32 %25)
br label %27
27: ; preds = %23, %18
br label %28
28: ; preds = %27, %15
br label %29
29: ; preds = %28, %14
ret void
}

LLVM IR (-O2):
@my_isr_handler.c1 = internal unnamed_addr global i32 0
@my_isr_handler.c2 = internal unnamed_addr global i32 0
@SIG_DFL = global i32 0
define void @my_isr_handler(i32 %0) {
switch i32 %0, label %14 [
i32 2, label %2
i32 3, label %6
]
2: ; preds = %1
%3 = load i32, i32* @my_isr_handler.c1
%4 = add nsw i32 %3, 1
store i32 %4, i32* @my_isr_handler.c1
%5 = icmp eq i32 %4, 3
br i1 %5, label %10, label %14
6: ; preds = %1
%7 = load i32, i32* @my_isr_handler.c2
%8 = add nsw i32 %7, 1
store i32 %8, i32* @my_isr_handler.c2
%9 = icmp eq i32 %8, 5
br i1 %9, label %10, label %14
10: ; preds = %6, %2
%11 = phi i32 [ 2, %2 ], [ 3, %6 ]
%12 = load i32, i32* @SIG_DFL
%13 = tail call i32 @signal(i32 %11, i32 %12)
br label %14
14: ; preds = %10, %1, %6, %2
ret void
}