#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 factorial(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int buscarPunteros(char *aguja, char **pajar) {
  int i = factorial(strlen(aguja)) - 1;
  while (i >= 0) {
    if (strcmp(aguja, pajar[i]) == 0)
      return i;
    i--;
  }
  return -1;
}


x86 assembly (clang, -O0):
<buscarPunteros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1030 <factorial@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1198 <buscarPunteros+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <buscarPunteros+0x5a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <buscarPunteros+0x6f>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <buscarPunteros+0x26>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buscarPunteros>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%edi
call   1030 <factorial@plt>
mov    %eax,%ebx
nopl   0x0(%rax)
test   %ebx,%ebx
jle    116d <buscarPunteros+0x3d>
add    $0xffffffffffffffff,%rbx
mov    %ebx,%eax
mov    (%r14,%rax,8),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1150 <buscarPunteros+0x20>
jmp    1172 <buscarPunteros+0x42>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @buscarPunteros(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @factorial(i32 %8)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %6
br label %11
11: ; preds = %25, %2
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = load i8**, i8*** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %15, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = load i32, i32* %6
store i32 %24, i32* %3
br label %29
25: ; preds = %14
%26 = load i32, i32* %6
%27 = add nsw i32 %26, -1
store i32 %27, i32* %6
br label %11
28: ; preds = %11
store i32 -1, i32* %3
br label %29
29: ; preds = %28, %23
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @buscarPunteros(i8* %0, i8** nocapture %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @factorial(i32 %3)
%5 = zext i32 %4 to i64
br label %6
6: ; preds = %11, %2
%7 = phi i64 [ %8, %11 ], [ %5, %2 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = and i64 %8, 4294967295
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %0, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %11
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %6, %17
%20 = phi i32 [ %18, %17 ], [ -1, %6 ]
ret i32 %20
}