#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__ strcmp(char *, char *);
char tolower(char);
int geterrmode(char *value) {
  int num;
  for (num = 0; value[num] != 0; num++)
    value[num] = tolower(value[num]);
  if (strcmp(value, "never") == 0)
    return (0);
  if (strcmp(value, "once") == 0)
    return (1);
  if (strcmp(value, "always") == 0)
    return (2);
  if (strcmp(value, "fatal") == 0)
    return (3);
  return (1);
}


x86 assembly (clang, -O0):
<geterrmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1174 <geterrmode+0x54>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <geterrmode+0x13>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119a <geterrmode+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    1213 <geterrmode+0xf3>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <geterrmode+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    1213 <geterrmode+0xf3>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e6 <geterrmode+0xc6>
movl   $0x2,-0x4(%rbp)
jmp    1213 <geterrmode+0xf3>
mov    -0x10(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <geterrmode+0xec>
movl   $0x3,-0x4(%rbp)
jmp    1213 <geterrmode+0xf3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geterrmode>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1156 <geterrmode+0x36>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <geterrmode+0x20>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b1 <geterrmode+0x91>
lea    0xe95(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b5 <geterrmode+0x95>
lea    0xe86(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11bc <geterrmode+0x9c>
lea    0xe79(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,1),%eax
add    $0x1,%eax
jmp    11c1 <geterrmode+0xa1>
xor    %eax,%eax
jmp    11c1 <geterrmode+0xa1>
mov    $0x1,%eax
jmp    11c1 <geterrmode+0xa1>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"never\00"
@.str.1 = [5 x i8] c"once\00"
@.str.2 = [7 x i8] c"always\00"
@.str.3 = [6 x i8] c"fatal\00"
define i32 @geterrmode(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 0, i32* %2
br label %48
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %2
br label %48
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 2, i32* %2
br label %48
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 3, i32* %2
br label %48
47: ; preds = %42
store i32 1, i32* %2
br label %48
48: ; preds = %47, %46, %41, %36, %31
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [6 x i8] c"never\00"
@.str.1 = [5 x i8] c"once\00"
@.str.2 = [7 x i8] c"always\00"
@.str.3 = [6 x i8] c"fatal\00"
define i32 @geterrmode(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = phi i8 [ %11, %4 ], [ %2, %1 ]
%7 = phi i8* [ %10, %4 ], [ %0, %1 ]
%8 = tail call signext i8 @tolower(i8 signext %6)
store i8 %8, i8* %7
%9 = add nuw i64 %5, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %1
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i32 3, i32 1
br label %26
26: ; preds = %22, %19, %16, %13
%27 = phi i32 [ 0, %13 ], [ 1, %16 ], [ 2, %19 ], [ %25, %22 ]
ret i32 %27
}