#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*/ md5_buffer(char const *, int /*<<< orphan*/,
                              unsigned char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ to_hex_char(char *, unsigned char *, int);
void thumbname_from_uri(const char *uri, char *thumb) {
  char hexdigest[33];
  unsigned char digest[16];
  md5_buffer(uri, strlen(uri), digest);
  hexdigest[0] = '\0';
  to_hex_char(hexdigest, digest, 16);
  hexdigest[32] = '\0';
  sprintf(thumb, "%s.png", hexdigest);
}


x86 assembly (clang, -O0):
<thumbname_from_uri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
lea    -0x50(%rbp),%rdx
call   1040 <md5_buffer@plt>
movb   $0x0,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   1050 <to_hex_char@plt>
movb   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1060 <sprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thumbname_from_uri>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x30(%rsp),%r15
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1040 <md5_buffer@plt>
movb   $0x0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1050 <to_hex_char@plt>
movb   $0x0,0x20(%rsp)
lea    0xe77(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s.png\00"
define void @thumbname_from_uri(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [33 x i8]
%6 = alloca [16 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%11 = call i32 @md5_buffer(i8* %7, i32 %9, i8* %10)
%12 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
store i8 0, i8* %12
%13 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%15 = call i32 @to_hex_char(i8* %13, i8* %14, i32 16)
%16 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 32
store i8 0, i8* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.png\00"
define void @thumbname_from_uri(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [33 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strlen(i8* %0)
%8 = call i32 @md5_buffer(i8* %0, i32 %7, i8* %6)
store i8 0, i8* %5
%9 = call i32 @to_hex_char(i8* %5, i8* %6, i32 16)
%10 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 32
store i8 0, i8* %10
%11 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
ret void
}