#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 find_magic(int *, int *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ process_str(char *, int *, int *, int, int *, int *);
int strlen(char *);
void main() {
  char str[] = "<><><<>";
  int len = strlen(str);
  int right[len];
  int left[len];
  for (int i = 0; i < len; i++) {
    right[i] = left[i] = -1;
  }
  int l_len, r_len;
  process_str(str, right, left, len, &l_len, &r_len);
  l_len++;
  r_len++;
  printf("%d %d", l_len, r_len);
  int res = find_magic(right, left, l_len, r_len);
  printf("Magic str len is %d", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movabs $0x3e3c3c3e3c3e3c,%rax
mov    %rax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e8 <main+0xa8>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movl   $0xffffffff,(%rcx,%rdx,4)
movslq -0x2c(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b0 <main+0x70>
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rsi
lea    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
call   1060 <process_str@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
call   1050 <find_magic@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x3e3c3c3e3c3e3c,%rax
mov    %rax,-0x38(%rbp)
lea    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rsp,%r13
mov    %eax,%r15d
mov    %rsp,%r14
lea    0xf(,%r15,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
mov    %rsp,%rbx
sub    %rcx,%rbx
mov    %rbx,%rsp
test   %eax,%eax
jle    11c8 <main+0x78>
lea    0x0(,%r15,4),%r12
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1050 <memset@plt>
lea    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%r8
lea    -0x2c(%rbp),%r9
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1070 <process_str@plt>
mov    -0x30(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x30(%rbp)
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <find_magic@plt>
lea    0xdec(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str = [8 x i8] c"<><><<>\00"
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [20 x i8] c"Magic str len is %d\00"
define void @main() {
%1 = alloca [8 x i8]
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast [8 x i8]* %1 to i8*
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %3
%16 = alloca i32, i64 %14
store i64 %14, i64* %4
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = alloca i32, i64 %18
store i64 %18, i64* %5
store i32 0, i32* %6
br label %20
20: ; preds = %31, %0
%21 = load i32, i32* %6
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %19, i64 %26
store i32 -1, i32* %27
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %16, i64 %29
store i32 -1, i32* %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %20
34: ; preds = %20
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%36 = load i32, i32* %2
%37 = call i32 @process_str(i8* %35, i32* %16, i32* %19, i32 %36, i32* %7, i32* %8)
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %43)
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = call i32 @find_magic(i32* %16, i32* %19, i32 %45, i32 %46)
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [20 x i8] c"Magic str len is %d\00"
define void @main() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
store i64 17517677995900476, i64* %1
%5 = call i32 @strlen(i8* %4)
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = alloca i32, i64 %6
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = bitcast i32* %9 to i8*
%13 = bitcast i32* %8 to i8*
%14 = shl nuw nsw i64 %6, 2
br label %15
15: ; preds = %11, %0
%16 = bitcast i32* %2 to i8*
%17 = bitcast i32* %3 to i8*
%18 = call i32 @process_str(i8* %4, i32* %8, i32* %9, i32 %5, i32* %2, i32* %3)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %22)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @find_magic(i32* %8, i32* %9, i32 %24, i32 %25)
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret void
}