#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*/ check(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int split_and_check(char *str, int size, int len) {
  int left = 0;
  static char s1[500000], s2[500000];
  while (left + size < len) {
    strncpy(s1, str + left, size);
    strncpy(s2, str + left + size, size);
    if (!check(s1, s2))
      return 0;
    left += size;
  }
  return len / size;
}


x86 assembly (clang, -O0):
<split_and_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b9 <split_and_check+0x99>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
lea    0x2ee3(%rip),%rdi
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
lea    0x7cfe2(%rip),%rdi
call   1030 <strncpy@plt>
lea    0x2eb6(%rip),%rdi
lea    0x7cfcf(%rip),%rsi
call   1040 <check@plt>
cmp    $0x0,%eax
jne    11ab <split_and_check+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <split_and_check+0xa3>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <split_and_check+0x19>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_and_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbp
mov    %esi,0x8(%rsp)
movslq %esi,%r13
mov    %edx,0xc(%rsp)
movslq %edx,%rax
mov    %rax,0x10(%rsp)
lea    (%rdi,%r13,1),%rbx
mov    %r13,%r14
mov    0x8(%rsp),%r12d
cmp    0x10(%rsp),%r14
jge    119e <split_and_check+0x7e>
lea    0x2ee2(%rip),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
lea    0x7cff0(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
lea    0x2ebb(%rip),%rdi
mov    %r15,%rsi
call   1040 <check@plt>
add    %r13,%rbx
add    %r13,%rbp
add    %r13,%r14
test   %eax,%eax
jne    1150 <split_and_check+0x30>
xor    %eax,%eax
jmp    11a7 <split_and_check+0x87>
mov    0xc(%rsp),%eax
cltd
idivl  0x8(%rsp)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@split_and_check.s1 = internal global [500000 x i8] zeroinitializer
@split_and_check.s2 = internal global [500000 x i8] zeroinitializer
define i32 @split_and_check(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %34, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = add nsw i32 %10, %11
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %38
15: ; preds = %9
%16 = load i8*, i8** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i32, i32* %6
%21 = call i32 @strncpy(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s1, i64 0, i64 0), i8* %19, i32 %20)
%22 = load i8*, i8** %5
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i32, i32* %6
%30 = call i32 @strncpy(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s2, i64 0, i64 0), i8* %28, i32 %29)
%31 = call i32 @check(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s1, i64 0, i64 0), i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s2, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %15
store i32 0, i32* %4
br label %42
34: ; preds = %15
%35 = load i32, i32* %6
%36 = load i32, i32* %8
%37 = add nsw i32 %36, %35
store i32 %37, i32* %8
br label %9
38: ; preds = %9
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = sdiv i32 %39, %40
store i32 %41, i32* %4
br label %42
42: ; preds = %38, %33
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@split_and_check.s1 = internal global [500000 x i8] zeroinitializer
@split_and_check.s2 = internal global [500000 x i8] zeroinitializer
define i32 @split_and_check(i8* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = sext i32 %2 to i64
br label %6
6: ; preds = %10, %3
%7 = phi i64 [ %8, %10 ], [ 0, %3 ]
%8 = add i64 %7, %4
%9 = icmp slt i64 %8, %5
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %0, i64 %7
%12 = tail call i32 @strncpy(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s1, i64 0, i64 0), i8* %11, i32 %1)
%13 = getelementptr inbounds i8, i8* %11, i64 %4
%14 = tail call i32 @strncpy(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s2, i64 0, i64 0), i8* %13, i32 %1)
%15 = tail call i32 @check(i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s1, i64 0, i64 0), i8* getelementptr inbounds ([500000 x i8], [500000 x i8]* @split_and_check.s2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %6
17: ; preds = %6
%18 = sdiv i32 %2, %1
br label %19
19: ; preds = %10, %17
%20 = phi i32 [ %18, %17 ], [ 0, %10 ]
ret i32 %20
}