#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 */
scalar_t__ strcasecmp(char const *, char *);
size_t strlen(char const *);
scalar_t__ strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int config_switch(const char *str) {
  size_t len = strlen(str);
  if ((len == 2 && strcasecmp(str, "on") == 0) ||
      (len == 3 && strcasecmp(str, "yes") == 0) ||
      (len == 4 && strcasecmp(str, "true") == 0))
    return 1;
  if ((len == 3 && strcasecmp(str, "off") == 0) ||
      (len == 2 && strcasecmp(str, "no") == 0) ||
      (len == 5 && strcasecmp(str, "false") == 0))
    return 0;
  return (int)strtol(str, NULL, 0);
}


x86 assembly (clang, -O0):
<config_switch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jne    116e <config_switch+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11b8 <config_switch+0x88>
cmpq   $0x3,-0x18(%rbp)
jne    1193 <config_switch+0x63>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11b8 <config_switch+0x88>
cmpq   $0x4,-0x18(%rbp)
jne    11c4 <config_switch+0x94>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c4 <config_switch+0x94>
movl   $0x1,-0x4(%rbp)
jmp    1251 <config_switch+0x121>
cmpq   $0x3,-0x18(%rbp)
jne    11e9 <config_switch+0xb9>
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1233 <config_switch+0x103>
cmpq   $0x2,-0x18(%rbp)
jne    120e <config_switch+0xde>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1233 <config_switch+0x103>
cmpq   $0x5,-0x18(%rbp)
jne    123f <config_switch+0x10f>
mov    -0x10(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    123f <config_switch+0x10f>
movl   $0x0,-0x4(%rbp)
jmp    1251 <config_switch+0x121>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_switch>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
add    $0xfffffffffffffffe,%rax
cmp    $0x3,%rax
ja     11bc <config_switch+0x8c>
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11a1 <config_switch+0x71>
lea    0xeb2(%rip),%rsi
jmp    11af <config_switch+0x7f>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11a1 <config_switch+0x71>
lea    0xe91(%rip),%rsi
jmp    11af <config_switch+0x7f>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11bc <config_switch+0x8c>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ca <config_switch+0x9a>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [6 x i8] c"false\00"
define i32 @config_switch(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %9, %1
%14 = load i64, i64* %4
%15 = icmp eq i64 %14, 3
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = call i64 @strcasecmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %16, %13
%21 = load i64, i64* %4
%22 = icmp eq i64 %21, 4
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %3
%25 = call i64 @strcasecmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %16, %9
store i32 1, i32* %2
br label %54
28: ; preds = %23, %20
%29 = load i64, i64* %4
%30 = icmp eq i64 %29, 3
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8*, i8** %3
%33 = call i64 @strcasecmp(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %49, label %35
35: ; preds = %31, %28
%36 = load i64, i64* %4
%37 = icmp eq i64 %36, 2
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = call i64 @strcasecmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %49, label %42
42: ; preds = %38, %35
%43 = load i64, i64* %4
%44 = icmp eq i64 %43, 5
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8*, i8** %3
%47 = call i64 @strcasecmp(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45, %38, %31
store i32 0, i32* %2
br label %54
50: ; preds = %45, %42
%51 = load i8*, i8** %3
%52 = call i64 @strtol(i8* %51, i32* null, i32 0)
%53 = trunc i64 %52 to i32
store i32 %53, i32* %2
br label %54
54: ; preds = %50, %49, %27
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [6 x i8] c"false\00"
define i32 @config_switch(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
switch i64 %2, label %21 [
i64 2, label %3
i64 3, label %6
i64 4, label %9
i64 5, label %18
]
3: ; preds = %1
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %24, label %15
6: ; preds = %1
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %24, label %12
9: ; preds = %1
%10 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %24, label %21
12: ; preds = %6
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %24, label %21
15: ; preds = %3
%16 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %21
18: ; preds = %1
%19 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %1, %15, %12, %9, %18
%22 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 0)
%23 = trunc i64 %22 to i32
br label %24
24: ; preds = %12, %15, %18, %3, %6, %9, %21
%25 = phi i32 [ %23, %21 ], [ 1, %9 ], [ 1, %6 ], [ 1, %3 ], [ 0, %18 ], [ 0, %15 ], [ 0, %12 ]
ret i32 %25
}