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

/* Variables and functions */
int /*<<< orphan*/ free(struct uio_info_t **);
int /*<<< orphan*/ strcmp(char *, char *);
struct uio_info_t **uio_find_devices();
char *uio_get_name(struct uio_info_t *);
struct uio_info_t *uio_find_by_uio_name(char *uio_name) {
  struct uio_info_t *info = NULL, **list, **uio_list;
  char *name;
  if (!uio_name)
    return NULL;
  uio_list = uio_find_devices();
  if (!uio_list)
    return NULL;
  for (list = uio_list; *list; list++) {
    struct uio_info_t *candidate = *list;
    name = uio_get_name(candidate);
    if (!strcmp(name, uio_name)) {
      info = candidate;
      break;
    }
  }
  free(uio_list);
  return info;
}


x86 assembly (clang, -O0):
<uio_find_by_uio_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116c <uio_find_by_uio_name+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    1207 <uio_find_by_uio_name+0xc7>
mov    $0x0,%al
call   1040 <uio_find_devices@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118f <uio_find_by_uio_name+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    1207 <uio_find_by_uio_name+0xc7>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f6 <uio_find_by_uio_name+0xb6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <uio_get_name@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e0 <uio_find_by_uio_name+0xa0>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    11f6 <uio_find_by_uio_name+0xb6>
jmp    11e5 <uio_find_by_uio_name+0xa5>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1197 <uio_find_by_uio_name+0x57>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uio_find_by_uio_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11b0 <uio_find_by_uio_name+0x70>
mov    %rdi,%r15
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <uio_find_devices@plt>
test   %rax,%rax
je     11b3 <uio_find_by_uio_name+0x73>
mov    %rax,%r14
mov    (%rax),%r12
test   %r12,%r12
je     11a3 <uio_find_by_uio_name+0x63>
mov    %r14,%rbx
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <uio_get_name@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11a6 <uio_find_by_uio_name+0x66>
mov    (%rbx),%r12
add    $0x8,%rbx
test   %r12,%r12
jne    1180 <uio_find_by_uio_name+0x40>
xor    %r12d,%r12d
mov    %r14,%rdi
call   1030 <free@plt>
jmp    11b3 <uio_find_by_uio_name+0x73>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.uio_info_t = type { i32 }
define %struct.uio_info_t* @uio_find_by_uio_name(i8* %0) {
%2 = alloca %struct.uio_info_t*
%3 = alloca i8*
%4 = alloca %struct.uio_info_t*
%5 = alloca %struct.uio_info_t**
%6 = alloca %struct.uio_info_t**
%7 = alloca i8*
%8 = alloca %struct.uio_info_t*
store i8* %0, i8** %3
store %struct.uio_info_t* null, %struct.uio_info_t** %4
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store %struct.uio_info_t* null, %struct.uio_info_t** %2
br label %42
12: ; preds = %1
%13 = call %struct.uio_info_t** (...) @uio_find_devices()
store %struct.uio_info_t** %13, %struct.uio_info_t*** %6
%14 = load %struct.uio_info_t**, %struct.uio_info_t*** %6
%15 = icmp ne %struct.uio_info_t** %14, null
br i1 %15, label %17, label %16
16: ; preds = %12
store %struct.uio_info_t* null, %struct.uio_info_t** %2
br label %42
17: ; preds = %12
%18 = load %struct.uio_info_t**, %struct.uio_info_t*** %6
store %struct.uio_info_t** %18, %struct.uio_info_t*** %5
br label %19
19: ; preds = %35, %17
%20 = load %struct.uio_info_t**, %struct.uio_info_t*** %5
%21 = load %struct.uio_info_t*, %struct.uio_info_t** %20
%22 = icmp ne %struct.uio_info_t* %21, null
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load %struct.uio_info_t**, %struct.uio_info_t*** %5
%25 = load %struct.uio_info_t*, %struct.uio_info_t** %24
store %struct.uio_info_t* %25, %struct.uio_info_t** %8
%26 = load %struct.uio_info_t*, %struct.uio_info_t** %8
%27 = call i8* @uio_get_name(%struct.uio_info_t* %26)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* %28, i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %23
%33 = load %struct.uio_info_t*, %struct.uio_info_t** %8
store %struct.uio_info_t* %33, %struct.uio_info_t** %4
br label %38
34: ; preds = %23
br label %35
35: ; preds = %34
%36 = load %struct.uio_info_t**, %struct.uio_info_t*** %5
%37 = getelementptr inbounds %struct.uio_info_t*, %struct.uio_info_t** %36, i32 1
store %struct.uio_info_t** %37, %struct.uio_info_t*** %5
br label %19
38: ; preds = %32, %19
%39 = load %struct.uio_info_t**, %struct.uio_info_t*** %6
%40 = call i32 @free(%struct.uio_info_t** %39)
%41 = load %struct.uio_info_t*, %struct.uio_info_t** %4
store %struct.uio_info_t* %41, %struct.uio_info_t** %2
br label %42
42: ; preds = %38, %16, %11
%43 = load %struct.uio_info_t*, %struct.uio_info_t** %2
ret %struct.uio_info_t* %43
}

LLVM IR (-O2):
%struct.uio_info_t = type { i32 }
define %struct.uio_info_t* @uio_find_by_uio_name(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call %struct.uio_info_t** (...) @uio_find_devices()
%5 = icmp eq %struct.uio_info_t** %4, null
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = load %struct.uio_info_t*, %struct.uio_info_t** %4
%8 = icmp eq %struct.uio_info_t* %7, null
br i1 %8, label %19, label %12
9: ; preds = %12
%10 = load %struct.uio_info_t*, %struct.uio_info_t** %18
%11 = icmp eq %struct.uio_info_t* %10, null
br i1 %11, label %19, label %12
12: ; preds = %6, %9
%13 = phi %struct.uio_info_t* [ %10, %9 ], [ %7, %6 ]
%14 = phi %struct.uio_info_t** [ %18, %9 ], [ %4, %6 ]
%15 = tail call i8* @uio_get_name(%struct.uio_info_t* %13)
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* %0)
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds %struct.uio_info_t*, %struct.uio_info_t** %14, i64 1
br i1 %17, label %19, label %9
19: ; preds = %9, %12, %6
%20 = phi %struct.uio_info_t* [ null, %6 ], [ %13, %12 ], [ null, %9 ]
%21 = tail call i32 @free(%struct.uio_info_t** %4)
br label %22
22: ; preds = %3, %1, %19
%23 = phi %struct.uio_info_t* [ %20, %19 ], [ null, %1 ], [ null, %3 ]
ret %struct.uio_info_t* %23
}