#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)) ^ *FSM_R2;
  r = (*FSM_R2 + (*FSM_R3 ^ LFSR[5]));
  *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
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
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 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = xor i32 %21, %23
store i32 %24, i32* %7
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = load i32*, i32** %6
%28 = load i32, i32* %27
%29 = load i32*, i32** %3
%30 = getelementptr inbounds i32, i32* %29, i64 5
%31 = load i32, i32* %30
%32 = xor i32 %28, %31
%33 = add nsw i32 %26, %32
store i32 %33, i32* %8
%34 = load i32*, i32** %5
%35 = load i32, i32* %34
%36 = call i32 @S2(i32 %35)
%37 = load i32*, i32** %6
store i32 %36, i32* %37
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = call i32 @S1(i32 %39)
%41 = load i32*, i32** %5
store i32 %40, i32* %41
%42 = load i32, i32* %8
%43 = load i32*, i32** %4
store i32 %42, i32* %43
%44 = load i32, i32* %7
ret i32 %44
}

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
}