#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 */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strncmp(char *, char *, int);
void checkmsg(char *msg, char *cok, int nspecial, float flip, int debug) {
  nspecial = 0;
  flip = 1.0;
  cok = "   ";
  int msgindicate = 22;
  int i;
  for (i = 22; i > 0; i--) {
    if (debug) {
      printf("%d\n", i);
    }
    if (msg[i] != ' ') {
      if (debug) {
        printf("No Space, finish loop\n");
      }
      msgindicate = i;
      i = 0;
    }
  }
  printf(" 	 message: %s\n", msg);
  if ((msgindicate >= 11) && (strncmp(&msg[msgindicate - 3], " OOO", 4)) == 0 ||
      (strncmp(&msg[20], " OO", 3)) == 0) {
    cok = "OOO";
    flip = -1.0;
    if (strncmp(&msg[20], " OO", 3)) {
      memcpy(msg, &msg[1], 19);
    } else {
      printf("Hit else");
      memcpy(msg, &msg[0], msgindicate - 4);
    }
  }
  if (strncmp(&msg[0], "ATT", 3) == 0) {
    nspecial = 1;
  }
  if (strncmp(&msg[0], "RO", 2) == 0) {
    nspecial = 2;
  }
  if (strncmp(&msg[0], "RRR", 3) == 0) {
    nspecial = 3;
  }
  if (strncmp(&msg[0], "73", 2) == 0) {
    nspecial = 4;
  }
  printf("compared: %d\nnspecial = %d\n", strncmp(&msg[0], "73", 2), nspecial);
}


x86 assembly (clang, -O0):
<checkmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movss  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movss  0xea6(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x16,-0x20(%rbp)
movl   $0x16,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11ea <checkmsg+0xba>
cmpl   $0x0,-0x1c(%rbp)
je     119d <checkmsg+0x6d>
mov    -0x24(%rbp),%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11d7 <checkmsg+0xa7>
cmpl   $0x0,-0x1c(%rbp)
je     11ca <checkmsg+0x9a>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    11dc <checkmsg+0xac>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <checkmsg+0x48>
mov    -0x8(%rbp),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xb,-0x20(%rbp)
jl     122f <checkmsg+0xff>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
cltq
add    %rax,%rdi
lea    0xe17(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1251 <checkmsg+0x121>
mov    -0x8(%rbp),%rdi
add    $0x14,%rdi
lea    0xdfa(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12cc <checkmsg+0x19c>
lea    0xddc(%rip),%rax
mov    %rax,-0x10(%rbp)
movss  0xda0(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x14,%rdi
lea    0xdc0(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     12a6 <checkmsg+0x176>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x13,%edx
call   1050 <memcpy@plt>
jmp    12c7 <checkmsg+0x197>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%edx
sub    $0x4,%edx
call   1050 <memcpy@plt>
jmp    12cc <checkmsg+0x19c>
mov    -0x8(%rbp),%rdi
lea    0xd6e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12f1 <checkmsg+0x1c1>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd4d(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1316 <checkmsg+0x1e6>
movl   $0x2,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd2b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    133b <checkmsg+0x20b>
movl   $0x3,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd0a(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1360 <checkmsg+0x230>
movl   $0x4,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xce5(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkmsg>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r12d
mov    %rdi,%r14
mov    $0x16,%ebx
mov    $0x17,%ebp
lea    0xee9(%rip),%r15
jmp    1183 <checkmsg+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,(%r14,%rbx,1)
jne    11ae <checkmsg+0x6e>
add    $0xffffffffffffffff,%rbx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jbe    11a9 <checkmsg+0x69>
test   %r12d,%r12d
je     1170 <checkmsg+0x30>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x20,(%r14,%rbx,1)
je     1177 <checkmsg+0x37>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
jmp    11ae <checkmsg+0x6e>
mov    $0x16,%ebx
lea    0xe4b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xb,%ebx
jl     11df <checkmsg+0x9f>
lea    -0x3(%rbx),%edi
add    %r14,%rdi
lea    0xe3f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f8 <checkmsg+0xb8>
lea    0x14(%r14),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    123d <checkmsg+0xfd>
lea    0x14(%r14),%rdi
lea    0xe12(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121f <checkmsg+0xdf>
lea    0x1(%r14),%rsi
mov    %r14,%rdi
mov    $0x13,%edx
jmp    1238 <checkmsg+0xf8>
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xfffffffc,%ebx
mov    %r14,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1060 <memcpy@plt>
lea    0xdde(%rip),%rsi
mov    $0x3,%r15d
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
lea    0xdc1(%rip),%rsi
mov    $0x2,%ebp
mov    %r14,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
cmove  %ebp,%ebx
lea    0xda6(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
cmove  %r15d,%ebx
lea    0xd90(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
mov    $0x4,%ebp
cmovne %ebx,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
lea    0xd62(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [23 x i8] c"No Space, finish loop\0A\00"
@.str.3 = [16 x i8] c" \09 message: %s\0A\00"
@.str.4 = [5 x i8] c" OOO\00"
@.str.5 = [4 x i8] c" OO\00"
@.str.6 = [4 x i8] c"OOO\00"
@.str.7 = [9 x i8] c"Hit else\00"
@.str.8 = [4 x i8] c"ATT\00"
@.str.9 = [3 x i8] c"RO\00"
@.str.10 = [4 x i8] c"RRR\00"
@.str.11 = [3 x i8] c"73\00"
@.str.12 = [28 x i8] c"compared: %d\0Anspecial = %d\0A\00"
define void @checkmsg(i8* %0, i8* %1, i32 %2, float %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store float %3, float* %9
store i32 %4, i32* %10
store i32 0, i32* %8
store float 1.000000e+00, float* %9
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 22, i32* %11
store i32 22, i32* %12
br label %13
13: ; preds = %38, %5
%14 = load i32, i32* %12
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %41
16: ; preds = %13
%17 = load i32, i32* %10
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %12
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %16
%23 = load i8*, i8** %6
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 32
br i1 %29, label %30, label %37
30: ; preds = %22
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* %12
store i32 %36, i32* %11
store i32 0, i32* %12
br label %37
37: ; preds = %35, %22
br label %38
38: ; preds = %37
%39 = load i32, i32* %12
%40 = add nsw i32 %39, -1
store i32 %40, i32* %12
br label %13
41: ; preds = %13
%42 = load i8*, i8** %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = load i32, i32* %11
%45 = icmp sge i32 %44, 11
br i1 %45, label %46, label %54
46: ; preds = %41
%47 = load i8*, i8** %6
%48 = load i32, i32* %11
%49 = sub nsw i32 %48, 3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = call i32 @strncmp(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%53 = icmp eq i32 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %46, %41
%55 = load i8*, i8** %6
%56 = getelementptr inbounds i8, i8* %55, i64 20
%57 = call i32 @strncmp(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %78
59: ; preds = %54, %46
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %7
store float -1.000000e+00, float* %9
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i64 20
%62 = call i32 @strncmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %59
%65 = load i8*, i8** %6
%66 = load i8*, i8** %6
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = call i32 @memcpy(i8* %65, i8* %67, i32 19)
br label %77
69: ; preds = %59
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%71 = load i8*, i8** %6
%72 = load i8*, i8** %6
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i32, i32* %11
%75 = sub nsw i32 %74, 4
%76 = call i32 @memcpy(i8* %71, i8* %73, i32 %75)
br label %77
77: ; preds = %69, %64
br label %78
78: ; preds = %77, %54
%79 = load i8*, i8** %6
%80 = getelementptr inbounds i8, i8* %79, i64 0
%81 = call i32 @strncmp(i8* %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %78
store i32 1, i32* %8
br label %84
84: ; preds = %83, %78
%85 = load i8*, i8** %6
%86 = getelementptr inbounds i8, i8* %85, i64 0
%87 = call i32 @strncmp(i8* %86, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %84
store i32 2, i32* %8
br label %90
90: ; preds = %89, %84
%91 = load i8*, i8** %6
%92 = getelementptr inbounds i8, i8* %91, i64 0
%93 = call i32 @strncmp(i8* %92, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %90
store i32 3, i32* %8
br label %96
96: ; preds = %95, %90
%97 = load i8*, i8** %6
%98 = getelementptr inbounds i8, i8* %97, i64 0
%99 = call i32 @strncmp(i8* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %102
101: ; preds = %96
store i32 4, i32* %8
br label %102
102: ; preds = %101, %96
%103 = load i8*, i8** %6
%104 = getelementptr inbounds i8, i8* %103, i64 0
%105 = call i32 @strncmp(i8* %104, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%106 = load i32, i32* %8
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), i32 %105, i32 %106)
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [16 x i8] c" \09 message: %s\0A\00"
@.str.4 = [5 x i8] c" OOO\00"
@.str.5 = [4 x i8] c" OO\00"
@.str.7 = [9 x i8] c"Hit else\00"
@.str.8 = [4 x i8] c"ATT\00"
@.str.9 = [3 x i8] c"RO\00"
@.str.10 = [4 x i8] c"RRR\00"
@.str.11 = [3 x i8] c"73\00"
@.str.12 = [28 x i8] c"compared: %d\0Anspecial = %d\0A\00"
@str = [22 x i8] c"No Space, finish loop\00"
define void @checkmsg(i8* %0, i8* nocapture readnone %1, i32 %2, float %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br label %7
7: ; preds = %5, %22
%8 = phi i32 [ 22, %5 ], [ %23, %22 ]
br i1 %6, label %9, label %14
9: ; preds = %7
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 32
br i1 %13, label %22, label %25
14: ; preds = %7
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%16 = zext i32 %8 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %22, label %20
20: ; preds = %14
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %25
22: ; preds = %9, %14
%23 = add nsw i32 %8, -1
%24 = icmp ugt i32 %8, 1
br i1 %24, label %7, label %25
25: ; preds = %9, %22, %20
%26 = phi i32 [ %8, %20 ], [ %8, %9 ], [ 22, %22 ]
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%28 = icmp sgt i32 %26, 10
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = add nsw i32 %26, -3
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = tail call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%34 = icmp eq i32 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %29, %25
%36 = getelementptr inbounds i8, i8* %0, i64 20
%37 = tail call i32 @strncmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %35, %29
%40 = getelementptr inbounds i8, i8* %0, i64 20
%41 = tail call i32 @strncmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %0, i64 1
%45 = tail call i32 @memcpy(i8* %0, i8* %44, i32 19)
br label %50
46: ; preds = %39
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%48 = add nsw i32 %26, -4
%49 = tail call i32 @memcpy(i8* %0, i8* %0, i32 %48)
br label %50
50: ; preds = %43, %46, %35
%51 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 3)
%52 = icmp eq i32 %51, 0
%53 = zext i1 %52 to i32
%54 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i32 2, i32 %53
%57 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 3)
%58 = icmp eq i32 %57, 0
%59 = select i1 %58, i32 3, i32 %56
%60 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i32 4, i32 %59
%63 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0), i32 %63, i32 %62)
ret void
}