#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 */
scalar_t__ if_nametoindex(char *);
char *get_station_ifname(void) {
  if (if_nametoindex("eth1") > 0)
    return "eth1";
  if (if_nametoindex("wlan1") > 0 && if_nametoindex("wlan0") > 0)
    return "wlan0";
  return "wlan0";
}


x86 assembly (clang, -O0):
<get_station_ifname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <if_nametoindex@plt>
cmp    $0x0,%rax
jle    113e <get_station_ifname+0x2e>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <get_station_ifname+0x75>
lea    0xec0(%rip),%rdi
call   1030 <if_nametoindex@plt>
cmp    $0x0,%rax
jle    117a <get_station_ifname+0x6a>
lea    0xeb0(%rip),%rdi
call   1030 <if_nametoindex@plt>
cmp    $0x0,%rax
jle    117a <get_station_ifname+0x6a>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <get_station_ifname+0x75>
lea    0xe8a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_station_ifname>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <if_nametoindex@plt>
test   %rax,%rax
jg     1145 <get_station_ifname+0x35>
lea    0xed9(%rip),%rdi
call   1030 <if_nametoindex@plt>
lea    0xed3(%rip),%rbx
test   %rax,%rax
jle    1145 <get_station_ifname+0x35>
mov    %rbx,%rdi
call   1030 <if_nametoindex@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"eth1\00"
@.str.1 = [6 x i8] c"wlan1\00"
@.str.2 = [6 x i8] c"wlan0\00"
define i8* @get_station_ifname() {
%1 = alloca i8*
%2 = call i64 @if_nametoindex(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp sgt i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1
br label %13
5: ; preds = %0
%6 = call i64 @if_nametoindex(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = call i64 @if_nametoindex(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %13
12: ; preds = %8, %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %13
13: ; preds = %12, %11, %4
%14 = load i8*, i8** %1
ret i8* %14
}

LLVM IR (-O2):
@.str = [5 x i8] c"eth1\00"
@.str.1 = [6 x i8] c"wlan1\00"
@.str.2 = [6 x i8] c"wlan0\00"
define i8* @get_station_ifname() {
%1 = tail call i64 @if_nametoindex(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp sgt i64 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i64 @if_nametoindex(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i64 @if_nametoindex(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %3, %0
%9 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %3 ]
ret i8* %9
}