#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 */
scalar_t__ strcmp(char *, char *);
int string_array_search_offset(char **string_array, char *search_string) {
  int offset = 0;
  while (*string_array) {
    if (strcmp(search_string, *string_array) == 0)
      return offset;
    offset++;
    string_array++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<string_array_search_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1174 <string_array_search_offset+0x64>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115a <string_array_search_offset+0x4a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <string_array_search_offset+0x6b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <string_array_search_offset+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_array_search_offset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    (%rdi),%rsi
mov    $0xffffffff,%r14d
test   %rsi,%rsi
je     1150 <string_array_search_offset+0x40>
mov    %rdi,%rbp
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114d <string_array_search_offset+0x3d>
mov    0x8(%rbp,%rbx,8),%rsi
add    $0x1,%rbx
test   %rsi,%rsi
jne    1130 <string_array_search_offset+0x20>
jmp    1150 <string_array_search_offset+0x40>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @string_array_search_offset(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
store i32 0, i32* %6
br label %7
7: ; preds = %19, %2
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = load i8**, i8*** %4
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %12, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i32, i32* %6
store i32 %18, i32* %3
br label %25
19: ; preds = %11
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i32 1
store i8** %23, i8*** %4
br label %7
24: ; preds = %7
store i32 -1, i32* %3
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @string_array_search_offset(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2, %11
%6 = phi i8* [ %14, %11 ], [ %3, %2 ]
%7 = phi i32 [ %12, %11 ], [ 0, %2 ]
%8 = phi i8** [ %13, %11 ], [ %0, %2 ]
%9 = tail call i64 @strcmp(i8* %1, i8* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = add nuw nsw i32 %7, 1
%13 = getelementptr inbounds i8*, i8** %8, i64 1
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %5
16: ; preds = %5, %11, %2
%17 = phi i32 [ -1, %2 ], [ -1, %11 ], [ %7, %5 ]
ret i32 %17
}