#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
void decrypt_file2(char *ftxt) {
  char *pass = (char *)malloc(sizeof(char) * 64);
  printf("pass: ");
  scanf("%s", pass);
  int passlen = strlen(pass);
  int length = strlen(ftxt);
  int i = 0;
  for (i = 0; i < length; i++) {
    *(ftxt + i) -= *(pass + (i % passlen));
  }
}


x86 assembly (clang, -O0):
<decrypt_file2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x40,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e1 <decrypt_file2+0xa1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%esi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
sub    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119c <decrypt_file2+0x5c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_file2>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x40,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d7 <decrypt_file2+0x97>
mov    %eax,%esi
cmp    $0x1,%eax
jne    1190 <decrypt_file2+0x50>
xor    %ecx,%ecx
jmp    11c5 <decrypt_file2+0x85>
mov    %esi,%edi
and    $0xfffffffe,%edi
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %ebp
movzbl (%rbx,%rdx,1),%eax
sub    %al,(%r14,%rcx,1)
lea    0x1(%rcx),%eax
cltd
idiv   %ebp
movzbl (%rbx,%rdx,1),%eax
sub    %al,0x1(%r14,%rcx,1)
add    $0x2,%rcx
cmp    %rdi,%rcx
jne    11a0 <decrypt_file2+0x60>
test   $0x1,%sil
je     11d7 <decrypt_file2+0x97>
mov    %ecx,%eax
cltd
idiv   %ebp
mov    (%rbx,%rdx,1),%al
sub    %al,(%r14,%rcx,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"pass: \00"
@.str.1 = [3 x i8] c"%s\00"
define void @decrypt_file2(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = call i64 @malloc(i32 64)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %3
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %4
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %16
16: ; preds = %37, %1
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = srem i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %2
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = sub nsw i32 %34, %28
%36 = trunc i32 %35 to i8
store i8 %36, i8* %32
br label %37
37: ; preds = %20
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %16
40: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"pass: \00"
@.str.1 = [3 x i8] c"%s\00"
define void @decrypt_file2(i8* %0) {
%2 = tail call i64 @malloc(i32 64)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = tail call i32 @strlen(i8* %3)
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %50
9: ; preds = %1
%10 = zext i32 %7 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %7, 1
br i1 %12, label %38, label %13
13: ; preds = %9
%14 = and i64 %10, 4294967294
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %35, %15 ]
%17 = phi i64 [ 0, %13 ], [ %36, %15 ]
%18 = trunc i64 %16 to i32
%19 = srem i32 %18, %6
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %3, i64 %20
%22 = load i8, i8* %21
%23 = getelementptr inbounds i8, i8* %0, i64 %16
%24 = load i8, i8* %23
%25 = sub i8 %24, %22
store i8 %25, i8* %23
%26 = or i64 %16, 1
%27 = trunc i64 %26 to i32
%28 = srem i32 %27, %6
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %3, i64 %29
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %0, i64 %26
%33 = load i8, i8* %32
%34 = sub i8 %33, %31
store i8 %34, i8* %32
%35 = add nuw nsw i64 %16, 2
%36 = add i64 %17, 2
%37 = icmp eq i64 %36, %14
br i1 %37, label %38, label %15
38: ; preds = %15, %9
%39 = phi i64 [ 0, %9 ], [ %35, %15 ]
%40 = icmp eq i64 %11, 0
br i1 %40, label %50, label %41
41: ; preds = %38
%42 = trunc i64 %39 to i32
%43 = srem i32 %42, %6
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %3, i64 %44
%46 = load i8, i8* %45
%47 = getelementptr inbounds i8, i8* %0, i64 %39
%48 = load i8, i8* %47
%49 = sub i8 %48, %46
store i8 %49, i8* %47
br label %50
50: ; preds = %41, %38, %1
ret void
}