#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 */
long long bytesize(char *);
scalar_t__ strncmp(char *, char const *, size_t);
long long get_value(char *ptr, const char *str, size_t str_len) {
  if (strncmp(ptr, str, str_len) == 0) {
    ptr += str_len;
    if (*ptr == ':') {
      ptr += 1;
      return (bytesize(ptr));
    }
  }
  return (-1L);
}


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118e <get_value+0x6e>
mov    -0x20(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1189 <get_value+0x69>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <bytesize@plt>
mov    %rax,-0x8(%rbp)
jmp    1196 <get_value+0x76>
jmp    118e <get_value+0x6e>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1151 <get_value+0x31>
cmpb   $0x3a,(%rbx,%r14,1)
jne    1151 <get_value+0x31>
add    %r14,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <bytesize@plt>
mov    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i64 @get_value(i8* %0, i8* %1, i64 %2) {
%4 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 %2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 58
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = tail call i64 @bytesize(i8* %11)
br label %13
13: ; preds = %3, %6, %10
%14 = phi i64 [ %12, %10 ], [ -1, %6 ], [ -1, %3 ]
ret i64 %14
}