#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__ strcasestr(char const *, char *);
int parse_machine(const char *string, int *machine) {
  if (strcasestr(string, "166"))
    *machine = 0x000001;
  else if (strcasestr(string, "pdp6"))
    *machine = 0x000001;
  else if (strcasestr(string, "KA"))
    *machine = 0x000002;
  else if (strcasestr(string, "KI"))
    *machine = 0x000008;
  else if (strcasestr(string, "KL"))
    *machine = 0x000010 | 0x000040;
  else if (strcasestr(string, "KS"))
    *machine = 0x000080;
  else
    return -1;
  if (strcasestr(string, "ITS")) {
    if (*machine & 0x000002)
      *machine = 0x000004;
    if (*machine & 0x000010)
      *machine = 0x000020;
    if (*machine & 0x000080)
      *machine = 0x000100;
  }
  if (strcasestr(string, "SAIL")) {
    if (*machine & 0x000002)
      *machine = 0x100000;
    if (*machine & 0x000010)
      *machine = 0x200000;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_machine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     1149 <parse_machine+0x39>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    123b <parse_machine+0x12b>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     1172 <parse_machine+0x62>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1236 <parse_machine+0x126>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     119b <parse_machine+0x8b>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    1231 <parse_machine+0x121>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     11c4 <parse_machine+0xb4>
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
jmp    122c <parse_machine+0x11c>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     11ed <parse_machine+0xdd>
mov    -0x18(%rbp),%rax
movl   $0x50,(%rax)
jmp    1227 <parse_machine+0x117>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     1216 <parse_machine+0x106>
mov    -0x18(%rbp),%rax
movl   $0x80,(%rax)
jmp    1222 <parse_machine+0x112>
movl   $0xffffffff,-0x4(%rbp)
jmp    130e <parse_machine+0x1fe>
jmp    1227 <parse_machine+0x117>
jmp    122c <parse_machine+0x11c>
jmp    1231 <parse_machine+0x121>
jmp    1236 <parse_machine+0x126>
jmp    123b <parse_machine+0x12b>
mov    -0x10(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     12b0 <parse_machine+0x1a0>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1271 <parse_machine+0x161>
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     128d <parse_machine+0x17d>
mov    -0x18(%rbp),%rax
movl   $0x20,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     12ab <parse_machine+0x19b>
mov    -0x18(%rbp),%rax
movl   $0x100,(%rax)
jmp    12b0 <parse_machine+0x1a0>
mov    -0x10(%rbp),%rdi
lea    0xd5e(%rip),%rsi
call   1030 <strcasestr@plt>
cmp    $0x0,%rax
je     1307 <parse_machine+0x1f7>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     12e6 <parse_machine+0x1d6>
mov    -0x18(%rbp),%rax
movl   $0x100000,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1302 <parse_machine+0x1f2>
mov    -0x18(%rbp),%rax
movl   $0x200000,(%rax)
jmp    1307 <parse_machine+0x1f7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_machine>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strcasestr@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11a8 <parse_machine+0x98>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
test   %rax,%rax
jne    11a8 <parse_machine+0x98>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
mov    $0x2,%ebp
test   %rax,%rax
jne    11a8 <parse_machine+0x98>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
mov    $0x8,%ebp
test   %rax,%rax
jne    11a8 <parse_machine+0x98>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
mov    $0x50,%ebp
test   %rax,%rax
jne    11a8 <parse_machine+0x98>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
mov    $0x80,%ebp
test   %rax,%rax
je     1218 <parse_machine+0x108>
mov    %ebp,(%r14)
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
test   %rax,%rax
je     11e0 <parse_machine+0xd0>
mov    (%r14),%eax
mov    $0x4,%ecx
test   $0x2,%al
jne    11dd <parse_machine+0xcd>
mov    $0x20,%ecx
test   $0x10,%al
jne    11dd <parse_machine+0xcd>
mov    $0x100,%ecx
test   $0x80,%al
je     11e0 <parse_machine+0xd0>
mov    %ecx,(%r14)
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasestr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1213 <parse_machine+0x103>
mov    (%r14),%edx
mov    $0x100000,%ecx
test   $0x2,%dl
jne    1210 <parse_machine+0x100>
mov    $0x200000,%ecx
test   $0x10,%dl
je     1213 <parse_machine+0x103>
mov    %ecx,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%eax
jmp    1213 <parse_machine+0x103>

LLVM IR (-O0):
@.str = [4 x i8] c"166\00"
@.str.1 = [5 x i8] c"pdp6\00"
@.str.2 = [3 x i8] c"KA\00"
@.str.3 = [3 x i8] c"KI\00"
@.str.4 = [3 x i8] c"KL\00"
@.str.5 = [3 x i8] c"KS\00"
@.str.6 = [4 x i8] c"ITS\00"
@.str.7 = [5 x i8] c"SAIL\00"
define i32 @parse_machine(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = call i64 @strcasestr(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32*, i32** %5
store i32 1, i32* %10
br label %47
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i64 @strcasestr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i32*, i32** %5
store i32 1, i32* %16
br label %46
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i64 @strcasestr(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32*, i32** %5
store i32 2, i32* %22
br label %45
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i64 @strcasestr(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32*, i32** %5
store i32 8, i32* %28
br label %44
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = call i64 @strcasestr(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32*, i32** %5
store i32 80, i32* %34
br label %43
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = call i64 @strcasestr(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32*, i32** %5
store i32 128, i32* %40
br label %42
41: ; preds = %35
store i32 -1, i32* %3
br label %93
42: ; preds = %39
br label %43
43: ; preds = %42, %33
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44, %21
br label %46
46: ; preds = %45, %15
br label %47
47: ; preds = %46, %9
%48 = load i8*, i8** %4
%49 = call i64 @strcasestr(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %73
51: ; preds = %47
%52 = load i32*, i32** %5
%53 = load i32, i32* %52
%54 = and i32 %53, 2
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = load i32*, i32** %5
store i32 4, i32* %57
br label %58
58: ; preds = %56, %51
%59 = load i32*, i32** %5
%60 = load i32, i32* %59
%61 = and i32 %60, 16
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = load i32*, i32** %5
store i32 32, i32* %64
br label %65
65: ; preds = %63, %58
%66 = load i32*, i32** %5
%67 = load i32, i32* %66
%68 = and i32 %67, 128
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = load i32*, i32** %5
store i32 256, i32* %71
br label %72
72: ; preds = %70, %65
br label %73
73: ; preds = %72, %47
%74 = load i8*, i8** %4
%75 = call i64 @strcasestr(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %92
77: ; preds = %73
%78 = load i32*, i32** %5
%79 = load i32, i32* %78
%80 = and i32 %79, 2
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = load i32*, i32** %5
store i32 1048576, i32* %83
br label %84
84: ; preds = %82, %77
%85 = load i32*, i32** %5
%86 = load i32, i32* %85
%87 = and i32 %86, 16
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %84
%90 = load i32*, i32** %5
store i32 2097152, i32* %90
br label %91
91: ; preds = %89, %84
br label %92
92: ; preds = %91, %73
store i32 0, i32* %3
br label %93
93: ; preds = %92, %41
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
@.str = [4 x i8] c"166\00"
@.str.1 = [5 x i8] c"pdp6\00"
@.str.2 = [3 x i8] c"KA\00"
@.str.3 = [3 x i8] c"KI\00"
@.str.4 = [3 x i8] c"KL\00"
@.str.5 = [3 x i8] c"KS\00"
@.str.6 = [4 x i8] c"ITS\00"
@.str.7 = [5 x i8] c"SAIL\00"
define i32 @parse_machine(i8* %0, i32* nocapture %1) {
%3 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %48, label %20
20: ; preds = %17, %14, %11, %8, %5, %2
%21 = phi i32 [ 1, %2 ], [ 1, %5 ], [ 2, %8 ], [ 8, %11 ], [ 80, %14 ], [ 128, %17 ]
store i32 %21, i32* %1
%22 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %36, label %24
24: ; preds = %20
%25 = load i32, i32* %1
%26 = and i32 %25, 2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = and i32 %25, 16
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = and i32 %25, 128
%33 = icmp eq i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31, %28, %24
%35 = phi i32 [ 4, %24 ], [ 32, %28 ], [ 256, %31 ]
store i32 %35, i32* %1
br label %36
36: ; preds = %34, %31, %20
%37 = tail call i64 @strcasestr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %36
%40 = load i32, i32* %1
%41 = and i32 %40, 2
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = and i32 %40, 16
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43, %39
%47 = phi i32 [ 1048576, %39 ], [ 2097152, %43 ]
store i32 %47, i32* %1
br label %48
48: ; preds = %46, %36, %43, %17
%49 = phi i32 [ -1, %17 ], [ 0, %43 ], [ 0, %36 ], [ 0, %46 ]
ret i32 %49
}