#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 atoi(char *);
scalar_t__ isspace(char);
char *strrchr(char *, char);
int parseOrigin(char *as) {
  int num = 0;
  if (as != NULL) {
    char *cnum;
    cnum = strrchr(as, ':');
    cnum++;
    while (isspace(*cnum)) {
      cnum++;
    }
    num = atoi(cnum + 2);
    return num;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parseOrigin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ae <parseOrigin+0x7e>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1193 <parseOrigin+0x63>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116c <parseOrigin+0x3c>
mov    -0x20(%rbp),%rdi
add    $0x2,%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <parseOrigin+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseOrigin>:
test   %rdi,%rdi
je     116b <parseOrigin+0x3b>
push   %rbx
mov    $0x3a,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
add    $0x2,%rbx
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <parseOrigin+0x20>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <atoi@plt>
xor    %eax,%eax
ret

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

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