#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 */
typedef int /*<<< orphan*/ sDFQueue;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int _iSelDdfQueueOp(unsigned char ucCmd, unsigned char *pucDdfNameLen,
                    unsigned char *psDdfName) {
  static unsigned char sDFQueue[200];
  static unsigned char ucCurrDFs;
  static int iCurrLength;
  int i;
  switch (ucCmd) {
  case 0:
    ucCurrDFs = 0;
    iCurrLength = 0;
    break;
  case 1:
    if (iCurrLength + *pucDdfNameLen + 1 > sizeof(sDFQueue))
      return (-1);
    sDFQueue[iCurrLength] = *pucDdfNameLen;
    memcpy(&sDFQueue[iCurrLength + 1], psDdfName, (int)(*pucDdfNameLen));
    iCurrLength += *pucDdfNameLen + 1;
    ucCurrDFs++;
    break;
  case 2:
    if (ucCurrDFs == 0)
      return (-1);
    *pucDdfNameLen = sDFQueue[0];
    memcpy(psDdfName, &sDFQueue[1], (int)(*pucDdfNameLen));
    for (i = 0; i < iCurrLength - *pucDdfNameLen - 1; i++)
      sDFQueue[i] = sDFQueue[i + *pucDdfNameLen + 1];
    ucCurrDFs--;
    break;
  case 3:
    return (ucCurrDFs);
  }
  return (0);
}


x86 assembly (clang, -O0):
<_iSelDdfQueueOp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movzbl -0x5(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     12b0 <_iSelDdfQueueOp+0x1a0>
mov    -0x28(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,0x2fb5(%rip)
movl   $0x0,0x2faf(%rip)
jmp    12b0 <_iSelDdfQueueOp+0x1a0>
mov    0x2fa4(%rip),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
add    %ecx,%eax
add    $0x1,%eax
cltq
cmp    $0xc8,%rax
jbe    118e <_iSelDdfQueueOp+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b7 <_iSelDdfQueueOp+0x1a7>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
movslq 0x2f71(%rip),%rcx
lea    0x2e9e(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    0x2f61(%rip),%eax
add    $0x1,%eax
cltq
lea    0x2e89(%rip),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
movzbl (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
add    $0x1,%eax
add    0x2f32(%rip),%eax
mov    %eax,0x2f2c(%rip)
mov    0x2f22(%rip),%al
add    $0x1,%al
mov    %al,0x2f1a(%rip)
jmp    12b0 <_iSelDdfQueueOp+0x1a0>
movzbl 0x2f0e(%rip),%eax
cmp    $0x0,%eax
jne    120f <_iSelDdfQueueOp+0xff>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b7 <_iSelDdfQueueOp+0x1a7>
mov    0x2e2b(%rip),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movzbl (%rax),%edx
lea    0x2e14(%rip),%rsi
call   1030 <memcpy@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2eca(%rip),%ecx
mov    -0x10(%rbp),%rdx
movzbl (%rdx),%edx
sub    %edx,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    128e <_iSelDdfQueueOp+0x17e>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
add    %ecx,%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2dd1(%rip),%rax
mov    (%rax,%rcx,1),%dl
movslq -0x1c(%rbp),%rcx
lea    0x2dc3(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1239 <_iSelDdfQueueOp+0x129>
mov    0x2e74(%rip),%al
add    $0xff,%al
mov    %al,0x2e6c(%rip)
jmp    12b0 <_iSelDdfQueueOp+0x1a0>
movzbl 0x2e60(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    12b7 <_iSelDdfQueueOp+0x1a7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_iSelDdfQueueOp>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x3,%dil
ja     123e <_iSelDdfQueueOp+0x12e>
mov    %rsi,%r14
mov    %edi,%eax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,0x2fcc(%rip)
movl   $0x0,0x2fc6(%rip)
xor    %eax,%eax
jmp    123e <_iSelDdfQueueOp+0x12e>
movslq 0x2fb8(%rip),%rcx
movzbl (%r14),%esi
lea    (%rcx,%rsi,1),%edi
add    $0xffffff38,%edi
mov    $0xffffffff,%eax
cmp    $0xffffff37,%edi
jb     123e <_iSelDdfQueueOp+0x12e>
lea    0x2ec7(%rip),%rax
mov    %sil,(%rcx,%rax,1)
lea    (%rcx,%rax,1),%rdi
add    $0x1,%rdi
movzbl (%r14),%eax
mov    %rdx,%rsi
mov    %eax,%edx
call   1030 <memcpy@plt>
movzbl (%r14),%eax
mov    0x2f6f(%rip),%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,0x2f64(%rip)
addb   $0x1,0x2f59(%rip)
xor    %eax,%eax
jmp    123e <_iSelDdfQueueOp+0x12e>
cmpb   $0x0,0x2f4b(%rip)
je     1239 <_iSelDdfQueueOp+0x129>
movzbl 0x2e7a(%rip),%eax
mov    %al,(%r14)
lea    0x2e71(%rip),%rsi
mov    %rdx,%rdi
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    0x2f2c(%rip),%eax
movzbl (%r14),%ecx
mov    %ecx,%edx
not    %edx
add    %eax,%edx
test   %edx,%edx
jle    1225 <_iSelDdfQueueOp+0x115>
xor    %esi,%esi
lea    0x2e49(%rip),%rdx
nopw   0x0(%rax,%rax,1)
add    %esi,%ecx
add    $0x1,%ecx
movzbl (%rcx,%rdx,1),%ecx
mov    %cl,(%rsi,%rdx,1)
lea    0x1(%rsi),%rdi
movzbl (%r14),%ecx
mov    %ecx,%esi
not    %esi
add    %eax,%esi
movslq %esi,%rbx
mov    %rdi,%rsi
cmp    %rbx,%rdi
jl     1200 <_iSelDdfQueueOp+0xf0>
addb   $0xff,0x2edc(%rip)
xor    %eax,%eax
jmp    123e <_iSelDdfQueueOp+0x12e>
movzbl 0x2ed1(%rip),%eax
jmp    123e <_iSelDdfQueueOp+0x12e>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@_iSelDdfQueueOp.sDFQueue = internal global [200 x i8] zeroinitializer
@_iSelDdfQueueOp.ucCurrDFs = internal global i8 0
@_iSelDdfQueueOp.iCurrLength = internal global i32 0
define i32 @_iSelDdfQueueOp(i8 zeroext %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
switch i32 %10, label %89 [
i32 0, label %11
i32 1, label %12
i32 2, label %45
i32 3, label %86
]
11: ; preds = %3
store i8 0, i8* @_iSelDdfQueueOp.ucCurrDFs
store i32 0, i32* @_iSelDdfQueueOp.iCurrLength
br label %89
12: ; preds = %3
%13 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = add nsw i32 %13, %16
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = icmp ugt i64 %19, 200
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 -1, i32* %4
br label %90
22: ; preds = %12
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %26
store i8 %24, i8* %27
%28 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %30
%32 = load i8*, i8** %7
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 @memcpy(i8* %31, i8* %32, i32 %35)
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = add nsw i32 %39, 1
%41 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%42 = add nsw i32 %41, %40
store i32 %42, i32* @_iSelDdfQueueOp.iCurrLength
%43 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%44 = add i8 %43, 1
store i8 %44, i8* @_iSelDdfQueueOp.ucCurrDFs
br label %89
45: ; preds = %3
%46 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%47 = zext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 -1, i32* %4
br label %90
50: ; preds = %45
%51 = load i8, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 0)
%52 = load i8*, i8** %6
store i8 %51, i8* %52
%53 = load i8*, i8** %7
%54 = load i8*, i8** %6
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 @memcpy(i8* %53, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 1), i32 %56)
store i32 0, i32* %8
br label %58
58: ; preds = %80, %50
%59 = load i32, i32* %8
%60 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%61 = load i8*, i8** %6
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = sub nsw i32 %60, %63
%65 = sub nsw i32 %64, 1
%66 = icmp slt i32 %59, %65
br i1 %66, label %67, label %83
67: ; preds = %58
%68 = load i32, i32* %8
%69 = load i8*, i8** %6
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = add nsw i32 %68, %71
%73 = add nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = load i32, i32* %8
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %78
store i8 %76, i8* %79
br label %80
80: ; preds = %67
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %58
83: ; preds = %58
%84 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%85 = add i8 %84, -1
store i8 %85, i8* @_iSelDdfQueueOp.ucCurrDFs
br label %89
86: ; preds = %3
%87 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%88 = zext i8 %87 to i32
store i32 %88, i32* %4
br label %90
89: ; preds = %3, %83, %22, %11
store i32 0, i32* %4
br label %90
90: ; preds = %89, %86, %49, %21
%91 = load i32, i32* %4
ret i32 %91
}

LLVM IR (-O2):
@_iSelDdfQueueOp.sDFQueue = internal global [200 x i8] zeroinitializer
@_iSelDdfQueueOp.ucCurrDFs = internal unnamed_addr global i8 0
@_iSelDdfQueueOp.iCurrLength = internal unnamed_addr global i32 0
define i32 @_iSelDdfQueueOp(i8 zeroext %0, i8* nocapture %1, i8* %2) {
switch i8 %0, label %63 [
i8 0, label %4
i8 1, label %5
i8 2, label %28
i8 3, label %60
]
4: ; preds = %3
store i8 0, i8* @_iSelDdfQueueOp.ucCurrDFs
store i32 0, i32* @_iSelDdfQueueOp.iCurrLength
br label %63
5: ; preds = %3
%6 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%7 = load i8, i8* %1
%8 = zext i8 %7 to i32
%9 = add i32 %6, -200
%10 = add i32 %9, %8
%11 = icmp ult i32 %10, -201
br i1 %11, label %63, label %12
12: ; preds = %5
%13 = sext i32 %6 to i64
%14 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %13
store i8 %7, i8* %14
%15 = add nsw i32 %6, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %16
%18 = load i8, i8* %1
%19 = zext i8 %18 to i32
%20 = tail call i32 @memcpy(i8* %17, i8* %2, i32 %19)
%21 = load i8, i8* %1
%22 = zext i8 %21 to i32
%23 = add nuw nsw i32 %22, 1
%24 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%25 = add nsw i32 %23, %24
store i32 %25, i32* @_iSelDdfQueueOp.iCurrLength
%26 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%27 = add i8 %26, 1
store i8 %27, i8* @_iSelDdfQueueOp.ucCurrDFs
br label %63
28: ; preds = %3
%29 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%30 = icmp eq i8 %29, 0
br i1 %30, label %63, label %31
31: ; preds = %28
%32 = load i8, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 0)
store i8 %32, i8* %1
%33 = zext i8 %32 to i32
%34 = tail call i32 @memcpy(i8* %2, i8* getelementptr inbounds ([200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 1), i32 %33)
%35 = load i32, i32* @_iSelDdfQueueOp.iCurrLength
%36 = load i8, i8* %1
%37 = zext i8 %36 to i32
%38 = xor i32 %37, -1
%39 = add i32 %35, %38
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %57
41: ; preds = %31, %41
%42 = phi i64 [ %44, %41 ], [ 0, %31 ]
%43 = phi i32 [ %52, %41 ], [ %37, %31 ]
%44 = add nuw nsw i64 %42, 1
%45 = trunc i64 %44 to i32
%46 = add i32 %43, %45
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = getelementptr inbounds [200 x i8], [200 x i8]* @_iSelDdfQueueOp.sDFQueue, i64 0, i64 %42
store i8 %49, i8* %50
%51 = load i8, i8* %1
%52 = zext i8 %51 to i32
%53 = xor i32 %52, -1
%54 = add i32 %35, %53
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %44, %55
br i1 %56, label %41, label %57
57: ; preds = %41, %31
%58 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%59 = add i8 %58, -1
store i8 %59, i8* @_iSelDdfQueueOp.ucCurrDFs
br label %63
60: ; preds = %3
%61 = load i8, i8* @_iSelDdfQueueOp.ucCurrDFs
%62 = zext i8 %61 to i32
br label %63
63: ; preds = %4, %12, %57, %3, %28, %5, %60
%64 = phi i32 [ %62, %60 ], [ -1, %5 ], [ -1, %28 ], [ 0, %3 ], [ 0, %57 ], [ 0, %12 ], [ 0, %4 ]
ret i32 %64
}