#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*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
char toupper(char);
void printlanhash(char *tmp) {
  int i;
  unsigned char c;
  char outbuffer[33];
  for (i = 0; i < 16; i++) {
    c = tmp[i];
    sprintf(outbuffer + 2 * i, "%x", (c >> 4) & 0x0f);
    sprintf(outbuffer + 2 * i + 1, "%x", c & 0x0f);
  }
  for (i = 0; i < 32; i++)
    outbuffer[i] = toupper(outbuffer[i]);
  outbuffer[32] = '\0';
  printf("%s", outbuffer);
}


x86 assembly (clang, -O0):
<printlanhash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    11ba <printlanhash+0x8a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
movzbl -0xd(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
lea    0xe85(%rip),%rsi
movzbl %al,%edx
call   1050 <sprintf@plt>
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
add    $0x1,%rdi
movzbl -0xd(%rbp),%eax
and    $0xf,%eax
lea    0xe5c(%rip),%rsi
movzbl %al,%edx
call   1050 <sprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <printlanhash+0x13>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11f1 <printlanhash+0xc1>
movslq -0xc(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <printlanhash+0x91>
movb   $0x0,-0x10(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlanhash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
xor    %ebp,%ebp
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rbp,1),%r12d
mov    %r12d,%eax
shr    $0x4,%al
movzbl %al,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <sprintf@plt>
lea    0x1(%rbx),%rdi
and    $0xf,%r12d
mov    %r15,%rsi
mov    %r12d,%edx
call   1050 <sprintf@plt>
add    $0x1,%rbp
add    $0x2,%rbx
cmp    $0x10,%rbp
jne    1150 <printlanhash+0x20>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1190 <printlanhash+0x60>
movb   $0x0,0x20(%rsp)
lea    0xe51(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlanhash(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca [33 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
br label %6
6: ; preds = %37, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %4
%15 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%16 = load i32, i32* %3
%17 = mul nsw i32 2, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = ashr i32 %21, 4
%23 = and i32 %22, 15
%24 = trunc i32 %23 to i8
%25 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %24)
%26 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%27 = load i32, i32* %3
%28 = mul nsw i32 2, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %4
%33 = zext i8 %32 to i32
%34 = and i32 %33, 15
%35 = trunc i32 %34 to i8
%36 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %35)
br label %37
37: ; preds = %9
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %6
40: ; preds = %6
store i32 0, i32* %3
br label %41
41: ; preds = %53, %40
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 32
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call signext i8 @toupper(i8 signext %48)
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 %51
store i8 %49, i8* %52
br label %53
53: ; preds = %44
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %41
56: ; preds = %41
%57 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 32
store i8 0, i8* %57
%58 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %58)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@.str.1 = [3 x i8] c"%s\00"
define void @printlanhash(i8* nocapture %0) {
%2 = alloca [33 x i8]
%3 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %15, %4 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = shl nuw nsw i64 %5, 1
%9 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 %8
%10 = lshr i8 %7, 4
%11 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = and i8 %7, 15
%14 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %13)
%15 = add nuw nsw i64 %5, 1
%16 = icmp eq i64 %15, 16
br i1 %16, label %17, label %4
17: ; preds = %4, %17
%18 = phi i64 [ %22, %17 ], [ 0, %4 ]
%19 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = tail call signext i8 @toupper(i8 signext %20)
store i8 %21, i8* %19
%22 = add nuw nsw i64 %18, 1
%23 = icmp eq i64 %22, 32
br i1 %23, label %24, label %17
24: ; preds = %17
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 32
store i8 0, i8* %25
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}