#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 */
struct tokens {
  int dummy;
};

/* Variables and functions */
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int tokens_get_length(struct tokens *);
int /*<<< orphan*/ tokens_get_token(struct tokens *, int);
int detect_in_direction(struct tokens *tokens) {
  int i = 0;
  for (; i < tokens_get_length(tokens); i++) {
    if (strcmp(tokens_get_token(tokens, i), "<") == 0) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<detect_in_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <tokens_get_length@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11a1 <detect_in_direction+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <tokens_get_token@plt>
mov    %eax,%edi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    118e <detect_in_direction+0x5e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <detect_in_direction+0x78>
jmp    1193 <detect_in_direction+0x63>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <detect_in_direction+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detect_in_direction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <tokens_get_length@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    118d <detect_in_direction+0x5d>
xor    %ebp,%ebp
lea    0xeae(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <tokens_get_token@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     118a <detect_in_direction+0x5a>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <tokens_get_length@plt>
cmp    %eax,%ebp
jl     1160 <detect_in_direction+0x30>
jmp    118d <detect_in_direction+0x5d>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tokens = type { i32 }
@.str = [2 x i8] c"<\00"
define i32 @detect_in_direction(%struct.tokens* %0) {
%2 = alloca i32
%3 = alloca %struct.tokens*
%4 = alloca i32
store %struct.tokens* %0, %struct.tokens** %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %4
%7 = load %struct.tokens*, %struct.tokens** %3
%8 = call i32 @tokens_get_length(%struct.tokens* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = load %struct.tokens*, %struct.tokens** %3
%12 = load i32, i32* %4
%13 = call i32 @tokens_get_token(%struct.tokens* %11, i32 %12)
%14 = call i64 @strcmp(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i32, i32* %4
store i32 %17, i32* %2
br label %23
18: ; preds = %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %5
store i32 -1, i32* %2
br label %23
23: ; preds = %22, %16
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
%struct.tokens = type { i32 }
@.str = [2 x i8] c"<\00"
define i32 @detect_in_direction(%struct.tokens* %0) {
%2 = tail call i32 @tokens_get_length(%struct.tokens* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1, %9
%5 = phi i32 [ %10, %9 ], [ 0, %1 ]
%6 = tail call i32 @tokens_get_token(%struct.tokens* %0, i32 %5)
%7 = tail call i64 @strcmp(i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = add nuw nsw i32 %5, 1
%11 = tail call i32 @tokens_get_length(%struct.tokens* %0)
%12 = icmp slt i32 %10, %11
br i1 %12, label %4, label %13
13: ; preds = %4, %9, %1
%14 = phi i32 [ -1, %1 ], [ -1, %9 ], [ %5, %4 ]
ret i32 %14
}