#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 */
struct pt_regs {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ do_profile(struct pt_regs *);
int /*<<< orphan*/ do_set_rtc();
int /*<<< orphan*/ do_timer(struct pt_regs *);
void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) {
  do_timer(regs);
  do_set_rtc();
  {
    static int count, state = 0xff;
    if (count-- == 0) {
      state ^= 1;
      count = 25;
      *((volatile unsigned int *)(0xe002ba00)) = state;
    }
  }
  do_profile(regs);
}


x86 assembly (clang, -O0):
<timer_interrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <do_timer@plt>
mov    $0x0,%al
call   1030 <do_set_rtc@plt>
mov    0x2ee7(%rip),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,0x2edc(%rip)
cmp    $0x0,%eax
jne    1193 <timer_interrupt+0x63>
mov    0x2ec5(%rip),%eax
xor    $0x1,%eax
mov    %eax,0x2ebc(%rip)
movl   $0x19,0x2eba(%rip)
mov    0x2eac(%rip),%ecx
mov    $0xe002ba00,%eax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <do_profile@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timer_interrupt>:
push   %rbx
mov    %rdx,%rbx
mov    %rdx,%rdi
call   1040 <do_timer@plt>
xor    %eax,%eax
call   1030 <do_set_rtc@plt>
subl   $0x1,0x2ef6(%rip)
jae    116c <timer_interrupt+0x3c>
mov    0x2ee6(%rip),%eax
xor    $0x1,%eax
mov    %eax,0x2edd(%rip)
movl   $0x19,0x2edb(%rip)
mov    $0xe002ba00,%ecx
mov    %eax,(%rcx)
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <do_profile@plt>

LLVM IR (-O0):
%struct.pt_regs = type { i32 }
@timer_interrupt.count = internal global i32 0
@timer_interrupt.state = internal global i32 255
define void @timer_interrupt(i32 %0, i8* %1, %struct.pt_regs* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.pt_regs*
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.pt_regs* %2, %struct.pt_regs** %6
%7 = load %struct.pt_regs*, %struct.pt_regs** %6
%8 = call i32 @do_timer(%struct.pt_regs* %7)
%9 = call i32 (...) @do_set_rtc()
%10 = load i32, i32* @timer_interrupt.count
%11 = add nsw i32 %10, -1
store i32 %11, i32* @timer_interrupt.count
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i32, i32* @timer_interrupt.state
%15 = xor i32 %14, 1
store i32 %15, i32* @timer_interrupt.state
store i32 25, i32* @timer_interrupt.count
%16 = load i32, i32* @timer_interrupt.state
store volatile i32 %16, i32* inttoptr (i64 3758275072 to i32*)
br label %17
17: ; preds = %13, %3
%18 = load %struct.pt_regs*, %struct.pt_regs** %6
%19 = call i32 @do_profile(%struct.pt_regs* %18)
ret void
}

LLVM IR (-O2):
%struct.pt_regs = type { i32 }
@timer_interrupt.count = internal unnamed_addr global i32 0
@timer_interrupt.state = internal unnamed_addr global i32 255
define void @timer_interrupt(i32 %0, i8* nocapture readnone %1, %struct.pt_regs* %2) {
%4 = tail call i32 @do_timer(%struct.pt_regs* %2)
%5 = tail call i32 (...) @do_set_rtc()
%6 = load i32, i32* @timer_interrupt.count
%7 = add nsw i32 %6, -1
store i32 %7, i32* @timer_interrupt.count
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @timer_interrupt.state
%11 = xor i32 %10, 1
store i32 %11, i32* @timer_interrupt.state
store i32 25, i32* @timer_interrupt.count
store volatile i32 %11, i32* inttoptr (i64 3758275072 to i32*)
br label %12
12: ; preds = %9, %3
%13 = tail call i32 @do_profile(%struct.pt_regs* %2)
ret void
}