#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*/ SHA1(char *, int, unsigned char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
void SHA1_Convert(register char *string, register char *hashout,
                  register int len) {
  register int i;
  unsigned char result[20];
  SHA1(string, len, result);
  for (i = 0; i < 20; i++) {
    sprintf(&hashout[i * 2], "%02x", result[i]);
  }
}


x86 assembly (clang, -O0):
<SHA1_Convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x30(%rbp),%rdx
call   1030 <SHA1@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    1186 <SHA1_Convert+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movslq -0x18(%rbp),%rax
lea    0xe92(%rip),%rsi
movzbl -0x30(%rbp,%rax,1),%edx
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <SHA1_Convert+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHA1_Convert>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rsp,%rax
mov    %edx,%esi
mov    %rax,%rdx
call   1030 <SHA1@plt>
movzbl (%rsp),%edx
lea    0xebe(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x2(%rbx),%rdi
movzbl 0x1(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x4(%rbx),%rdi
movzbl 0x2(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x6(%rbx),%rdi
movzbl 0x3(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x8(%rbx),%rdi
movzbl 0x4(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xa(%rbx),%rdi
movzbl 0x5(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xc(%rbx),%rdi
movzbl 0x6(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xe(%rbx),%rdi
movzbl 0x7(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x10(%rbx),%rdi
movzbl 0x8(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x12(%rbx),%rdi
movzbl 0x9(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x14(%rbx),%rdi
movzbl 0xa(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x16(%rbx),%rdi
movzbl 0xb(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x18(%rbx),%rdi
movzbl 0xc(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x1a(%rbx),%rdi
movzbl 0xd(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x1c(%rbx),%rdi
movzbl 0xe(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x1e(%rbx),%rdi
movzbl 0xf(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x20(%rbx),%rdi
movzbl 0x10(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x22(%rbx),%rdi
movzbl 0x11(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0x24(%rbx),%rdi
movzbl 0x12(%rsp),%edx
mov    %r14,%rsi
call   1040 <sprintf@plt>
add    $0x26,%rbx
movzbl 0x13(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @SHA1_Convert(i8* %0, i8* nocapture writeonly %1, i32 %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = call i32 @SHA1(i8* %0, i32 %2, i8* %5)
%7 = load i8, i8* %5
%8 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %7)
%9 = getelementptr inbounds i8, i8* %1, i64 2
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 1
%11 = load i8, i8* %10
%12 = call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %11)
%13 = getelementptr inbounds i8, i8* %1, i64 4
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 2
%15 = load i8, i8* %14
%16 = call i32 @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
%17 = getelementptr inbounds i8, i8* %1, i64 6
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 3
%19 = load i8, i8* %18
%20 = call i32 @sprintf(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %19)
%21 = getelementptr inbounds i8, i8* %1, i64 8
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 4
%23 = load i8, i8* %22
%24 = call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %23)
%25 = getelementptr inbounds i8, i8* %1, i64 10
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 5
%27 = load i8, i8* %26
%28 = call i32 @sprintf(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %27)
%29 = getelementptr inbounds i8, i8* %1, i64 12
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 6
%31 = load i8, i8* %30
%32 = call i32 @sprintf(i8* dereferenceable(1) %29, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %31)
%33 = getelementptr inbounds i8, i8* %1, i64 14
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 7
%35 = load i8, i8* %34
%36 = call i32 @sprintf(i8* dereferenceable(1) %33, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %35)
%37 = getelementptr inbounds i8, i8* %1, i64 16
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 8
%39 = load i8, i8* %38
%40 = call i32 @sprintf(i8* dereferenceable(1) %37, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %39)
%41 = getelementptr inbounds i8, i8* %1, i64 18
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 9
%43 = load i8, i8* %42
%44 = call i32 @sprintf(i8* dereferenceable(1) %41, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %43)
%45 = getelementptr inbounds i8, i8* %1, i64 20
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 10
%47 = load i8, i8* %46
%48 = call i32 @sprintf(i8* dereferenceable(1) %45, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %47)
%49 = getelementptr inbounds i8, i8* %1, i64 22
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 11
%51 = load i8, i8* %50
%52 = call i32 @sprintf(i8* dereferenceable(1) %49, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %51)
%53 = getelementptr inbounds i8, i8* %1, i64 24
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 12
%55 = load i8, i8* %54
%56 = call i32 @sprintf(i8* dereferenceable(1) %53, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %55)
%57 = getelementptr inbounds i8, i8* %1, i64 26
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 13
%59 = load i8, i8* %58
%60 = call i32 @sprintf(i8* dereferenceable(1) %57, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %59)
%61 = getelementptr inbounds i8, i8* %1, i64 28
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 14
%63 = load i8, i8* %62
%64 = call i32 @sprintf(i8* dereferenceable(1) %61, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %63)
%65 = getelementptr inbounds i8, i8* %1, i64 30
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 15
%67 = load i8, i8* %66
%68 = call i32 @sprintf(i8* dereferenceable(1) %65, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %67)
%69 = getelementptr inbounds i8, i8* %1, i64 32
%70 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 16
%71 = load i8, i8* %70
%72 = call i32 @sprintf(i8* dereferenceable(1) %69, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %71)
%73 = getelementptr inbounds i8, i8* %1, i64 34
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 17
%75 = load i8, i8* %74
%76 = call i32 @sprintf(i8* dereferenceable(1) %73, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %75)
%77 = getelementptr inbounds i8, i8* %1, i64 36
%78 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 18
%79 = load i8, i8* %78
%80 = call i32 @sprintf(i8* dereferenceable(1) %77, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %79)
%81 = getelementptr inbounds i8, i8* %1, i64 38
%82 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 19
%83 = load i8, i8* %82
%84 = call i32 @sprintf(i8* dereferenceable(1) %81, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %83)
ret void
}