#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 *);
int /*<<< orphan*/ memmove(char *, char const *, int);
int strlen(char const *);
char *strrchr(char *, char);
int get_branch_ext(char *buff, const char *rev, int *leaf) {
  char *p;
  int len = strlen(rev);
  memmove(buff, rev, len);
  buff[len] = 0;
  p = strrchr(buff, '.');
  if (!p)
    return 0;
  *p++ = 0;
  if (leaf)
    *leaf = atoi(p);
  return 1;
}


x86 assembly (clang, -O0):
<get_branch_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a5 <get_branch_ext+0x65>
movl   $0x0,-0x4(%rbp)
jmp    11da <get_branch_ext+0x9a>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x0,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     11d3 <get_branch_ext+0x93>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%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):
<get_branch_ext>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     119e <get_branch_ext+0x5e>
movb   $0x0,(%rax)
mov    $0x1,%ebp
test   %r14,%r14
je     11a0 <get_branch_ext+0x60>
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
jmp    11a0 <get_branch_ext+0x60>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_branch_ext(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %9
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = load i32, i32* %9
%15 = call i32 @memmove(i8* %12, i8* %13, i32 %14)
%16 = load i8*, i8** %5
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %5
%21 = call i8* @strrchr(i8* %20, i8 signext 46)
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %3
store i32 0, i32* %4
br label %35
25: ; preds = %3
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %8
store i8 0, i8* %26
%28 = load i32*, i32** %7
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i8*, i8** %8
%32 = call i32 @atoi(i8* %31)
%33 = load i32*, i32** %7
store i32 %32, i32* %33
br label %34
34: ; preds = %30, %25
store i32 1, i32* %4
br label %35
35: ; preds = %34, %24
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @get_branch_ext(i8* %0, i8* %1, i32* writeonly %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @memmove(i8* %0, i8* %1, i32 %4)
%6 = sext i32 %4 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 0, i8* %7
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %3
store i8 0, i8* %8
%11 = icmp eq i32* %2, null
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* %2
br label %15
15: ; preds = %10, %12, %3
%16 = phi i32 [ 0, %3 ], [ 1, %12 ], [ 1, %10 ]
ret i32 %16
}