#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 */
char *find_rom(char const *);
char *find_rom_in_list(const char *preferred, const char **list) {
  char *path;
  int i;
  if (preferred && (path = find_rom(preferred))) {
    return path;
  }
  if (list == NULL) {
    return NULL;
  }
  for (i = 0; list[i]; i++) {
    if ((path = find_rom(list[i])))
      return path;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_rom_in_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114f <find_rom_in_list+0x3f>
mov    -0x10(%rbp),%rdi
call   1030 <find_rom@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     114f <find_rom_in_list+0x3f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <find_rom_in_list+0xb8>
cmpq   $0x0,-0x18(%rbp)
jne    1167 <find_rom_in_list+0x57>
movq   $0x0,-0x8(%rbp)
jmp    11c8 <find_rom_in_list+0xb8>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c0 <find_rom_in_list+0xb0>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <find_rom@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ad <find_rom_in_list+0x9d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c8 <find_rom_in_list+0xb8>
jmp    11b2 <find_rom_in_list+0xa2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116e <find_rom_in_list+0x5e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_rom_in_list>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rdi,%rdi
je     1129 <find_rom_in_list+0x19>
call   1030 <find_rom@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1160 <find_rom_in_list+0x50>
test   %rbx,%rbx
je     1158 <find_rom_in_list+0x48>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1158 <find_rom_in_list+0x48>
add    $0x8,%rbx
xor    %r14d,%r14d
nopl   (%rax)
call   1030 <find_rom@plt>
test   %rax,%rax
jne    115d <find_rom_in_list+0x4d>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <find_rom_in_list+0x30>
jmp    1160 <find_rom_in_list+0x50>
xor    %r14d,%r14d
jmp    1160 <find_rom_in_list+0x50>
mov    %rax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @find_rom_in_list(i8* %0, i8** %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i8* @find_rom(i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %22
7: ; preds = %4, %2
%8 = icmp eq i8** %1, null
br i1 %8, label %22, label %9
9: ; preds = %7
%10 = load i8*, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %22, label %16
12: ; preds = %16
%13 = getelementptr inbounds i8*, i8** %1, i64 %21
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %9, %12
%17 = phi i64 [ %21, %12 ], [ 0, %9 ]
%18 = phi i8* [ %14, %12 ], [ %10, %9 ]
%19 = tail call i8* @find_rom(i8* %18)
%20 = icmp eq i8* %19, null
%21 = add nuw i64 %17, 1
br i1 %20, label %12, label %22
22: ; preds = %16, %12, %9, %7, %4
%23 = phi i8* [ %5, %4 ], [ null, %7 ], [ null, %9 ], [ %19, %16 ], [ null, %12 ]
ret i8* %23
}