#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 SHA_DIGEST_LENGTH;
int /*<<< orphan*/ hash(char *, int, unsigned char *);
scalar_t__ strncmp(unsigned char const *, unsigned char *, int);
int tryLength(int len, unsigned const char *target, char *plaintext) {
  int i;
  for (i = 0; i < len; i++) {
    *(plaintext + i) = 32;
  }
  char *max = plaintext + len;
  unsigned char h[SHA_DIGEST_LENGTH];
  while (1) {
    char *j;
    for (j = plaintext; *(j++) == 126 + 1;) {
      if (j == max) {
        return 0;
      }
      *(j - 1) = 32;
      (*j)++;
    }
    hash(plaintext, len, h);
    if (strncmp(target, h, SHA_DIGEST_LENGTH) == 0) {
      return 1;
    }
    (*plaintext)++;
  }
}


x86 assembly (clang, -O0):
<tryLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1160 <tryLength+0x40>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <tryLength+0x1a>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
jmp    11a0 <tryLength+0x80>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movsbl (%rax),%eax
cmp    $0x7f,%eax
jne    11fc <tryLength+0xdc>
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    11e4 <tryLength+0xc4>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    124f <tryLength+0x12f>
mov    -0x40(%rbp),%rax
movb   $0x20,-0x1(%rax)
mov    -0x40(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
jmp    11a8 <tryLength+0x88>
mov    -0x50(%rbp),%rdx
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <hash@plt>
mov    -0x50(%rbp),%rsi
mov    -0x10(%rbp),%rdi
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    123f <tryLength+0x11f>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    124f <tryLength+0x12f>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
jmp    119b <tryLength+0x7b>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tryLength>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
test   %edi,%edi
jle    115b <tryLength+0x2b>
mov    %r15d,%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <memset@plt>
movslq %r15d,%r13
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    (%rbx),%al
cmp    $0x7f,%al
jne    11ad <tryLength+0x7d>
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %rax,%r13
je     11e1 <tryLength+0xb1>
movb   $0x20,-0x1(%rbx,%rax,1)
movzbl (%rbx,%rax,1),%ecx
add    $0x1,%cl
mov    %cl,(%rbx,%rax,1)
add    $0x1,%rax
cmp    $0x7f,%cl
je     1190 <tryLength+0x60>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1040 <hash@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f2 <tryLength+0xc2>
movzbl (%rbx),%eax
add    $0x1,%al
mov    %al,(%rbx)
cmp    $0x7f,%al
je     117e <tryLength+0x4e>
jmp    11ad <tryLength+0x7d>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    11e3 <tryLength+0xb3>

LLVM IR (-O0):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @tryLength(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
br label %14
14: ; preds = %23, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %7
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 32, i8* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %14
26: ; preds = %14
%27 = load i8*, i8** %7
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8* %30, i8** %9
%31 = load i32, i32* @SHA_DIGEST_LENGTH
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %10
%34 = alloca i8, i64 %32
store i64 %32, i64* %11
br label %35
35: ; preds = %64, %26
br label %36
36: ; preds = %35
%37 = load i8*, i8** %7
store i8* %37, i8** %12
br label %38
38: ; preds = %49, %36
%39 = load i8*, i8** %12
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %12
%41 = load i8, i8* %39
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 127
br i1 %43, label %44, label %55
44: ; preds = %38
%45 = load i8*, i8** %12
%46 = load i8*, i8** %9
%47 = icmp eq i8* %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 0, i32* %4
store i32 1, i32* %13
br label %68
49: ; preds = %44
%50 = load i8*, i8** %12
%51 = getelementptr inbounds i8, i8* %50, i64 -1
store i8 32, i8* %51
%52 = load i8*, i8** %12
%53 = load i8, i8* %52
%54 = add i8 %53, 1
store i8 %54, i8* %52
br label %38
55: ; preds = %38
%56 = load i8*, i8** %7
%57 = load i32, i32* %5
%58 = call i32 @hash(i8* %56, i32 %57, i8* %34)
%59 = load i8*, i8** %6
%60 = load i32, i32* @SHA_DIGEST_LENGTH
%61 = call i64 @strncmp(i8* %59, i8* %34, i32 %60)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %55
store i32 1, i32* %4
store i32 1, i32* %13
br label %68
64: ; preds = %55
%65 = load i8*, i8** %7
%66 = load i8, i8* %65
%67 = add i8 %66, 1
store i8 %67, i8* %65
br label %35
68: ; preds = %63, %48
%69 = load i8*, i8** %10
%70 = load i32, i32* %4
ret i32 %70
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @tryLength(i32 %0, i8* %1, i8* %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %3
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
%10 = load i32, i32* @SHA_DIGEST_LENGTH
%11 = zext i32 %10 to i64
%12 = alloca i8, i64 %11
%13 = load i8, i8* %2
br label %14
14: ; preds = %30, %7
%15 = phi i8 [ %32, %30 ], [ %13, %7 ]
%16 = icmp eq i8 %15, 127
br i1 %16, label %17, label %25
17: ; preds = %14, %21
%18 = phi i8* [ %19, %21 ], [ %2, %14 ]
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = icmp eq i8* %19, %9
br i1 %20, label %33, label %21
21: ; preds = %17
store i8 32, i8* %18
%22 = load i8, i8* %19
%23 = add i8 %22, 1
store i8 %23, i8* %19
%24 = icmp eq i8 %23, 127
br i1 %24, label %17, label %25
25: ; preds = %21, %14
%26 = call i32 @hash(i8* %2, i32 %0, i8* %12)
%27 = load i32, i32* @SHA_DIGEST_LENGTH
%28 = call i64 @strncmp(i8* %1, i8* %12, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load i8, i8* %2
%32 = add i8 %31, 1
store i8 %32, i8* %2
br label %14
33: ; preds = %25, %17
%34 = phi i32 [ 0, %17 ], [ 1, %25 ]
ret i32 %34
}