#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 *);
unsigned short int isvalue(char string[1000]) {
  unsigned short int ret = 0;
  char val_a[1000] = "a";
  char val_b[1000] = "b";
  char val_c[1000] = "c";
  char val_d[1000] = "d";
  if (strcmp(string, val_a) == 0)
    ret = 1;
  else if (strcmp(string, val_b) == 0)
    ret = 2;
  else if (strcmp(string, val_c) == 0)
    ret = 3;
  else if (strcmp(string, val_d) == 0)
    ret = 4;
  else
    ret = 0;
  return ret;
}


x86 assembly (clang, -O0):
<isvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1030 <memset@plt>
movb   $0x61,-0x400(%rbp)
lea    -0x7f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1030 <memset@plt>
movb   $0x62,-0x7f0(%rbp)
lea    -0xbe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1030 <memset@plt>
movb   $0x63,-0xbe0(%rbp)
lea    -0xfd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1030 <memset@plt>
movb   $0x64,-0xfd0(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <isvalue+0xa2>
movw   $0x1,-0xa(%rbp)
jmp    1246 <isvalue+0x126>
mov    -0x8(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e7 <isvalue+0xc7>
movw   $0x2,-0xa(%rbp)
jmp    1241 <isvalue+0x121>
mov    -0x8(%rbp),%rdi
lea    -0xbe0(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <isvalue+0xec>
movw   $0x3,-0xa(%rbp)
jmp    123c <isvalue+0x11c>
mov    -0x8(%rbp),%rdi
lea    -0xfd0(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <isvalue+0x111>
movw   $0x4,-0xa(%rbp)
jmp    1237 <isvalue+0x117>
movw   $0x0,-0xa(%rbp)
jmp    123c <isvalue+0x11c>
jmp    1241 <isvalue+0x121>
jmp    1246 <isvalue+0x126>
movzwl -0xa(%rbp),%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isvalue>:
push   %r14
push   %rbx
sub    $0xfb8,%rsp
mov    %rdi,%rbx
lea    0xbd0(%rsp),%r14
mov    $0x3e8,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
movb   $0x61,0xbd0(%rsp)
61
lea    0x7e0(%rsp),%rdi
mov    $0x3e8,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movb   $0x62,0x7e0(%rsp)
62
lea    0x3f0(%rsp),%rdi
mov    $0x3e8,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movb   $0x63,0x3f0(%rsp)
63
mov    %rsp,%rdi
mov    $0x3e8,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movb   $0x64,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ec <isvalue+0xcc>
lea    0x7e0(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f2 <isvalue+0xd2>
lea    0x3f0(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f8 <isvalue+0xd8>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
shl    $0x2,%eax
jmp    11fc <isvalue+0xdc>
mov    $0x1,%ax
jmp    11fc <isvalue+0xdc>
mov    $0x2,%ax
jmp    11fc <isvalue+0xdc>
mov    $0x3,%ax
add    $0xfb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i16 @isvalue(i8* %0) {
%2 = alloca i8*
%3 = alloca i16
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
store i8* %0, i8** %2
store i16 0, i16* %3
%8 = bitcast [1000 x i8]* %4 to i8*
%9 = bitcast i8* %8 to [1000 x i8]*
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i32 0, i32 0
store i8 97, i8* %10
%11 = bitcast [1000 x i8]* %5 to i8*
%12 = bitcast i8* %11 to [1000 x i8]*
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i32 0, i32 0
store i8 98, i8* %13
%14 = bitcast [1000 x i8]* %6 to i8*
%15 = bitcast i8* %14 to [1000 x i8]*
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %15, i32 0, i32 0
store i8 99, i8* %16
%17 = bitcast [1000 x i8]* %7 to i8*
%18 = bitcast i8* %17 to [1000 x i8]*
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i32 0, i32 0
store i8 100, i8* %19
%20 = load i8*, i8** %2
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %1
store i16 1, i16* %3
br label %47
25: ; preds = %1
%26 = load i8*, i8** %2
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i16 2, i16* %3
br label %46
31: ; preds = %25
%32 = load i8*, i8** %2
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%34 = call i64 @strcmp(i8* %32, i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31
store i16 3, i16* %3
br label %45
37: ; preds = %31
%38 = load i8*, i8** %2
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%40 = call i64 @strcmp(i8* %38, i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i16 4, i16* %3
br label %44
43: ; preds = %37
store i16 0, i16* %3
br label %44
44: ; preds = %43, %42
br label %45
45: ; preds = %44, %36
br label %46
46: ; preds = %45, %30
br label %47
47: ; preds = %46, %24
%48 = load i16, i16* %3
ret i16 %48
}

LLVM IR (-O2):
define zeroext i16 @isvalue(i8* %0) {
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
store i8 97, i8* %6
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
store i8 98, i8* %7
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
store i8 99, i8* %8
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
store i8 100, i8* %9
%10 = call i64 @strcmp(i8* %0, i8* %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %1
%13 = call i64 @strcmp(i8* %0, i8* %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = call i64 @strcmp(i8* %0, i8* %8)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = call i64 @strcmp(i8* %0, i8* %9)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i16 4, i16 0
br label %22
22: ; preds = %18, %15, %12, %1
%23 = phi i16 [ 1, %1 ], [ 2, %12 ], [ 3, %15 ], [ %21, %18 ]
ret i16 %23
}