#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 /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
const char *get_tty_name(int c) {
  if (c == 0) {
    if (access("/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB0",
               F_OK) != -1)
      return "/dev/ttyUSB0";
    if (access("/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB1",
               F_OK) != -1)
      return "/dev/ttyUSB1";
  }
  if (c == 1) {
    if (access("/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB0",
               F_OK) != -1)
      return "/dev/ttyUSB0";
    if (access("/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB1",
               F_OK) != -1)
      return "/dev/ttyUSB1";
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_tty_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1186 <get_tty_name+0x76>
mov    0x2eac(%rip),%rax
mov    (%rax),%esi
lea    0xecb(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     1153 <get_tty_name+0x43>
lea    0xeef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <get_tty_name+0xe9>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xee3(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     1181 <get_tty_name+0x71>
lea    0xf07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <get_tty_name+0xe9>
jmp    1186 <get_tty_name+0x76>
cmpl   $0x1,-0xc(%rbp)
jne    11f1 <get_tty_name+0xe1>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0xeec(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     11be <get_tty_name+0xae>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <get_tty_name+0xe9>
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
lea    0xef7(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     11ec <get_tty_name+0xdc>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <get_tty_name+0xe9>
jmp    11f1 <get_tty_name+0xe1>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tty_name>:
push   %rbx
cmp    $0x1,%edi
je     113f <get_tty_name+0x2f>
test   %edi,%edi
jne    117e <get_tty_name+0x6e>
mov    0x2eb7(%rip),%rbx
mov    (%rbx),%esi
lea    0xed6(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
jne    1159 <get_tty_name+0x49>
mov    (%rbx),%esi
lea    0xf09(%rip),%rdi
jmp    116b <get_tty_name+0x5b>
mov    0x2e92(%rip),%rbx
mov    (%rbx),%esi
lea    0xf3d(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     1162 <get_tty_name+0x52>
lea    0xed9(%rip),%rax
pop    %rbx
ret
mov    (%rbx),%esi
lea    0xf5a(%rip),%rdi
call   1030 <access@plt>
cmp    $0xffffffff,%eax
je     117e <get_tty_name+0x6e>
lea    0xf03(%rip),%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB0\00"
@F_OK = global i32 0
@.str.1 = [13 x i8] c"/dev/ttyUSB0\00"
@.str.2 = [57 x i8] c"/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB1\00"
@.str.3 = [13 x i8] c"/dev/ttyUSB1\00"
@.str.4 = [57 x i8] c"/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB0\00"
@.str.5 = [57 x i8] c"/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB1\00"
define i8* @get_tty_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load i32, i32* @F_OK
%8 = call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %32
11: ; preds = %6
%12 = load i32, i32* @F_OK
%13 = call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %32
16: ; preds = %11
br label %17
17: ; preds = %16, %1
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = load i32, i32* @F_OK
%22 = call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %32
25: ; preds = %20
%26 = load i32, i32* @F_OK
%27 = call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %32
30: ; preds = %25
br label %31
31: ; preds = %30, %17
store i8* null, i8** %2
br label %32
32: ; preds = %31, %29, %24, %15, %10
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@.str = [57 x i8] c"/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB0\00"
@F_OK = global i32 0
@.str.1 = [13 x i8] c"/dev/ttyUSB0\00"
@.str.2 = [57 x i8] c"/sys/devices/platform/sw-ohci.1/usb2/2-1/2-1:1.0/ttyUSB1\00"
@.str.3 = [13 x i8] c"/dev/ttyUSB1\00"
@.str.4 = [57 x i8] c"/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB0\00"
@.str.5 = [57 x i8] c"/sys/devices/platform/sw-ohci.2/usb4/4-1/4-1:1.0/ttyUSB1\00"
define i8* @get_tty_name(i32 %0) {
switch i32 %0, label %18 [
i32 0, label %2
i32 1, label %10
]
2: ; preds = %1
%3 = load i32, i32* @F_OK
%4 = tail call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = load i32, i32* @F_OK
%8 = tail call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %18, label %19
10: ; preds = %1
%11 = load i32, i32* @F_OK
%12 = tail call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* @F_OK
%16 = tail call i32 @access(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %19
18: ; preds = %6, %1, %14
br label %19
19: ; preds = %14, %10, %6, %2, %18
%20 = phi i8* [ null, %18 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %14 ]
ret i8* %20
}