#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 */
struct port_interface {
  int dummy;
};

/* Variables and functions */
int gpio_sequence(struct port_interface *, char const *, int);
char *strchr(char const *, char);
int strlen(char const *);
int gpio_bl_entry(struct port_interface *port, const char *seq) {
  char *s;
  if (seq == NULL || seq[0] == ':')
    return 1;
  s = strchr(seq, ':');
  if (s == NULL)
    return gpio_sequence(port, seq, strlen(seq));
  return gpio_sequence(port, seq, s - seq);
}


x86 assembly (clang, -O0):
<gpio_bl_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115b <gpio_bl_entry+0x2b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1167 <gpio_bl_entry+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <gpio_bl_entry+0xa1>
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b4 <gpio_bl_entry+0x84>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1050 <gpio_sequence@plt>
mov    %eax,-0x4(%rbp)
jmp    11d1 <gpio_bl_entry+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1050 <gpio_sequence@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_bl_entry>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1141 <gpio_bl_entry+0x11>
mov    %rsi,%rbx
cmpb   $0x3a,(%rsi)
jne    114e <gpio_bl_entry+0x1e>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rdi,%r14
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1167 <gpio_bl_entry+0x37>
sub    %ebx,%eax
jmp    116f <gpio_bl_entry+0x3f>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <gpio_sequence@plt>

LLVM IR (-O0):
%struct.port_interface = type { i32 }
define i32 @gpio_bl_entry(%struct.port_interface* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.port_interface*
%5 = alloca i8*
%6 = alloca i8*
store %struct.port_interface* %0, %struct.port_interface** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 58
br i1 %14, label %15, label %16
15: ; preds = %9, %2
store i32 1, i32* %3
br label %37
16: ; preds = %9
%17 = load i8*, i8** %5
%18 = call i8* @strchr(i8* %17, i8 signext 58)
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load %struct.port_interface*, %struct.port_interface** %4
%23 = load i8*, i8** %5
%24 = load i8*, i8** %5
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @gpio_sequence(%struct.port_interface* %22, i8* %23, i32 %25)
store i32 %26, i32* %3
br label %37
27: ; preds = %16
%28 = load %struct.port_interface*, %struct.port_interface** %4
%29 = load i8*, i8** %5
%30 = load i8*, i8** %6
%31 = load i8*, i8** %5
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
%36 = call i32 @gpio_sequence(%struct.port_interface* %28, i8* %29, i32 %35)
store i32 %36, i32* %3
br label %37
37: ; preds = %27, %21, %15
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.port_interface = type { i32 }
define i32 @gpio_bl_entry(%struct.port_interface* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 58
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = tail call i8* @strchr(i8* %1, i8 signext 58)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %1)
br label %17
12: ; preds = %7
%13 = ptrtoint i8* %8 to i64
%14 = ptrtoint i8* %1 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
br label %17
17: ; preds = %10, %12
%18 = phi i32 [ %16, %12 ], [ %11, %10 ]
%19 = tail call i32 @gpio_sequence(%struct.port_interface* %0, i8* %1, i32 %18)
br label %20
20: ; preds = %17, %2, %4
%21 = phi i32 [ 1, %4 ], [ 1, %2 ], [ %19, %17 ]
ret i32 %21
}