#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 *lib_stralloc(char *);
int /*<<< orphan*/ resources_get_int_sprintf(char *, int *, char const *);
char *resources_write_item_to_string(char const *, char *);
int /*<<< orphan*/ util_addline_free(char **, char *);
char *romset_file_list(const char **resource_list) {
  char *list;
  const char *s;
  list = lib_stralloc("");
  s = *resource_list++;
  while (s != NULL) {
    int enable;
    char *line;
    resources_get_int_sprintf("Romset%s", &enable, s);
    line = resources_write_item_to_string(s, "\n");
    if (line != NULL) {
      util_addline_free(&list, line);
    }
    s = *resource_list++;
  }
  return list;
}


x86 assembly (clang, -O0):
<romset_file_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xeb7(%rip),%rdi
call   1040 <lib_stralloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d8 <romset_file_list+0x98>
mov    -0x18(%rbp),%rdx
lea    0xe78(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <resources_get_int_sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <resources_write_item_to_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bd <romset_file_list+0x7d>
mov    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1030 <util_addline_free@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <romset_file_list+0x32>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<romset_file_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xeb2(%rip),%rdi
call   1040 <lib_stralloc@plt>
mov    %rax,0x8(%rsp)
mov    (%rbx),%rbp
test   %rbp,%rbp
je     11cc <romset_file_list+0x8c>
add    $0x8,%rbx
lea    0xe8b(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xe88(%rip),%r12
lea    0x8(%rsp),%r13
jmp    119c <romset_file_list+0x5c>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rbp
add    $0x8,%rbx
test   %rbp,%rbp
je     11c7 <romset_file_list+0x87>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <resources_get_int_sprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <resources_write_item_to_string@plt>
test   %rax,%rax
je     1190 <romset_file_list+0x50>
mov    %r13,%rdi
mov    %rax,%rsi
call   1030 <util_addline_free@plt>
jmp    1190 <romset_file_list+0x50>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"Romset%s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @romset_file_list(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8** %0, i8*** %2
%7 = call i8* @lib_stralloc(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8**, i8*** %2
%9 = getelementptr inbounds i8*, i8** %8, i32 1
store i8** %9, i8*** %2
%10 = load i8*, i8** %8
store i8* %10, i8** %4
br label %11
11: ; preds = %24, %1
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = call i32 @resources_get_int_sprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %5, i8* %15)
%17 = load i8*, i8** %4
%18 = call i8* @resources_write_item_to_string(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i8*, i8** %6
%23 = call i32 @util_addline_free(i8** %3, i8* %22)
br label %24
24: ; preds = %21, %14
%25 = load i8**, i8*** %2
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %2
%27 = load i8*, i8** %25
store i8* %27, i8** %4
br label %11
28: ; preds = %11
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"Romset%s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @romset_file_list(i8** nocapture %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = bitcast i8** %2 to i8*
%5 = tail call i8* @lib_stralloc(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %24, label %8
8: ; preds = %1
%9 = bitcast i32* %3 to i8*
br label %10
10: ; preds = %8, %19
%11 = phi i8** [ %0, %8 ], [ %13, %19 ]
%12 = phi i8* [ %6, %8 ], [ %20, %19 ]
%13 = getelementptr inbounds i8*, i8** %11, i64 1
%14 = call i32 @resources_get_int_sprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i8* %12)
%15 = call i8* @resources_write_item_to_string(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = call i32 @util_addline_free(i8** %2, i8* %15)
br label %19
19: ; preds = %17, %10
%20 = load i8*, i8** %13
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %10
22: ; preds = %19
%23 = load i8*, i8** %2
br label %24
24: ; preds = %22, %1
%25 = phi i8* [ %23, %22 ], [ %5, %1 ]
ret i8* %25
}