#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 strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int verifica_caractere(char *linha) {
  int tamanho = strlen(linha), x = 0, posicao = 0;
  char letra[2];
  for (x = 0; x < tamanho; x++) {
    strncpy(letra, linha + x, 1);
    if (strcmp(":", letra) == 0)
      posicao = x;
  }
  if (posicao > 0) {
    return posicao;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<verifica_caractere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <verifica_caractere+0x85>
lea    -0x1e(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a2 <verifica_caractere+0x72>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a7 <verifica_caractere+0x77>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115d <verifica_caractere+0x2d>
cmpl   $0x0,-0x1c(%rbp)
jle    11ca <verifica_caractere+0x9a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <verifica_caractere+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verifica_caractere>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    1194 <verifica_caractere+0x64>
mov    %eax,%r12d
xor    %ebx,%ebx
lea    0x6(%rsp),%r13
lea    0xea8(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
lea    (%r14,%rbx,1),%rsi
mov    %r13,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
cmove  %ebx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <verifica_caractere+0x30>
xor    %eax,%eax
test   %ebp,%ebp
cmovns %ebp,%eax
jmp    1196 <verifica_caractere+0x66>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i32 @verifica_caractere(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i8]
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %5
br label %10
10: ; preds = %27, %1
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = call i32 @strncpy(i8* %15, i8* %19, i32 1)
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%22 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %14
%25 = load i32, i32* %5
store i32 %25, i32* %6
br label %26
26: ; preds = %24, %14
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %10
30: ; preds = %10
%31 = load i32, i32* %6
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* %6
store i32 %34, i32* %2
br label %36
35: ; preds = %30
store i32 0, i32* %2
br label %36
36: ; preds = %35, %33
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define i32 @verifica_caractere(i8* %0) {
%2 = alloca [2 x i8]
%3 = tail call i32 @strlen(i8* %0)
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %17, %8 ]
%10 = phi i32 [ 0, %6 ], [ %16, %8 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = call i32 @strncpy(i8* %4, i8* %11, i32 1)
%13 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %4)
%14 = icmp eq i64 %13, 0
%15 = trunc i64 %9 to i32
%16 = select i1 %14, i32 %15, i32 %10
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %19, label %8
19: ; preds = %8
%20 = icmp sgt i32 %16, 0
%21 = select i1 %20, i32 %16, i32 0
br label %22
22: ; preds = %19, %1
%23 = phi i32 [ 0, %1 ], [ %21, %19 ]
ret i32 %23
}