#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 strlen(char *);
int point_position(char *str) {
  int i;
  int len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '.')
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<point_position>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    116e <point_position+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    115b <point_position+0x4b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1175 <point_position+0x65>
jmp    1160 <point_position+0x50>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <point_position+0x1f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<point_position>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jle    113f <point_position+0x2f>
mov    %ecx,%edx
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
cmpb   $0x2e,(%rbx,%rcx,1)
je     1141 <point_position+0x31>
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    1130 <point_position+0x20>
pop    %rbx
ret
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @point_position(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
store i32 0, i32* %4
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%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 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 46
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %27
22: ; preds = %12
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %8
26: ; preds = %8
store i32 -1, i32* %2
br label %27
27: ; preds = %26, %20
%28 = load i32, i32* %2
ret i32 %28
}

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