#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int S1(int);
int S2(int);
uint32_t ClockFSM(uint8_t *state) {
  uint32_t *LFSR = (uint32_t *)state;
  uint32_t *FSM_R1 = ((uint32_t *)state) + 16;
  uint32_t *FSM_R2 = FSM_R1 + 1;
  uint32_t *FSM_R3 = FSM_R1 + 2;
  uint32_t F;
  uint32_t r;
  F = ((LFSR[15] + *FSM_R1) & 0xffffffff) ^ *FSM_R2;
  r = (*FSM_R2 + (*FSM_R3 ^ LFSR[5])) & 0xffffffff;
  *FSM_R3 = S2(*FSM_R2);
  *FSM_R2 = S1(*FSM_R1);
  *FSM_R1 = r;
  return F;
}


x86 assembly (clang, -O0):
<ClockFSM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x3c(%rax),%eax
mov    -0x18(%rbp),%rcx
add    (%rcx),%eax
and    $0xffffffff,%eax
mov    -0x20(%rbp),%rcx
xor    (%rcx),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%ecx
mov    -0x10(%rbp),%rdx
xor    0x14(%rdx),%ecx
add    %ecx,%eax
and    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <S2@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <S1@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClockFSM>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x14(%rdi),%r14d
mov    0x40(%rdi),%ebp
add    0x3c(%rdi),%ebp
mov    0x44(%rdi),%edi
xor    %edi,%ebp
xor    0x48(%rbx),%r14d
add    %edi,%r14d
call   1030 <S2@plt>
mov    %eax,0x48(%rbx)
mov    0x40(%rbx),%edi
call   1040 <S1@plt>
mov    %eax,0x44(%rbx)
mov    %r14d,0x40(%rbx)
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ClockFSM(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
%9 = load i32*, i32** %2
store i32* %9, i32** %3
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i64 16
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32* %13, i32** %5
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 2
store i32* %15, i32** %6
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i64 15
%18 = load i32, i32* %17
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = add nsw i32 %18, %20
%22 = and i32 %21, -1
%23 = load i32*, i32** %5
%24 = load i32, i32* %23
%25 = xor i32 %22, %24
store i32 %25, i32* %7
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = load i32*, i32** %6
%29 = load i32, i32* %28
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 5
%32 = load i32, i32* %31
%33 = xor i32 %29, %32
%34 = add nsw i32 %27, %33
%35 = and i32 %34, -1
store i32 %35, i32* %8
%36 = load i32*, i32** %5
%37 = load i32, i32* %36
%38 = call i32 @S2(i32 %37)
%39 = load i32*, i32** %6
store i32 %38, i32* %39
%40 = load i32*, i32** %4
%41 = load i32, i32* %40
%42 = call i32 @S1(i32 %41)
%43 = load i32*, i32** %5
store i32 %42, i32* %43
%44 = load i32, i32* %8
%45 = load i32*, i32** %4
store i32 %44, i32* %45
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
define i32 @ClockFSM(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 16
%3 = getelementptr inbounds i32, i32* %0, i64 17
%4 = getelementptr inbounds i32, i32* %0, i64 18
%5 = getelementptr inbounds i32, i32* %0, i64 15
%6 = load i32, i32* %5
%7 = load i32, i32* %2
%8 = add nsw i32 %7, %6
%9 = load i32, i32* %3
%10 = xor i32 %8, %9
%11 = load i32, i32* %4
%12 = getelementptr inbounds i32, i32* %0, i64 5
%13 = load i32, i32* %12
%14 = xor i32 %13, %11
%15 = add nsw i32 %14, %9
%16 = tail call i32 @S2(i32 %9)
store i32 %16, i32* %4
%17 = load i32, i32* %2
%18 = tail call i32 @S1(i32 %17)
store i32 %18, i32* %3
store i32 %15, i32* %2
ret i32 %10
}