#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 /*<<< orphan*/ strncpy(char *, char *, int);
int has_eq(char *z, char *w, int *where) {
  int i;
  for (i = 0; i < strlen(z); i++)
    if (z[i] == ':')
      break;
  if (i == strlen(z))
    return (0);
  strncpy(w, z, i);
  w[i] = 0;
  *where = i + 1;
  return (1);
}


x86 assembly (clang, -O0):
<has_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    1184 <has_eq+0x64>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1171 <has_eq+0x51>
jmp    1184 <has_eq+0x64>
jmp    1176 <has_eq+0x56>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113b <has_eq+0x1b>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    11ac <has_eq+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    11db <has_eq+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_eq>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
xor    %ebp,%ebp
mov    $0x0,%ebx
test   %eax,%eax
jle    116a <has_eq+0x4a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x3a,(%r12,%rbx,1)
je     116a <has_eq+0x4a>
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <has_eq+0x30>
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebx
je     1195 <has_eq+0x75>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %ebx,%eax
movb   $0x0,(%r15,%rax,1)
add    $0x1,%ebx
mov    %ebx,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @has_eq(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 0, i32* %8
br label %9
9: ; preds = %24, %3
%10 = load i32, i32* %8
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 58
br i1 %21, label %22, label %23
22: ; preds = %14
br label %27
23: ; preds = %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %9
27: ; preds = %22, %9
%28 = load i32, i32* %8
%29 = load i8*, i8** %5
%30 = call i32 @strlen(i8* %29)
%31 = icmp eq i32 %28, %30
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %4
br label %45
33: ; preds = %27
%34 = load i8*, i8** %6
%35 = load i8*, i8** %5
%36 = load i32, i32* %8
%37 = call i32 @strncpy(i8* %34, i8* %35, i32 %36)
%38 = load i8*, i8** %6
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %7
store i32 %43, i32* %44
store i32 1, i32* %4
br label %45
45: ; preds = %33, %32
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
define i32 @has_eq(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3, %11
%7 = phi i64 [ %12, %11 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = add nuw nsw i64 %7, 1
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %6, label %16
16: ; preds = %6, %11
%17 = phi i64 [ %12, %11 ], [ %7, %6 ]
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %16, %3
%20 = phi i32 [ 0, %3 ], [ %18, %16 ]
%21 = tail call i32 @strlen(i8* %0)
%22 = icmp eq i32 %20, %21
br i1 %22, label %28, label %23
23: ; preds = %19
%24 = tail call i32 @strncpy(i8* %1, i8* %0, i32 %20)
%25 = zext i32 %20 to i64
%26 = getelementptr inbounds i8, i8* %1, i64 %25
store i8 0, i8* %26
%27 = add nuw nsw i32 %20, 1
store i32 %27, i32* %2
br label %28
28: ; preds = %19, %23
%29 = phi i32 [ 1, %23 ], [ 0, %19 ]
ret i32 %29
}