#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*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *quotequotes(char *);
scalar_t__ strcmp(char *, char *);
void select_list(char **list, char *vname, char *def) {
  int i;
  printf("<select name=%s>\n", vname);
  printf("<option %s value=\"\">\n", (def && *def) ? "" : "SELECTED");
  for (i = 0; list && list[i]; i++) {
    char *s = quotequotes(list[i]);
    printf("<option %s value=\"%s\">%s\n",
           (def && strcmp(def, list[i]) == 0) ? "SELECTED" : "", s, s);
    free(s);
  }
  printf("</select>\n");
}


x86 assembly (clang, -O0):
<select_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x29(%rbp)
je     1186 <select_list+0x46>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%cl
lea    0xe98(%rip),%rsi
lea    0xe90(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x2a(%rbp)
je     11d6 <select_list+0x96>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
setne  %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    11e6 <select_list+0xa6>
jmp    126f <select_list+0x12f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <quotequotes@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x2b(%rbp)
je     122a <select_list+0xea>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x2b(%rbp)
mov    -0x2b(%rbp),%cl
lea    0xdf3(%rip),%rsi
lea    0xded(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b3 <select_list+0x73>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%r12
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14,%r14
je     118c <select_list+0x3c>
cmpb   $0x0,(%r14)
lea    0xea9(%rip),%rax
lea    0xea1(%rip),%rsi
cmove  %rax,%rsi
jmp    1193 <select_list+0x43>
lea    0xe95(%rip),%rsi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r12,%r12
je     121e <select_list+0xce>
mov    (%r12),%rdi
test   %rdi,%rdi
je     121e <select_list+0xce>
add    $0x8,%r12
lea    0xe6d(%rip),%r13
lea    0xe70(%rip),%r15
lea    0xe60(%rip),%rbp
jmp    11f5 <select_list+0xa5>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r12),%rdi
add    $0x8,%r12
test   %rdi,%rdi
je     121e <select_list+0xce>
call   1070 <quotequotes@plt>
mov    %rax,%rbx
mov    %r13,%rsi
test   %r14,%r14
je     11d0 <select_list+0x80>
mov    -0x8(%r12),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    %r13,%rsi
cmove  %rbp,%rsi
jmp    11d0 <select_list+0x80>
lea    0xe26(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"<select name=%s>\0A\00"
@.str.1 = [22 x i8] c"<option %s value=\22\22>\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"SELECTED\00"
@.str.4 = [26 x i8] c"<option %s value=\22%s\22>%s\0A\00"
@.str.5 = [11 x i8] c"</select>\0A\00"
define void @select_list(i8** %0, i8* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %3
%19 = phi i1 [ false, %3 ], [ %17, %13 ]
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %7
br label %23
23: ; preds = %62, %18
%24 = load i8**, i8*** %4
%25 = icmp ne i8** %24, null
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i8**, i8*** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br label %33
33: ; preds = %26, %23
%34 = phi i1 [ false, %23 ], [ %32, %26 ]
br i1 %34, label %35, label %65
35: ; preds = %33
%36 = load i8**, i8*** %4
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i8* @quotequotes(i8* %40)
store i8* %41, i8** %8
%42 = load i8*, i8** %6
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %53
44: ; preds = %35
%45 = load i8*, i8** %6
%46 = load i8**, i8*** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %45, i8* %50)
%52 = icmp eq i64 %51, 0
br label %53
53: ; preds = %44, %35
%54 = phi i1 [ false, %35 ], [ %52, %44 ]
%55 = zext i1 %54 to i64
%56 = select i1 %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%57 = load i8*, i8** %8
%58 = load i8*, i8** %8
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %56, i8* %57, i8* %58)
%60 = load i8*, i8** %8
%61 = call i32 @free(i8* %60)
br label %62
62: ; preds = %53
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %23
65: ; preds = %33
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"<select name=%s>\0A\00"
@.str.1 = [22 x i8] c"<option %s value=\22\22>\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"SELECTED\00"
@.str.4 = [26 x i8] c"<option %s value=\22%s\22>%s\0A\00"
@str = [10 x i8] c"</select>\00"
define void @select_list(i8** %0, i8* %1, i8* %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = icmp eq i8* %2, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
br label %10
10: ; preds = %6, %3
%11 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %3 ], [ %9, %6 ]
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = icmp eq i8** %0, null
br i1 %13, label %35, label %14
14: ; preds = %10
%15 = load i8*, i8** %0
%16 = icmp eq i8* %15, null
br i1 %16, label %35, label %17
17: ; preds = %14, %27
%18 = phi i8* [ %33, %27 ], [ %15, %14 ]
%19 = phi i8** [ %32, %27 ], [ %0, %14 ]
%20 = phi i64 [ %31, %27 ], [ 0, %14 ]
%21 = tail call i8* @quotequotes(i8* %18)
br i1 %5, label %27, label %22
22: ; preds = %17
%23 = load i8*, i8** %19
%24 = tail call i64 @strcmp(i8* %2, i8* %23)
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
br label %27
27: ; preds = %22, %17
%28 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %17 ], [ %26, %22 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %28, i8* %21, i8* %21)
%30 = tail call i32 @free(i8* %21)
%31 = add nuw i64 %20, 1
%32 = getelementptr inbounds i8*, i8** %0, i64 %31
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %17
35: ; preds = %27, %14, %10
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
ret void
}