#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*/ error(char *);
int ll_first_up_if();
char const *ll_index_to_name(int);
const char *get_dev(int *dev_idx) {
  int idx;
  if ((idx = ll_first_up_if()) == -1) {
    error("Couldn't find \"up\" devices. Set one dev \"up\", or "
          "specify the device name in the options.");
    return 0;
  }
  if (dev_idx)
    *dev_idx = idx;
  return ll_index_to_name(idx);
}


x86 assembly (clang, -O0):
<get_dev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <ll_first_up_if@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1168 <get_dev+0x38>
lea    0xeaa(%rip),%rdi
call   1050 <error@plt>
movq   $0x0,-0x8(%rbp)
jmp    1188 <get_dev+0x58>
cmpq   $0x0,-0x10(%rbp)
je     117c <get_dev+0x4c>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%edi
call   1030 <ll_index_to_name@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dev>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <ll_first_up_if@plt>
cmp    $0xffffffff,%eax
je     114f <get_dev+0x1f>
test   %rbx,%rbx
je     1147 <get_dev+0x17>
mov    %eax,(%rbx)
mov    %eax,%edi
pop    %rbx
jmp    1030 <ll_index_to_name@plt>
lea    0xeaa(%rip),%rdi
call   1050 <error@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [89 x i8] c"Couldn't find \22up\22 devices. Set one dev \22up\22, or specify the device name in the options.\00"
define i8* @get_dev(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = call i32 (...) @ll_first_up_if()
store i32 %5, i32* %4
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @error(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %18
9: ; preds = %1
%10 = load i32*, i32** %3
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32*, i32** %3
store i32 %13, i32* %14
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %4
%17 = call i8* @ll_index_to_name(i32 %16)
store i8* %17, i8** %2
br label %18
18: ; preds = %15, %7
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [89 x i8] c"Couldn't find \22up\22 devices. Set one dev \22up\22, or specify the device name in the options.\00"
define i8* @get_dev(i32* writeonly %0) {
%2 = tail call i32 (...) @ll_first_up_if()
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @error(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str, i64 0, i64 0))
br label %11
6: ; preds = %1
%7 = icmp eq i32* %0, null
br i1 %7, label %9, label %8
8: ; preds = %6
store i32 %2, i32* %0
br label %9
9: ; preds = %8, %6
%10 = tail call i8* @ll_index_to_name(i32 %2)
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ null, %4 ], [ %10, %9 ]
ret i8* %12
}