#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 autodetect_list(char **, int);
int tolower(char);
int get_list_type(char *fargs[], int nfargs, int type_pos, char *ptrs[],
                  int nitems) {
  if (nfargs >= type_pos) {
    switch (tolower(*fargs[type_pos - 1])) {
    case 'd':
      return 3;
    case 'n':
      return 2;
    case 'f':
      return 4;
    case 'i':
      return 5;
    case '\0':
      return autodetect_list(ptrs, nitems);
    default:
      return 1;
    }
  }
  return autodetect_list(ptrs, nitems);
}


x86 assembly (clang, -O0):
<get_list_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     1205 <get_list_type+0xe5>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
test   %eax,%eax
je     11e5 <get_list_type+0xc5>
jmp    1171 <get_list_type+0x51>
mov    -0x28(%rbp),%eax
sub    $0x64,%eax
je     11b5 <get_list_type+0x95>
jmp    1182 <get_list_type+0x62>
mov    -0x28(%rbp),%eax
sub    $0x66,%eax
je     11cd <get_list_type+0xad>
jmp    1193 <get_list_type+0x73>
mov    -0x28(%rbp),%eax
sub    $0x69,%eax
je     11d9 <get_list_type+0xb9>
jmp    11a4 <get_list_type+0x84>
mov    -0x28(%rbp),%eax
sub    $0x6e,%eax
je     11c1 <get_list_type+0xa1>
jmp    11f9 <get_list_type+0xd9>
movl   $0x3,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
movl   $0x2,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
movl   $0x4,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
movl   $0x5,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <autodetect_list@plt>
mov    %eax,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
movl   $0x1,-0x4(%rbp)
jmp    1214 <get_list_type+0xf4>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <autodetect_list@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_list_type>:
push   %rbp
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rcx,%rbx
cmp    %edx,%esi
jge    113d <get_list_type+0x1d>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <autodetect_list@plt>
movslq %edx,%rax
mov    -0x8(%rdi,%rax,8),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
lea    -0x64(%rax),%ecx
cmp    $0xa,%ecx
ja     1171 <get_list_type+0x51>
mov    $0x3,%eax
lea    0xe9f(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x4,%eax
jmp    1188 <get_list_type+0x68>
test   %eax,%eax
je     112d <get_list_type+0xd>
mov    $0x1,%eax
jmp    1188 <get_list_type+0x68>
mov    $0x5,%eax
jmp    1188 <get_list_type+0x68>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_list_type(i8** %0, i32 %1, i32 %2, i8** %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
store i8** %0, i8*** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8** %3, i8*** %10
store i32 %4, i32* %11
%12 = load i32, i32* %8
%13 = load i32, i32* %9
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %5
%16 = load i8**, i8*** %7
%17 = load i32, i32* %9
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %16, i64 %19
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = call i32 @tolower(i8 signext %22)
switch i32 %23, label %32 [
i32 100, label %24
i32 110, label %25
i32 102, label %26
i32 105, label %27
i32 0, label %28
]
24: ; preds = %15
store i32 3, i32* %6
br label %37
25: ; preds = %15
store i32 2, i32* %6
br label %37
26: ; preds = %15
store i32 4, i32* %6
br label %37
27: ; preds = %15
store i32 5, i32* %6
br label %37
28: ; preds = %15
%29 = load i8**, i8*** %10
%30 = load i32, i32* %11
%31 = call i32 @autodetect_list(i8** %29, i32 %30)
store i32 %31, i32* %6
br label %37
32: ; preds = %15
store i32 1, i32* %6
br label %37
33: ; preds = %5
%34 = load i8**, i8*** %10
%35 = load i32, i32* %11
%36 = call i32 @autodetect_list(i8** %34, i32 %35)
store i32 %36, i32* %6
br label %37
37: ; preds = %33, %32, %28, %27, %26, %25, %24
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
define i32 @get_list_type(i8** nocapture %0, i32 %1, i32 %2, i8** %3, i32 %4) {
%6 = icmp slt i32 %1, %2
br i1 %6, label %20, label %7
7: ; preds = %5
%8 = add nsw i32 %2, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = tail call i32 @tolower(i8 signext %12)
switch i32 %13, label %19 [
i32 100, label %22
i32 110, label %14
i32 102, label %15
i32 105, label %16
i32 0, label %17
]
14: ; preds = %7
br label %22
15: ; preds = %7
br label %22
16: ; preds = %7
br label %22
17: ; preds = %7
%18 = tail call i32 @autodetect_list(i8** %3, i32 %4)
br label %22
19: ; preds = %7
br label %22
20: ; preds = %5
%21 = tail call i32 @autodetect_list(i8** %3, i32 %4)
br label %22
22: ; preds = %7, %20, %19, %17, %16, %15, %14
%23 = phi i32 [ 1, %19 ], [ %18, %17 ], [ 5, %16 ], [ 4, %15 ], [ 2, %14 ], [ %21, %20 ], [ 3, %7 ]
ret i32 %23
}