#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 DesDec(unsigned char *, int, char *, int *);
int DesEnc(char *, int, unsigned char *, int *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int main() {
  int ret = 0;
  char *plain = "1232343444";
  int plainlen = strlen(plain);
  char plain2[4096] = {0};
  int plainlen2 = 0;
  unsigned char cryptbuf[4096] = {0};
  int cryptlen = 0;
  ret = DesEnc(plain, plainlen, cryptbuf, &cryptlen);
  if (ret != 0) {
    printf("func DesEnc() err:%d \n");
    return ret;
  }
  ret = DesDec(cryptbuf, cryptlen, plain2, &plainlen2);
  if (ret != 0) {
    printf("func DesDec() err:%d \n");
    return ret;
  }
  if (plainlen != plainlen2) {
    ret = -2;
    printf("Ã÷ÎÄ³¤¶ÈºÍ½âÃÜºóµÄÃ÷ÎÄ³¤¶È ²»Ò»Ñù \n");
    return ret;
  }
  if (memcmp(plain2, plain, plainlen) == 0)
    printf("Ã÷ÎÄ³¤¶ÈºÍ½âÃÜºóµÄÃ÷ÎÄ³¤¶È Ò»Ñù ok \n");
  else
    printf("Ã÷ÎÄ³¤¶ÈºÍ½âÃÜºóµÄÃ÷ÎÄ³¤¶È ²»Ò»Ñù err \n");
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
movl   $0x0,-0x1024(%rbp)
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
movl   $0x0,-0x2034(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x2030(%rbp),%rdx
lea    -0x2034(%rbp),%rcx
call   1040 <DesEnc@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1208 <main+0xa8>
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b9 <main+0x159>
lea    -0x2030(%rbp),%rdi
mov    -0x2034(%rbp),%esi
lea    -0x1020(%rbp),%rdx
lea    -0x1024(%rbp),%rcx
call   1060 <DesDec@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     124c <main+0xec>
lea    0xde6(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b9 <main+0x159>
mov    -0x14(%rbp),%eax
cmp    -0x1024(%rbp),%eax
je     1279 <main+0x119>
movl   $0xfffffffe,-0x8(%rbp)
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b9 <main+0x159>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    12a7 <main+0x147>
lea    0xde0(%rip),%rdi
call   1050 <printf@plt>
jmp    12b3 <main+0x153>
lea    0xe12(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2010,%rsp
lea    0xe7e(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0x10(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1080 <memset@plt>
movl   $0x0,0xc(%rsp)
lea    0x1010(%rsp),%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
movl   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rcx
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1050 <DesEnc@plt>
test   %eax,%eax
je     11ec <main+0x7c>
mov    %eax,%ebp
lea    0xe26(%rip),%rdi
call   1060 <printf@plt>
jmp    1265 <main+0xf5>
mov    0x8(%rsp),%esi
lea    0x1010(%rsp),%rdi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1070 <DesDec@plt>
test   %eax,%eax
je     121b <main+0xab>
mov    %eax,%ebp
lea    0xe0e(%rip),%rdi
call   1060 <printf@plt>
jmp    1265 <main+0xf5>
cmp    0xc(%rsp),%r14d
jne    1244 <main+0xd4>
lea    0xdd7(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %r14d,%edx
call   1090 <memcmp@plt>
test   %rax,%rax
je     1257 <main+0xe7>
lea    0xdf7(%rip),%rdi
jmp    125e <main+0xee>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffe,%ebp
jmp    1265 <main+0xf5>
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x2010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1232343444\00"
@.str.1 = [23 x i8] c"func DesEnc() err:%d \0A\00"
@.str.2 = [23 x i8] c"func DesDec() err:%d \0A\00"
@.str.3 = [68 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C2\B2\C2\BB\C3\92\C2\BB\C3\91\C3\B9 \0A\00"
@.str.4 = [67 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C3\92\C2\BB\C3\91\C3\B9 ok \0A\00"
@.str.5 = [72 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C2\B2\C2\BB\C3\92\C2\BB\C3\91\C3\B9 err \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [4096 x i8]
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %4
%11 = bitcast [4096 x i8]* %5 to i8*
store i32 0, i32* %6
%12 = bitcast [4096 x i8]* %7 to i8*
store i32 0, i32* %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%16 = call i32 @DesEnc(i8* %13, i32 %14, i8* %15, i32* %8)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %2
store i32 %21, i32* %1
br label %51
22: ; preds = %0
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* %8
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%26 = call i32 @DesDec(i8* %23, i32 %24, i8* %25, i32* %6)
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %2
store i32 %31, i32* %1
br label %51
32: ; preds = %22
%33 = load i32, i32* %4
%34 = load i32, i32* %6
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
store i32 -2, i32* %2
%37 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* %2
store i32 %38, i32* %1
br label %51
39: ; preds = %32
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%41 = load i8*, i8** %3
%42 = load i32, i32* %4
%43 = call i64 @memcmp(i8* %40, i8* %41, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
br label %49
47: ; preds = %39
%48 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
%50 = load i32, i32* %2
store i32 %50, i32* %1
br label %51
51: ; preds = %49, %36, %29, %19
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [11 x i8] c"1232343444\00"
@.str.1 = [23 x i8] c"func DesEnc() err:%d \0A\00"
@.str.2 = [23 x i8] c"func DesDec() err:%d \0A\00"
@str = [71 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C2\B2\C2\BB\C3\92\C2\BB\C3\91\C3\B9 err \00"
@str.6 = [66 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C3\92\C2\BB\C3\91\C3\B9 ok \00"
@str.7 = [67 x i8] c"\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88\C2\BA\C3\8D\C2\BD\C3\A2\C3\83\C3\9C\C2\BA\C3\B3\C2\B5\C3\84\C3\83\C3\B7\C3\8E\C3\84\C2\B3\C2\A4\C2\B6\C3\88 \C2\B2\C2\BB\C3\92\C2\BB\C3\91\C3\B9 \00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca i32
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = call i32 @DesEnc(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %8, i32* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %32
14: ; preds = %0
%15 = load i32, i32* %4
%16 = call i32 @DesDec(i8* %8, i32 %15, i8* %6, i32* %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %32
20: ; preds = %14
%21 = load i32, i32* %2
%22 = icmp eq i32 %5, %21
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.7, i64 0, i64 0))
br label %32
25: ; preds = %20
%26 = call i64 @memcmp(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.6, i64 0, i64 0))
br label %32
30: ; preds = %25
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %28, %30, %23, %18, %12
%33 = phi i32 [ %10, %12 ], [ %16, %18 ], [ -2, %23 ], [ 0, %30 ], [ 0, %28 ]
ret i32 %33
}