#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 *config_get_option(char *);
scalar_t__ strcasecmp(char const *, char *);
int getservermode() {
  int servmode = 3;
  const char *opt = config_get_option("defaultmode");
  if (opt) {
    if (0 == strcasecmp(opt, "passive")) {
      servmode = 1;
    }
    if (0 == strcasecmp(opt, "active")) {
      servmode = 2;
    }
    if (0 == strcasecmp(opt, "asclient")) {
      servmode = 3;
    }
  }
  return servmode;
}


x86 assembly (clang, -O0):
<getservermode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <config_get_option@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11be <getservermode+0x9e>
mov    -0x10(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    116f <getservermode+0x4f>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1194 <getservermode+0x74>
movl   $0x2,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11b9 <getservermode+0x99>
movl   $0x3,-0x4(%rbp)
jmp    11be <getservermode+0x9e>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getservermode>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%rdi
call   1040 <config_get_option@plt>
test   %rax,%rax
je     118e <getservermode+0x6e>
mov    %rax,%rbx
lea    0xecd(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,1),%r14d
add    $0x1,%r14d
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
mov    $0x2,%ebp
cmovne %r14d,%ebp
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
mov    $0x3,%eax
cmovne %ebp,%eax
jmp    1193 <getservermode+0x73>
mov    $0x3,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"defaultmode\00"
@.str.1 = [8 x i8] c"passive\00"
@.str.2 = [7 x i8] c"active\00"
@.str.3 = [9 x i8] c"asclient\00"
define i32 @getservermode() {
%1 = alloca i32
%2 = alloca i8*
store i32 3, i32* %1
%3 = call i8* @config_get_option(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %22
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 0, %8
br i1 %9, label %10, label %11
10: ; preds = %6
store i32 1, i32* %1
br label %11
11: ; preds = %10, %6
%12 = load i8*, i8** %2
%13 = call i64 @strcasecmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 2, i32* %1
br label %16
16: ; preds = %15, %11
%17 = load i8*, i8** %2
%18 = call i64 @strcasecmp(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 0, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 3, i32* %1
br label %21
21: ; preds = %20, %16
br label %22
22: ; preds = %21, %0
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [12 x i8] c"defaultmode\00"
@.str.1 = [8 x i8] c"passive\00"
@.str.2 = [7 x i8] c"active\00"
@.str.3 = [9 x i8] c"asclient\00"
define i32 @getservermode() {
%1 = tail call i8* @config_get_option(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %13, label %3
3: ; preds = %0
%4 = tail call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i32 1, i32 3
%7 = tail call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 2, i32 %6
%10 = tail call i64 @strcasecmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 3, i32 %9
br label %13
13: ; preds = %3, %0
%14 = phi i32 [ 3, %0 ], [ %12, %3 ]
ret i32 %14
}