#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 _open_serial_connection(char *, char *);
int _open_tcp_connection(char *, char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int _open_connection(char *name, char *option) {
  if (strncmp(name, "tcp:", strlen("tcp:")) == 0) {
    return _open_tcp_connection(name, option);
  } else {
    return _open_serial_connection(name, option);
  }
}


x86 assembly (clang, -O0):
<_open_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xea1(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe8f(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1195 <_open_connection+0x55>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <_open_tcp_connection@plt>
mov    %eax,-0x4(%rbp)
jmp    11a5 <_open_connection+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <_open_serial_connection@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_open_connection>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeae(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
test   %rax,%rax
je     117c <_open_connection+0x3c>
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <_open_serial_connection@plt>
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <_open_tcp_connection@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"tcp:\00"
define i32 @_open_connection(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = call i32 @_open_tcp_connection(i8* %11, i8* %12)
store i32 %13, i32* %3
br label %18
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i32 @_open_serial_connection(i8* %15, i8* %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %14, %10
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"tcp:\00"
define i32 @_open_connection(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @_open_tcp_connection(i8* %0, i8* %1)
br label %10
8: ; preds = %2
%9 = tail call i32 @_open_serial_connection(i8* %0, i8* %1)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
ret i32 %11
}