#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 uint32_t;
typedef int /*<<< orphan*/ u_char;
struct stat {
  int st_size;
};
typedef int off_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int O_CREAT;
int O_EXCL;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ R_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ btea(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int getpid();
int htonl(int);
int /*<<< orphan*/ memcpy(int *, int /*<<< orphan*/ *, int);
int ntohl(int);
int open(char *, int, ...);
int rand();
int read(int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ srand(int);
int stat(char *, struct stat *);
scalar_t__ time(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int xxtea_decrypt(char *in_file, char *out_file, char *key) {
  extern int errno;
  int c;
  int i;
  int j;
  int sl;
  int first_block = 1;
  int fd_in;
  int fd_out;
  int bl = 0;
  int bytes_read;
  int pad = 0;
  int trnd = 0;
  int uid;
  int use_file = 0;
  uint32_t randpad[16];
  off_t filesize = 0;
  uint32_t filesize_msb = 0;
  uint32_t read_filesize_msb = 0;
  uint32_t read_filesize = 0;
  uint32_t bsf = 0;
  char fb_buffer[64];
  u_char plaintext[64];
  struct stat statbuf;
  if (in_file != NULL) {
    if (-1 == (stat(in_file, &statbuf))) {
      return 1;
    } else {
      filesize = statbuf.st_size;
      filesize_msb = htonl(filesize);
    }
    if (-1 == access(in_file, R_OK)) {
      return 5;
    }
    if (-1 == (fd_in = open(in_file, O_RDONLY))) {
      return 5;
    }
  } else {
    return 1;
  }
  if (-1 == (fd_out = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 00600))) {
    return 4;
  }
  for (i = 0; i < 16; i++) {
    srand(i);
    trnd = rand();
    srand((int)time(0) + getpid() + i + trnd);
    randpad[i] = rand();
  }
  while (first_block) {
    read(fd_in, plaintext, 64);
    btea((int32_t *)plaintext, -16, (int32_t *)key);
    memcpy(&read_filesize_msb, plaintext, 4);
    read_filesize = ntohl(read_filesize_msb);
    pad = (64 - (read_filesize) % 64);
    if (pad < 4) {
      pad += 64;
      i = read_filesize;
    } else {
      i = read_filesize;
    }
    if (filesize != (i + pad)) {
      return 6;
    }
    if (read_filesize >= 60) {
      write(fd_out, (char *)plaintext + 4, 60);
    } else {
      write(fd_out, (char *)plaintext + 4, read_filesize);
    }
    bsf += 64;
    first_block = 0;
  }
  while (0 != (bytes_read = read(fd_in, plaintext, 64))) {
    btea((int32_t *)plaintext, -16, (int32_t *)key);
    bsf += 64;
    if (bsf < (read_filesize + 4) && read_filesize > 64) {
      write(fd_out, (char *)plaintext, 64);
    } else {
      bl = 64 - (bsf - (read_filesize + 4));
      write(fd_out, (char *)plaintext, bl);
    }
  }
  close(fd_out);
  close(fd_in);
  return (0);
}


x86 assembly (clang, -O0):
<xxtea_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1303 <xxtea_decrypt+0x123>
mov    -0x10(%rbp),%rdi
lea    -0x208(%rbp),%rsi
call   10a0 <stat@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1282 <xxtea_decrypt+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
mov    -0x208(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%edi
call   1060 <htonl@plt>
mov    %eax,-0xa8(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
call   10e0 <access@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12cc <xxtea_decrypt+0xec>
movl   $0x5,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
mov    -0x10(%rbp),%rdi
mov    0x2d09(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x38(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12fe <xxtea_decrypt+0x11e>
movl   $0x5,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
jmp    130f <xxtea_decrypt+0x12f>
movl   $0x1,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
mov    -0x18(%rbp),%rdi
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
mov    0x2cd5(%rip),%rax
or     (%rax),%esi
mov    0x2ca4(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x3c(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1358 <xxtea_decrypt+0x178>
movl   $0x4,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jge    13c4 <xxtea_decrypt+0x1e4>
mov    -0x28(%rbp),%edi
call   1090 <srand@plt>
mov    $0x0,%al
call   1100 <rand@plt>
mov    %eax,-0x4c(%rbp)
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,-0x20c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x20c(%rbp),%edi
add    %eax,%edi
add    -0x28(%rbp),%edi
add    -0x4c(%rbp),%edi
call   1090 <srand@plt>
mov    $0x0,%al
call   1100 <rand@plt>
mov    %eax,%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    135f <xxtea_decrypt+0x17f>
jmp    13c9 <xxtea_decrypt+0x1e9>
cmpl   $0x0,-0x34(%rbp)
je     14e5 <xxtea_decrypt+0x305>
mov    -0x38(%rbp),%edi
lea    -0x200(%rbp),%rsi
mov    $0x40,%edx
call   1080 <read@plt>
lea    -0x200(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xfffffff0,%esi
call   1050 <btea@plt>
lea    -0x200(%rbp),%rsi
lea    -0xac(%rbp),%rdi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    -0xac(%rbp),%edi
call   10f0 <ntohl@plt>
mov    %eax,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    $0x40,%eax
sub    %edx,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x4,-0x48(%rbp)
jge    145e <xxtea_decrypt+0x27e>
mov    -0x48(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x48(%rbp)
mov    -0xb0(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1467 <xxtea_decrypt+0x287>
mov    -0xb0(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xa4(%rbp),%eax
mov    -0x28(%rbp),%ecx
add    -0x48(%rbp),%ecx
cmp    %ecx,%eax
je     1487 <xxtea_decrypt+0x2a7>
movl   $0x6,-0x4(%rbp)
jmp    15b7 <xxtea_decrypt+0x3d7>
cmpl   $0x3c,-0xb0(%rbp)
jl     14b1 <xxtea_decrypt+0x2d1>
mov    -0x3c(%rbp),%edi
lea    -0x200(%rbp),%rsi
add    $0x4,%rsi
mov    $0x3c,%edx
call   1030 <write@plt>
jmp    14ca <xxtea_decrypt+0x2ea>
mov    -0x3c(%rbp),%edi
lea    -0x200(%rbp),%rsi
add    $0x4,%rsi
mov    -0xb0(%rbp),%edx
call   1030 <write@plt>
mov    -0xb4(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0xb4(%rbp)
movl   $0x0,-0x34(%rbp)
jmp    13c9 <xxtea_decrypt+0x1e9>
jmp    14ea <xxtea_decrypt+0x30a>
mov    -0x38(%rbp),%edi
lea    -0x200(%rbp),%rsi
mov    $0x40,%edx
call   1080 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     15a0 <xxtea_decrypt+0x3c0>
lea    -0x200(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xfffffff0,%esi
call   1050 <btea@plt>
mov    -0xb4(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    -0xb0(%rbp),%ecx
add    $0x4,%ecx
cmp    %ecx,%eax
jge    156e <xxtea_decrypt+0x38e>
cmpl   $0x40,-0xb0(%rbp)
jle    156e <xxtea_decrypt+0x38e>
mov    -0x3c(%rbp),%edi
lea    -0x200(%rbp),%rsi
mov    $0x40,%edx
call   1030 <write@plt>
jmp    159b <xxtea_decrypt+0x3bb>
mov    -0xb4(%rbp),%ecx
mov    -0xb0(%rbp),%eax
add    $0x4,%eax
sub    %eax,%ecx
mov    $0x40,%eax
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x200(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   1030 <write@plt>
jmp    14ea <xxtea_decrypt+0x30a>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    -0x38(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xxtea_decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
movl   $0x0,0x4(%rsp)
mov    $0x1,%ebx
test   %rdi,%rdi
je     1415 <xxtea_decrypt+0x235>
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
je     1415 <xxtea_decrypt+0x235>
mov    0x8(%rsp),%r15d
mov    %r15d,%edi
call   1060 <htonl@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10e0 <access@plt>
mov    $0x5,%ebx
cmp    $0xffffffff,%eax
je     1415 <xxtea_decrypt+0x235>
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1415 <xxtea_decrypt+0x235>
mov    %eax,%r12d
mov    0x2d43(%rip),%rax
mov    0x2d7c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d49(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
mov    $0x180,%edx
xor    %eax,%eax
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1410 <xxtea_decrypt+0x230>
mov    %eax,%r14d
mov    %r15d,(%rsp)
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1090 <srand@plt>
xor    %eax,%eax
call   1100 <rand@plt>
mov    %eax,%ebp
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <getpid@plt>
add    %eax,%ebp
add    %r15d,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1090 <srand@plt>
xor    %eax,%eax
call   1100 <rand@plt>
add    $0x1,%ebx
cmp    $0x10,%ebx
jne    12b0 <xxtea_decrypt+0xd0>
lea    0x10(%rsp),%rbx
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1080 <read@plt>
mov    %rbx,%rdi
mov    $0xfffffff0,%esi
mov    %r13,%rdx
call   1050 <btea@plt>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    0x4(%rsp),%edi
call   10f0 <ntohl@plt>
mov    %eax,%ebp
lea    0x3f(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xffffffc0,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
xor    %edx,%edx
cmp    $0x3d,%ecx
setge  %dl
shl    $0x6,%edx
add    %edx,%eax
add    $0x40,%eax
mov    $0x6,%ebx
cmp    %eax,(%rsp)
jne    1415 <xxtea_decrypt+0x235>
lea    0x14(%rsp),%rsi
cmp    $0x3c,%ebp
mov    $0x3c,%edx
cmovl  %ebp,%edx
mov    %r14d,%edi
call   1030 <write@plt>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0x40,%edx
call   1080 <read@plt>
test   %eax,%eax
mov    %r12d,(%rsp)
mov    %r14d,%r12d
je     13fc <xxtea_decrypt+0x21c>
lea    -0x3c(%rbp),%r15d
mov    $0x7c,%r14d
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xfffffff0,%esi
mov    %r13,%rdx
call   1050 <btea@plt>
cmp    %r14d,%ebp
mov    %r15d,%edx
mov    $0x40,%eax
cmovg  %eax,%edx
cmp    $0x41,%ebp
cmovl  %r15d,%edx
mov    %r12d,%edi
mov    %rbx,%rsi
call   1030 <write@plt>
mov    (%rsp),%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1080 <read@plt>
add    $0xffffffc0,%r15d
add    $0x40,%r14d
test   %eax,%eax
jne    13b0 <xxtea_decrypt+0x1d0>
mov    %r12d,%edi
call   1070 <close@plt>
mov    (%rsp),%edi
call   1070 <close@plt>
xor    %ebx,%ebx
jmp    1415 <xxtea_decrypt+0x235>
mov    $0x4,%ebx
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@R_OK = global i32 0
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
define i32 @xxtea_decrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca [16 x i32]
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca [64 x i8]
%28 = alloca [64 x i32]
%29 = alloca %struct.stat
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 1, i32* %12
store i32 0, i32* %15
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %20
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
store i32 0, i32* %25
store i32 0, i32* %26
%30 = load i8*, i8** %5
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %55
32: ; preds = %3
%33 = load i8*, i8** %5
%34 = call i32 @stat(i8* %33, %struct.stat* %29)
%35 = icmp eq i32 -1, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %4
br label %185
37: ; preds = %32
%38 = getelementptr inbounds %struct.stat, %struct.stat* %29, i32 0, i32 0
%39 = load i32, i32* %38
store i32 %39, i32* %22
%40 = load i32, i32* %22
%41 = call i32 @htonl(i32 %40)
store i32 %41, i32* %23
br label %42
42: ; preds = %37
%43 = load i8*, i8** %5
%44 = load i32, i32* @R_OK
%45 = call i32 @access(i8* %43, i32 %44)
%46 = icmp eq i32 -1, %45
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 5, i32* %4
br label %185
48: ; preds = %42
%49 = load i8*, i8** %5
%50 = load i32, i32* @O_RDONLY
%51 = call i32 (i8*, i32, ...) @open(i8* %49, i32 %50)
store i32 %51, i32* %13
%52 = icmp eq i32 -1, %51
br i1 %52, label %53, label %54
53: ; preds = %48
store i32 5, i32* %4
br label %185
54: ; preds = %48
br label %56
55: ; preds = %3
store i32 1, i32* %4
br label %185
56: ; preds = %54
%57 = load i8*, i8** %6
%58 = load i32, i32* @O_WRONLY
%59 = load i32, i32* @O_CREAT
%60 = or i32 %58, %59
%61 = load i32, i32* @O_EXCL
%62 = or i32 %60, %61
%63 = call i32 (i8*, i32, ...) @open(i8* %57, i32 %62, i32 384)
store i32 %63, i32* %14
%64 = icmp eq i32 -1, %63
br i1 %64, label %65, label %66
65: ; preds = %56
store i32 4, i32* %4
br label %185
66: ; preds = %56
store i32 0, i32* %9
br label %67
67: ; preds = %87, %66
%68 = load i32, i32* %9
%69 = icmp slt i32 %68, 16
br i1 %69, label %70, label %90
70: ; preds = %67
%71 = load i32, i32* %9
%72 = call i32 @srand(i32 %71)
%73 = call i32 (...) @rand()
store i32 %73, i32* %18
%74 = call i64 @time(i32 0)
%75 = trunc i64 %74 to i32
%76 = call i32 (...) @getpid()
%77 = add nsw i32 %75, %76
%78 = load i32, i32* %9
%79 = add nsw i32 %77, %78
%80 = load i32, i32* %18
%81 = add nsw i32 %79, %80
%82 = call i32 @srand(i32 %81)
%83 = call i32 (...) @rand()
%84 = load i32, i32* %9
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [16 x i32], [16 x i32]* %21, i64 0, i64 %85
store i32 %83, i32* %86
br label %87
87: ; preds = %70
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
store i32 %89, i32* %9
br label %67
90: ; preds = %67
br label %91
91: ; preds = %140, %90
%92 = load i32, i32* %12
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %143
94: ; preds = %91
%95 = load i32, i32* %13
%96 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%97 = call i32 @read(i32 %95, i32* %96, i32 64)
%98 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%99 = load i8*, i8** %7
%100 = bitcast i8* %99 to i32*
%101 = call i32 @btea(i32* %98, i32 -16, i32* %100)
%102 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%103 = call i32 @memcpy(i32* %24, i32* %102, i32 4)
%104 = load i32, i32* %24
%105 = call i32 @ntohl(i32 %104)
store i32 %105, i32* %25
%106 = load i32, i32* %25
%107 = srem i32 %106, 64
%108 = sub nsw i32 64, %107
store i32 %108, i32* %17
%109 = load i32, i32* %17
%110 = icmp slt i32 %109, 4
br i1 %110, label %111, label %115
111: ; preds = %94
%112 = load i32, i32* %17
%113 = add nsw i32 %112, 64
store i32 %113, i32* %17
%114 = load i32, i32* %25
store i32 %114, i32* %9
br label %117
115: ; preds = %94
%116 = load i32, i32* %25
store i32 %116, i32* %9
br label %117
117: ; preds = %115, %111
%118 = load i32, i32* %22
%119 = load i32, i32* %9
%120 = load i32, i32* %17
%121 = add nsw i32 %119, %120
%122 = icmp ne i32 %118, %121
br i1 %122, label %123, label %124
123: ; preds = %117
store i32 6, i32* %4
br label %185
124: ; preds = %117
%125 = load i32, i32* %25
%126 = icmp sge i32 %125, 60
br i1 %126, label %127, label %133
127: ; preds = %124
%128 = load i32, i32* %14
%129 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%130 = bitcast i32* %129 to i8*
%131 = getelementptr inbounds i8, i8* %130, i64 4
%132 = call i32 @write(i32 %128, i8* %131, i32 60)
br label %140
133: ; preds = %124
%134 = load i32, i32* %14
%135 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%136 = bitcast i32* %135 to i8*
%137 = getelementptr inbounds i8, i8* %136, i64 4
%138 = load i32, i32* %25
%139 = call i32 @write(i32 %134, i8* %137, i32 %138)
br label %140
140: ; preds = %133, %127
%141 = load i32, i32* %26
%142 = add nsw i32 %141, 64
store i32 %142, i32* %26
store i32 0, i32* %12
br label %91
143: ; preds = %91
br label %144
144: ; preds = %179, %143
%145 = load i32, i32* %13
%146 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%147 = call i32 @read(i32 %145, i32* %146, i32 64)
store i32 %147, i32* %16
%148 = icmp ne i32 0, %147
br i1 %148, label %149, label %180
149: ; preds = %144
%150 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%151 = load i8*, i8** %7
%152 = bitcast i8* %151 to i32*
%153 = call i32 @btea(i32* %150, i32 -16, i32* %152)
%154 = load i32, i32* %26
%155 = add nsw i32 %154, 64
store i32 %155, i32* %26
%156 = load i32, i32* %26
%157 = load i32, i32* %25
%158 = add nsw i32 %157, 4
%159 = icmp slt i32 %156, %158
br i1 %159, label %160, label %168
160: ; preds = %149
%161 = load i32, i32* %25
%162 = icmp sgt i32 %161, 64
br i1 %162, label %163, label %168
163: ; preds = %160
%164 = load i32, i32* %14
%165 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%166 = bitcast i32* %165 to i8*
%167 = call i32 @write(i32 %164, i8* %166, i32 64)
br label %179
168: ; preds = %160, %149
%169 = load i32, i32* %26
%170 = load i32, i32* %25
%171 = add nsw i32 %170, 4
%172 = sub nsw i32 %169, %171
%173 = sub nsw i32 64, %172
store i32 %173, i32* %15
%174 = load i32, i32* %14
%175 = getelementptr inbounds [64 x i32], [64 x i32]* %28, i64 0, i64 0
%176 = bitcast i32* %175 to i8*
%177 = load i32, i32* %15
%178 = call i32 @write(i32 %174, i8* %176, i32 %177)
br label %179
179: ; preds = %168, %163
br label %144
180: ; preds = %144
%181 = load i32, i32* %14
%182 = call i32 @close(i32 %181)
%183 = load i32, i32* %13
%184 = call i32 @close(i32 %183)
store i32 0, i32* %4
br label %185
185: ; preds = %180, %123, %65, %55, %53, %47, %36
%186 = load i32, i32* %4
ret i32 %186
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@R_OK = global i32 0
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
define i32 @xxtea_decrypt(i8* %0, i8* nocapture %1, i8* %2) {
%4 = alloca i32
%5 = alloca [64 x i32]
%6 = alloca %struct.stat
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast [64 x i32]* %5 to i8*
%9 = bitcast %struct.stat* %6 to i8*
%10 = icmp eq i8* %0, null
br i1 %10, label %87, label %11
11: ; preds = %3
%12 = call i32 @stat(i8* %0, %struct.stat* %6)
%13 = icmp eq i32 %12, -1
br i1 %13, label %87, label %14
14: ; preds = %11
%15 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%16 = load i32, i32* %15
%17 = tail call i32 @htonl(i32 %16)
%18 = load i32, i32* @R_OK
%19 = tail call i32 @access(i8* %0, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %87, label %21
21: ; preds = %14
%22 = load i32, i32* @O_RDONLY
%23 = tail call i32 (i8*, i32, ...) @open(i8* %0, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %87, label %25
25: ; preds = %21
%26 = load i32, i32* @O_WRONLY
%27 = load i32, i32* @O_CREAT
%28 = or i32 %27, %26
%29 = load i32, i32* @O_EXCL
%30 = or i32 %28, %29
%31 = tail call i32 (i8*, i32, ...) @open(i8* %1, i32 %30, i32 384)
%32 = icmp eq i32 %31, -1
br i1 %32, label %87, label %47
33: ; preds = %47
%34 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
%35 = bitcast i8* %2 to i32*
%36 = call i32 @read(i32 %23, i32* %34, i32 64)
%37 = call i32 @btea(i32* %34, i32 -16, i32* %35)
%38 = call i32 @memcpy(i32* %4, i32* %34, i32 4)
%39 = load i32, i32* %4
%40 = call i32 @ntohl(i32 %39)
%41 = srem i32 %40, 64
%42 = icmp sgt i32 %41, 60
%43 = select i1 %42, i32 128, i32 64
%44 = sub i32 %40, %41
%45 = add i32 %44, %43
%46 = icmp eq i32 %16, %45
br i1 %46, label %63, label %87
47: ; preds = %25, %47
%48 = phi i32 [ %59, %47 ], [ 0, %25 ]
%49 = tail call i32 @srand(i32 %48)
%50 = tail call i32 (...) @rand()
%51 = tail call i64 @time(i32 0)
%52 = trunc i64 %51 to i32
%53 = tail call i32 (...) @getpid()
%54 = add i32 %50, %48
%55 = add i32 %54, %52
%56 = add i32 %55, %53
%57 = tail call i32 @srand(i32 %56)
%58 = tail call i32 (...) @rand()
%59 = add nuw nsw i32 %48, 1
%60 = icmp eq i32 %59, 16
br i1 %60, label %33, label %47
61: ; preds = %63
%62 = icmp sgt i32 %40, 64
br label %71
63: ; preds = %33
%64 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 1
%65 = bitcast i32* %64 to i8*
%66 = icmp slt i32 %40, 60
%67 = select i1 %66, i32 %40, i32 60
%68 = call i32 @write(i32 %31, i8* %65, i32 %67)
%69 = call i32 @read(i32 %23, i32* %34, i32 64)
%70 = icmp eq i32 %69, 0
br i1 %70, label %84, label %61
71: ; preds = %61, %71
%72 = phi i32 [ 64, %61 ], [ %74, %71 ]
%73 = call i32 @btea(i32* %34, i32 -16, i32* %35)
%74 = add nuw nsw i32 %72, 64
%75 = or i32 %72, 60
%76 = icmp sgt i32 %40, %75
%77 = and i1 %62, %76
%78 = sub i32 %40, %72
%79 = add i32 %78, 4
%80 = select i1 %77, i32 64, i32 %79
%81 = call i32 @write(i32 %31, i8* %8, i32 %80)
%82 = call i32 @read(i32 %23, i32* %34, i32 64)
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %71
84: ; preds = %71, %63
%85 = call i32 @close(i32 %31)
%86 = call i32 @close(i32 %23)
br label %87
87: ; preds = %33, %25, %3, %21, %14, %11, %84
%88 = phi i32 [ 0, %84 ], [ 1, %11 ], [ 5, %14 ], [ 5, %21 ], [ 1, %3 ], [ 4, %25 ], [ 6, %33 ]
ret i32 %88
}