#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 path {
  int dummy;
};

/* Variables and functions */
int open_pty(struct path *);
int open_serial(char const *, struct path *);
int open_socket(char const *, struct path *);
scalar_t__ strcmp(char const *, char *);
bool open_path(const char *opt, struct path *path) {
  if ((strcmp(opt, "pty") == 0))
    return open_pty(path);
  else if ((strcmp(opt, "listen") == 0))
    return open_socket(opt, path);
  else
    return open_serial(opt, path);
}


x86 assembly (clang, -O0):
<open_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    117b <open_path+0x3b>
mov    -0x18(%rbp),%rdi
call   1030 <open_pty@plt>
mov    %eax,-0x4(%rbp)
jmp    11ba <open_path+0x7a>
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11aa <open_path+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <open_socket@plt>
mov    %eax,-0x4(%rbp)
jmp    11ba <open_path+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <open_serial@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeaf(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1181 <open_path+0x41>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
test   %rax,%rax
je     1190 <open_path+0x50>
pop    %rbx
pop    %r14
jmp    1060 <open_serial@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <open_pty@plt>
pop    %rbx
pop    %r14
jmp    1040 <open_socket@plt>

LLVM IR (-O0):
%struct.path = type { i32 }
@.str = [4 x i8] c"pty\00"
@.str.1 = [7 x i8] c"listen\00"
define i32 @open_path(i8* %0, %struct.path* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.path*
store i8* %0, i8** %4
store %struct.path* %1, %struct.path** %5
%6 = load i8*, i8** %4
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load %struct.path*, %struct.path** %5
%11 = call i32 @open_pty(%struct.path* %10)
store i32 %11, i32* %3
br label %24
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load %struct.path*, %struct.path** %5
%19 = call i32 @open_socket(i8* %17, %struct.path* %18)
store i32 %19, i32* %3
br label %24
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = load %struct.path*, %struct.path** %5
%23 = call i32 @open_serial(i8* %21, %struct.path* %22)
store i32 %23, i32* %3
br label %24
24: ; preds = %20, %16, %9
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
%struct.path = type { i32 }
@.str = [4 x i8] c"pty\00"
@.str.1 = [7 x i8] c"listen\00"
define i32 @open_path(i8* %0, %struct.path* %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @open_pty(%struct.path* %1)
br label %14
7: ; preds = %2
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @open_socket(i8* %0, %struct.path* %1)
br label %14
12: ; preds = %7
%13 = tail call i32 @open_serial(i8* %0, %struct.path* %1)
br label %14
14: ; preds = %12, %10, %5
%15 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %13, %12 ]
ret i32 %15
}