#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 *mmGetPtr(char *, char);
char *strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
int mmDelEntry(char *path, char key, char *type, char *value) {
  char *shmptr = mmGetPtr(path, key);
  char *ePtr, *ptr;
  int size = *(int *)shmptr;
  shmptr += sizeof(int);
  ePtr = ptr = shmptr;
  while (ePtr < (shmptr + size)) {
    if (!(*(int *)ePtr))
      break;
    ptr = ePtr + sizeof(int);
    if (!strcmp(ptr, type)) {
      if (value == NULL) {
        *ptr = 'u';
        *(ptr + 1) = '\0';
      } else if (!strcmp(strchr(ptr, '\0') + 1, value)) {
        *ptr = 'u';
        *(ptr + 1) = '\0';
      }
    }
    ePtr = ePtr + (*(int *)ePtr);
  }
  return 1;
}


x86 assembly (clang, -O0):
<mmDelEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1050 <mmGetPtr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    123b <mmDelEntry+0x10b>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11a6 <mmDelEntry+0x76>
jmp    123b <mmDelEntry+0x10b>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1224 <mmDelEntry+0xf4>
cmpq   $0x0,-0x20(%rbp)
jne    11e7 <mmDelEntry+0xb7>
mov    -0x38(%rbp),%rax
movb   $0x75,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    121f <mmDelEntry+0xef>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121a <mmDelEntry+0xea>
mov    -0x38(%rbp),%rax
movb   $0x75,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    121f <mmDelEntry+0xef>
jmp    1224 <mmDelEntry+0xf4>
mov    -0x30(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    117c <mmDelEntry+0x4c>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmDelEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
call   1050 <mmGetPtr@plt>
mov    %rax,%rbx
movslq (%rax),%rax
test   %rax,%rax
jle    11ac <mmDelEntry+0x7c>
lea    (%rax,%rbx,1),%r13
add    $0x4,%r13
add    $0x4,%rbx
jmp    116e <mmDelEntry+0x3e>
nop
movw   $0x75,0x4(%rbx)
add    %rbp,%rbx
cmp    %r13,%rbx
jae    11ac <mmDelEntry+0x7c>
movslq (%rbx),%rbp
test   %rbp,%rbp
je     11ac <mmDelEntry+0x7c>
lea    0x4(%rbx),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1166 <mmDelEntry+0x36>
test   %r14,%r14
je     1160 <mmDelEntry+0x30>
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x5,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1166 <mmDelEntry+0x36>
jmp    1160 <mmDelEntry+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mmDelEntry(i8* %0, i8 signext %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%13 = load i8*, i8** %5
%14 = load i8, i8* %6
%15 = call i8* @mmGetPtr(i8* %13, i8 signext %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17
store i32 %18, i32* %12
%19 = load i8*, i8** %9
%20 = getelementptr inbounds i8, i8* %19, i64 4
store i8* %20, i8** %9
%21 = load i8*, i8** %9
store i8* %21, i8** %11
store i8* %21, i8** %10
br label %22
22: ; preds = %62, %4
%23 = load i8*, i8** %10
%24 = load i8*, i8** %9
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = icmp ult i8* %23, %27
br i1 %28, label %29, label %69
29: ; preds = %22
%30 = load i8*, i8** %10
%31 = bitcast i8* %30 to i32*
%32 = load i32, i32* %31
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %29
br label %69
35: ; preds = %29
%36 = load i8*, i8** %10
%37 = getelementptr inbounds i8, i8* %36, i64 4
store i8* %37, i8** %11
%38 = load i8*, i8** %11
%39 = load i8*, i8** %7
%40 = call i32 @strcmp(i8* %38, i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %62, label %42
42: ; preds = %35
%43 = load i8*, i8** %8
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i8*, i8** %11
store i8 117, i8* %46
%47 = load i8*, i8** %11
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8 0, i8* %48
br label %61
49: ; preds = %42
%50 = load i8*, i8** %11
%51 = call i8* @strchr(i8* %50, i8 signext 0)
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = load i8*, i8** %8
%54 = call i32 @strcmp(i8* %52, i8* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %49
%57 = load i8*, i8** %11
store i8 117, i8* %57
%58 = load i8*, i8** %11
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8 0, i8* %59
br label %60
60: ; preds = %56, %49
br label %61
61: ; preds = %60, %45
br label %62
62: ; preds = %61, %35
%63 = load i8*, i8** %10
%64 = load i8*, i8** %10
%65 = bitcast i8* %64 to i32*
%66 = load i32, i32* %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %63, i64 %67
store i8* %68, i8** %10
br label %22
69: ; preds = %34, %22
ret i32 1
}

LLVM IR (-O2):
define i32 @mmDelEntry(i8* %0, i8 signext %1, i8* nocapture %2, i8* %3) {
%5 = tail call i8* @mmGetPtr(i8* %0, i8 signext %1)
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
%8 = sext i32 %7 to i64
%9 = add nsw i64 %8, 4
%10 = getelementptr inbounds i8, i8* %5, i64 %9
%11 = icmp sgt i32 %7, 0
br i1 %11, label %12, label %37
12: ; preds = %4
%13 = getelementptr inbounds i8, i8* %5, i64 4
%14 = icmp eq i8* %3, null
br label %15
15: ; preds = %12, %33
%16 = phi i8* [ %13, %12 ], [ %35, %33 ]
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %37, label %20
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %16, i64 4
%22 = tail call i32 @strcmp(i8* %21, i8* dereferenceable(1) %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %20
br i1 %14, label %31, label %25
25: ; preds = %24
%26 = tail call i64 @strlen(i8* %21)
%27 = getelementptr i8, i8* %16, i64 5
%28 = getelementptr inbounds i8, i8* %27, i64 %26
%29 = tail call i32 @strcmp(i8* %28, i8* %3)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25, %24
store i8 117, i8* %21
%32 = getelementptr inbounds i8, i8* %16, i64 5
store i8 0, i8* %32
br label %33
33: ; preds = %31, %25, %20
%34 = sext i32 %18 to i64
%35 = getelementptr inbounds i8, i8* %16, i64 %34
%36 = icmp ult i8* %35, %10
br i1 %36, label %15, label %37
37: ; preds = %33, %15, %4
ret i32 1
}