#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 */
scalar_t__ IsStop(int const, int const);
int IsValidGencode(int const);
int /*<<< orphan*/ assert(int);
int count_sequence_stops(const int *seq, const int n, const int gencode) {
  assert(NULL != seq);
  assert(n > 0);
  assert(IsValidGencode(gencode));
  int nstop = 0;
  for (int i = 0; i < n; i++) {
    if (IsStop(seq[i], gencode)) {
      nstop++;
    }
  }
  return nstop;
}


x86 assembly (clang, -O0):
<count_sequence_stops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%edi
call   1040 <IsValidGencode@plt>
mov    %eax,%edi
call   1030 <assert@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <count_sequence_stops+0x98>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%esi
call   1050 <IsStop@plt>
cmp    $0x0,%rax
je     11b5 <count_sequence_stops+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ba <count_sequence_stops+0x8a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1183 <count_sequence_stops+0x53>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_sequence_stops>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14d,%r14d
setg   %dil
call   1030 <assert@plt>
mov    %r15d,%edi
call   1040 <IsValidGencode@plt>
mov    %eax,%edi
call   1030 <assert@plt>
test   %r14d,%r14d
jle    119e <count_sequence_stops+0x6e>
mov    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%edi
mov    %r15d,%esi
call   1050 <IsStop@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <count_sequence_stops+0x50>
jmp    11a0 <count_sequence_stops+0x70>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count_sequence_stops(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32*, i32** %4
%10 = icmp ne i32* null, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %6
%18 = call i32 @IsValidGencode(i32 %17)
%19 = call i32 @assert(i32 %18)
store i32 0, i32* %7
store i32 0, i32* %8
br label %20
20: ; preds = %37, %3
%21 = load i32, i32* %8
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32*, i32** %4
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %6
%31 = call i64 @IsStop(i32 %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %24
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %36
36: ; preds = %33, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %20
40: ; preds = %20
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
define i32 @count_sequence_stops(i32* %0, i32 %1, i32 %2) {
%4 = icmp ne i32* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp sgt i32 %1, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @IsValidGencode(i32 %2)
%11 = tail call i32 @assert(i32 %10)
br i1 %7, label %12, label %14
12: ; preds = %3
%13 = zext i32 %1 to i64
br label %16
14: ; preds = %16, %3
%15 = phi i32 [ 0, %3 ], [ %24, %16 ]
ret i32 %15
16: ; preds = %12, %16
%17 = phi i64 [ 0, %12 ], [ %25, %16 ]
%18 = phi i32 [ 0, %12 ], [ %24, %16 ]
%19 = getelementptr inbounds i32, i32* %0, i64 %17
%20 = load i32, i32* %19
%21 = tail call i64 @IsStop(i32 %20, i32 %2)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %18, %23
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, %13
br i1 %26, label %14, label %16
}