#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*/ memset(char *, int /*<<< orphan*/, int);
int rule126(bool init, int len, char *base) {
  int i;
  if (init == true) {
    memset(base, 0, len);
    base[len / 4] = 1;
    base[(len / 4) * 3] = 1;
    return 0;
  }
  i = (base[1] != 0) + (base[2] != 0) + (base[3] != 0);
  return i == 1 || i == 2;
}


x86 assembly (clang, -O0):
<rule126>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1189 <rule126+0x79>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
imul   $0x3,%ecx,%ecx
movslq %ecx,%rcx
movb   $0x1,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
jmp    11ef <rule126+0xdf>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x18(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
cmp    $0x0,%ecx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
movsbl 0x3(%rcx),%ecx
cmp    $0x0,%ecx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0x31(%rbp)
je     11e4 <rule126+0xd4>
cmpl   $0x2,-0x1c(%rbp)
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rule126>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
cmp    $0x1,%edi
jne    1148 <rule126+0x38>
mov    %esi,%ebp
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
lea    0x3(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
sar    $0x2,%eax
cltq
movb   $0x1,(%rbx,%rax,1)
lea    (%rax,%rax,2),%rax
movb   $0x1,(%rbx,%rax,1)
jmp    1169 <rule126+0x59>
xor    %eax,%eax
cmpb   $0x0,0x2(%rbx)
setne  %al
cmpb   $0x1,0x1(%rbx)
sbb    $0x0,%eax
cmpb   $0x1,0x3(%rbx)
sbb    $0xffffffff,%eax
xor    %r14d,%r14d
cmp    $0x2,%eax
setb   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rule126(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %26
11: ; preds = %3
%12 = load i8*, i8** %7
%13 = load i32, i32* %6
%14 = call i32 @memset(i8* %12, i32 0, i32 %13)
%15 = load i8*, i8** %7
%16 = load i32, i32* %6
%17 = sdiv i32 %16, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 1, i8* %19
%20 = load i8*, i8** %7
%21 = load i32, i32* %6
%22 = sdiv i32 %21, 4
%23 = mul nsw i32 %22, 3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 1, i8* %25
store i32 0, i32* %4
br label %55
26: ; preds = %3
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i32
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i64 2
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
%38 = zext i1 %37 to i32
%39 = add nsw i32 %32, %38
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i32
%46 = add nsw i32 %39, %45
store i32 %46, i32* %8
%47 = load i32, i32* %8
%48 = icmp eq i32 %47, 1
br i1 %48, label %52, label %49
49: ; preds = %26
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 2
br label %52
52: ; preds = %49, %26
%53 = phi i1 [ true, %26 ], [ %51, %49 ]
%54 = zext i1 %53 to i32
store i32 %54, i32* %4
br label %55
55: ; preds = %52, %11
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
define i32 @rule126(i32 %0, i32 %1, i8* %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %13
5: ; preds = %3
%6 = tail call i32 @memset(i8* %2, i32 0, i32 %1)
%7 = sdiv i32 %1, 4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
store i8 1, i8* %9
%10 = mul nsw i32 %7, 3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %2, i64 %11
store i8 1, i8* %12
br label %30
13: ; preds = %3
%14 = getelementptr inbounds i8, i8* %2, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
%17 = getelementptr inbounds i8, i8* %2, i64 2
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
%20 = zext i1 %19 to i32
%21 = getelementptr inbounds i8, i8* %2, i64 3
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
%24 = zext i1 %23 to i32
%25 = sext i1 %16 to i32
%26 = add nsw i32 %25, %20
%27 = add nsw i32 %26, %24
%28 = icmp ult i32 %27, 2
%29 = zext i1 %28 to i32
br label %30
30: ; preds = %13, %5
%31 = phi i32 [ 0, %5 ], [ %29, %13 ]
ret i32 %31
}