#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*/ _fDes(int, unsigned char *, unsigned char *,
                         unsigned char *);
void _vDes(unsigned int uiMode, unsigned char *psSource, unsigned char *psKey,
           unsigned char *psResult) {
  unsigned char sBuf[8];
  switch (uiMode) {
  case 1:
  case 2:
    _fDes((char)uiMode, (unsigned char *)psSource, (unsigned char *)psKey,
          psResult);
    break;
  case 3:
    _fDes(1, (unsigned char *)psSource, (unsigned char *)psKey, psResult);
    _fDes(2, (unsigned char *)psResult, (unsigned char *)psKey + 8, sBuf);
    _fDes(1, (unsigned char *)sBuf, (unsigned char *)psKey, psResult);
    break;
  case 4:
    _fDes(2, (unsigned char *)psSource, (unsigned char *)psKey, psResult);
    _fDes(1, (unsigned char *)psResult, (unsigned char *)psKey + 8, sBuf);
    _fDes(2, (unsigned char *)sBuf, (unsigned char *)psKey, psResult);
    break;
  }
}


x86 assembly (clang, -O0):
<_vDes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     1160 <_vDes+0x50>
jmp    113e <_vDes+0x2e>
mov    -0x2c(%rbp),%eax
sub    $0x3,%eax
je     117c <_vDes+0x6c>
jmp    114f <_vDes+0x3f>
mov    -0x2c(%rbp),%eax
sub    $0x4,%eax
je     11c7 <_vDes+0xb7>
jmp    120d <_vDes+0xfd>
mov    -0x4(%rbp),%eax
movsbl %al,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <_fDes@plt>
jmp    120d <_vDes+0xfd>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%edi
call   1030 <_fDes@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
lea    -0x28(%rbp),%rcx
mov    $0x2,%edi
call   1030 <_fDes@plt>
lea    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%edi
call   1030 <_fDes@plt>
jmp    120d <_vDes+0xfd>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x2,%edi
call   1030 <_fDes@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
lea    -0x28(%rbp),%rcx
mov    $0x1,%edi
call   1030 <_fDes@plt>
lea    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x2,%edi
call   1030 <_fDes@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vDes>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
lea    -0x1(%rdi),%eax
cmp    $0x2,%eax
jb     1165 <_vDes+0x55>
cmp    $0x3,%edi
je     1179 <_vDes+0x69>
cmp    $0x4,%edi
jne    11b5 <_vDes+0xa5>
mov    $0x2,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <_fDes@plt>
lea    0x8(%rbx),%rdx
lea    0x8(%rsp),%r15
mov    $0x1,%edi
mov    %r14,%rsi
mov    %r15,%rcx
call   1030 <_fDes@plt>
mov    $0x2,%edi
jmp    11a7 <_vDes+0x97>
mov    %rbx,%rdx
mov    %r14,%rcx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <_fDes@plt>
mov    $0x1,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <_fDes@plt>
lea    0x8(%rbx),%rdx
lea    0x8(%rsp),%r15
mov    $0x2,%edi
mov    %r14,%rsi
mov    %r15,%rcx
call   1030 <_fDes@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <_fDes@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @_vDes(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [8 x i8]
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
switch i32 %0, label %19 [
i32 1, label %7
i32 2, label %7
i32 3, label %9
i32 4, label %14
]
7: ; preds = %4, %4
%8 = tail call i32 @_fDes(i32 %0, i8* %1, i8* %2, i8* %3)
br label %19
9: ; preds = %4
%10 = tail call i32 @_fDes(i32 1, i8* %1, i8* %2, i8* %3)
%11 = getelementptr inbounds i8, i8* %2, i64 8
%12 = call i32 @_fDes(i32 2, i8* %3, i8* %11, i8* %6)
%13 = call i32 @_fDes(i32 1, i8* %6, i8* %2, i8* %3)
br label %19
14: ; preds = %4
%15 = tail call i32 @_fDes(i32 2, i8* %1, i8* %2, i8* %3)
%16 = getelementptr inbounds i8, i8* %2, i64 8
%17 = call i32 @_fDes(i32 1, i8* %3, i8* %16, i8* %6)
%18 = call i32 @_fDes(i32 2, i8* %6, i8* %2, i8* %3)
br label %19
19: ; preds = %4, %14, %9, %7
ret void
}