#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ output;
typedef int /*<<< orphan*/ digest;
typedef int /*<<< orphan*/ SHA_CTX;

/* Variables and functions */
int /*<<< orphan*/ SHA1_Final(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA1_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ SHA1_Update(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ base32_encode(int /*<<< orphan*/ *, size_t *,
                                 int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  SHA_CTX context;
  uint8_t digest[20];
  char output[80];
  size_t bufflen = sizeof(output);
  if (argc <= 1) {
    fprintf(stderr, "Usage: %s <value>\n", argv[0]);
    return 1;
  }
  SHA1_Init(&context);
  SHA1_Update(&context, argv[1], strlen(argv[1]));
  SHA1_Final(digest, &context);
  base32_encode((uint8_t *)output, &bufflen, digest, sizeof(digest));
  printf("%s\n", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x50,-0xc8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11c6 <main+0x56>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0xd0>
lea    -0x14(%rbp),%rdi
call   1080 <SHA1_Init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0xd0(%rbp),%rsi
mov    %eax,%edx
lea    -0x14(%rbp),%rdi
call   1060 <SHA1_Update@plt>
lea    -0x70(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1090 <SHA1_Final@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0xc8(%rbp),%rsi
mov    $0x50,%ecx
call   1070 <base32_encode@plt>
lea    -0xc0(%rbp),%rsi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rbx
movq   $0x50,(%rsp)
cmp    $0x1,%edi
jg     11a9 <main+0x39>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1208 <main+0x98>
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1080 <SHA1_Init@plt>
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <SHA1_Update@plt>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <SHA1_Final@plt>
lea    0x10(%rsp),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x50,%ecx
call   1070 <base32_encode@plt>
lea    0xe15(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s <value>\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i32]
%8 = alloca [80 x i8]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 80, i64* %9
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %36
18: ; preds = %2
%19 = call i32 @SHA1_Init(i32* %6)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @SHA1_Update(i32* %6, i8* %22, i32 %26)
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%29 = call i32 @SHA1_Final(i32* %28, i32* %6)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%31 = bitcast i8* %30 to i32*
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%33 = call i32 @base32_encode(i32* %31, i64* %9, i32* %32, i32 80)
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %34)
store i32 0, i32* %3
br label %36
36: ; preds = %18, %12
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s <value>\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [20 x i32]
%5 = alloca [80 x i8]
%6 = alloca i64
%7 = bitcast i32* %3 to i8*
%8 = bitcast [20 x i32]* %4 to i8*
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = bitcast i64* %6 to i8*
store i64 80, i64* %6
%11 = icmp slt i32 %0, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %27
16: ; preds = %2
%17 = call i32 @SHA1_Init(i32* %3)
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @SHA1_Update(i32* %3, i8* %19, i32 %20)
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%23 = call i32 @SHA1_Final(i32* %22, i32* %3)
%24 = bitcast [80 x i8]* %5 to i32*
%25 = call i32 @base32_encode(i32* %24, i64* %6, i32* %22, i32 80)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %27
27: ; preds = %16, %12
%28 = phi i32 [ 1, %12 ], [ 0, %16 ]
ret i32 %28
}