#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*/ write(int, char *, int);
int search_ets(char **argv) {
  int i;
  i = 0;
  while (argv[i]) {
    if (argv[i][1] == 's' && argv[i][0] == '-') {
      if (argv[i + 1])
        return (i + 1);
      else {
        write(1, "No item to search especified\n", 29);
        return (-1);
      }
    }
    i++;
  }
  write(1, "No item to search especified\n", 29);
  return (-1);
}


x86 assembly (clang, -O0):
<search_ets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11bd <search_ets+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x73,%eax
jne    11af <search_ets+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11af <search_ets+0x9f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118d <search_ets+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11da <search_ets+0xca>
mov    $0x1,%edi
lea    0xe67(%rip),%rsi
mov    $0x1d,%edx
call   1030 <write@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <search_ets+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <search_ets+0x13>
mov    $0x1,%edi
lea    0xe37(%rip),%rsi
mov    $0x1d,%edx
call   1030 <write@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_ets>:
push   %rax
mov    (%rdi),%rcx
test   %rcx,%rcx
je     1143 <search_ets+0x33>
mov    $0x1,%eax
jmp    112d <search_ets+0x1d>
mov    (%rdi,%rax,8),%rcx
add    $0x1,%rax
test   %rcx,%rcx
je     1143 <search_ets+0x33>
cmpb   $0x73,0x1(%rcx)
jne    1120 <search_ets+0x10>
cmpb   $0x2d,(%rcx)
jne    1120 <search_ets+0x10>
mov    %eax,%ecx
cmpq   $0x0,(%rdi,%rcx,8)
je     1143 <search_ets+0x33>
pop    %rcx
ret
lea    0xeb6(%rip),%rsi
mov    $0x1,%edi
mov    $0x1d,%edx
call   1030 <write@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"No item to search especified\0A\00"
define i32 @search_ets(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 0, i32* %4
br label %5
5: ; preds = %45, %1
%6 = load i8**, i8*** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %6, i64 %8
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %48
12: ; preds = %5
%13 = load i8**, i8*** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 115
br i1 %21, label %22, label %45
22: ; preds = %12
%23 = load i8**, i8*** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 45
br i1 %31, label %32, label %45
32: ; preds = %22
%33 = load i8**, i8*** %3
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %43
40: ; preds = %32
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %50
43: ; preds = %32
%44 = call i32 @write(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 29)
store i32 -1, i32* %2
br label %50
45: ; preds = %22, %12
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %5
48: ; preds = %5
%49 = call i32 @write(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 29)
store i32 -1, i32* %2
br label %50
50: ; preds = %48, %43, %40
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [30 x i8] c"No item to search especified\0A\00"
define i32 @search_ets(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %25, label %4
4: ; preds = %1, %20
%5 = phi i64 [ %21, %20 ], [ 0, %1 ]
%6 = phi i8* [ %23, %20 ], [ %2, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 115
br i1 %9, label %10, label %20
10: ; preds = %4
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = trunc i64 %5 to i32
%15 = add nuw nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
%18 = load i8*, i8** %17
%19 = icmp eq i8* %18, null
br i1 %19, label %25, label %27
20: ; preds = %10, %4
%21 = add nuw i64 %5, 1
%22 = getelementptr inbounds i8*, i8** %0, i64 %21
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %4
25: ; preds = %20, %1, %13
%26 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 29)
br label %27
27: ; preds = %25, %13
%28 = phi i32 [ %15, %13 ], [ -1, %25 ]
ret i32 %28
}