#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 */
size_t strlen(char const *);
int find_symb_pos(const char *str, char symb) {
  size_t i;
  for (i = 0; i < strlen(str); i++) {
    if (str[i] == symb)
      return (int)i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_symb_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    1185 <find_symb_pos+0x75>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    116f <find_symb_pos+0x5f>
mov    -0x20(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    118c <find_symb_pos+0x7c>
jmp    1174 <find_symb_pos+0x64>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112a <find_symb_pos+0x1a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_symb_pos>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     1143 <find_symb_pos+0x33>
xor    %edx,%edx
nopl   0x0(%rax)
cmp    %bpl,(%rbx,%rdx,1)
je     1141 <find_symb_pos+0x31>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1130 <find_symb_pos+0x20>
jmp    1143 <find_symb_pos+0x33>
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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