#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 */
typedef scalar_t__ ssize_t;
typedef int int32_t;

/* Variables and functions */
int parseInt32(char const *, int *);
char *strstr(char const *, char *);
int parseMetaData(const char *line) {
  const char *match = strstr(line, ":");
  if (match == NULL) {
    return -1;
  }
  ssize_t colonPos = match - line;
  if (colonPos < 0) {
    return -1;
  }
  int32_t x;
  int err = parseInt32(line + colonPos + 1, &x);
  if (err != 0) {
    return err;
  }
  return x;
}


x86 assembly (clang, -O0):
<parseMetaData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1157 <parseMetaData+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <parseMetaData+0x90>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    117d <parseMetaData+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <parseMetaData+0x90>
mov    -0x10(%rbp),%rdi
add    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    -0x24(%rbp),%rsi
call   1030 <parseInt32@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     11aa <parseMetaData+0x8a>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <parseMetaData+0x90>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseMetaData>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     115e <parseMetaData+0x3e>
sub    %rbx,%rcx
js     115e <parseMetaData+0x3e>
lea    (%rbx,%rcx,1),%rdi
add    $0x1,%rdi
lea    0xc(%rsp),%rsi
call   1040 <parseInt32@plt>
test   %eax,%eax
jne    115e <parseMetaData+0x3e>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @parseMetaData(i8* %0) {
%2 = alloca i32
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 58)
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %1
%6 = ptrtoint i8* %3 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = icmp slt i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %5
%11 = bitcast i32* %2 to i8*
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = call i32 @parseInt32(i8* %13, i32* %2)
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* %2
%17 = select i1 %15, i32 %16, i32 %14
br label %18
18: ; preds = %10, %5, %1
%19 = phi i32 [ -1, %1 ], [ %17, %10 ], [ -1, %5 ]
ret i32 %19
}