#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*/ dc_crypt_char(char *, int, int, int);
int /*<<< orphan*/ printf(char *, char *);
void dc_crypt_buffer(char *buffer, int len, int decrypt) {
  if (decrypt)
    printf("\nDecrpyting buffer '%s'\n", buffer);
  else
    printf("\nEncrypting buffer '%s'\n", buffer);
  int c_no;
  for (c_no = 0; c_no < len; c_no++)
    dc_crypt_char(&buffer[c_no], c_no, len, decrypt);
}


x86 assembly (clang, -O0):
<dc_crypt_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1151 <dc_crypt_buffer+0x31>
mov    -0x8(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    1161 <dc_crypt_buffer+0x41>
mov    -0x8(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <dc_crypt_buffer+0x7b>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <dc_crypt_char@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <dc_crypt_buffer+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dc_crypt_buffer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
test   %edx,%edx
lea    0xee1(%rip),%rax
lea    0xec1(%rip),%rdi
cmove  %rax,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
test   %ebx,%ebx
jle    1179 <dc_crypt_buffer+0x59>
mov    %ebx,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r15,%rbx,1),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <dc_crypt_char@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <dc_crypt_buffer+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0ADecrpyting buffer '%s'\0A\00"
@.str.1 = [25 x i8] c"\0AEncrypting buffer '%s'\0A\00"
define void @dc_crypt_buffer(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
store i32 0, i32* %7
br label %17
17: ; preds = %30, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i32, i32* %7
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @dc_crypt_char(i8* %25, i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %21
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %17
33: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0ADecrpyting buffer '%s'\0A\00"
@.str.1 = [25 x i8] c"\0AEncrypting buffer '%s'\0A\00"
define void @dc_crypt_buffer(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0)
%6 = tail call i32 @printf(i8* %5, i8* %0)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = trunc i64 %11 to i32
%14 = tail call i32 @dc_crypt_char(i8* %12, i32 %13, i32 %1, i32 %2)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %3
ret void
}