#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 strtol(char const *, char **, int);
int process_uart_filename(const char *name) {
  if (name[0] == 'C' && name[1] == 'O' && name[2] == 'M') {
    char *endptr;
    int uart = strtol(name + 3, &endptr, 10);
    if (endptr[0] == ':' && endptr[1] == '\0') {
      return uart;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<process_uart_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    1198 <process_uart_filename+0x88>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x4f,%eax
jne    1198 <process_uart_filename+0x88>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x4d,%eax
jne    1198 <process_uart_filename+0x88>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1193 <process_uart_filename+0x83>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1193 <process_uart_filename+0x83>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <process_uart_filename+0x8f>
jmp    1198 <process_uart_filename+0x88>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_uart_filename>:
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%ebx
cmpb   $0x43,(%rdi)
jne    1150 <process_uart_filename+0x40>
cmpb   $0x4f,0x1(%rdi)
jne    1150 <process_uart_filename+0x40>
cmpb   $0x4d,0x2(%rdi)
jne    1150 <process_uart_filename+0x40>
add    $0x3,%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x3a,(%rcx)
jne    1150 <process_uart_filename+0x40>
cmpb   $0x0,0x1(%rcx)
jne    1150 <process_uart_filename+0x40>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @process_uart_filename(i8* %0) {
%2 = alloca i8*
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 67
br i1 %4, label %5, label %26
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 79
br i1 %8, label %9, label %26
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 77
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = bitcast i8** %2 to i8*
%15 = getelementptr inbounds i8, i8* %0, i64 3
%16 = call i32 @strtol(i8* %15, i8** %2, i32 10)
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 58
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = getelementptr inbounds i8, i8* %17, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %13, %20
br label %26
25: ; preds = %20
br label %26
26: ; preds = %1, %5, %9, %24, %25
%27 = phi i32 [ %16, %25 ], [ -1, %24 ], [ -1, %9 ], [ -1, %5 ], [ -1, %1 ]
ret i32 %27
}