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

/* Variables and functions */
int /*<<< orphan*/ MD5_Final(int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, int *, size_t);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
size_t strlen(char *);
int main(int ac, char **av) {
  MD5_CTX ctx;
  uint8_t out[16];
  char *hex = av[1];
  size_t xlen = strlen(av[1]);
  size_t blen = xlen / 2;
  uint8_t *in = (uint8_t *)malloc(blen);
  for (size_t i = 0; i < blen; ++i) {
    sscanf(hex, "%2hhx", &in[i]);
    hex += 2;
  }
  MD5_Init(&ctx);
  MD5_Update(&ctx, in, blen);
  MD5_Final(out, &ctx);
  free(in);
  for (size_t i = 0; i < 16; ++i)
    printf("%02x", out[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%rax
cmp    -0x78(%rbp),%rax
jae    1230 <main+0xb0>
mov    -0x68(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x88(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdf8(%rip),%rsi
call   1080 <sscanf@plt>
mov    -0x68(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x68(%rbp)
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    11da <main+0x5a>
lea    -0x14(%rbp),%rdi
call   1090 <MD5_Init@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdx
lea    -0x14(%rbp),%rdi
call   10a0 <MD5_Update@plt>
lea    -0x60(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <MD5_Final@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x90(%rbp)
cmpq   $0x10,-0x90(%rbp)
10
jae    12a9 <main+0x129>
mov    -0x90(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
jmp    126b <main+0xeb>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x8(%rsi),%r13
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %rax,%rbx
mov    %rax,%r15
shr    %r15
mov    %r15,%rdi
call   1080 <malloc@plt>
mov    %rax,%r14
cmp    $0x2,%rbx
jb     11fc <main+0x6c>
cmp    $0x2,%r15
mov    $0x1,%ebp
cmovae %r15,%rbp
lea    0xe28(%rip),%r12
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1090 <sscanf@plt>
add    $0x2,%r13
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    11e0 <main+0x50>
lea    0x44(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <MD5_Init@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   10b0 <MD5_Update@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1050 <MD5_Final@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    (%rsp),%esi
lea    0xdd2(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%2hhx\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [16 x i32]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %8
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strlen(i8* %19)
store i64 %20, i64* %9
%21 = load i64, i64* %9
%22 = udiv i64 %21, 2
store i64 %22, i64* %10
%23 = load i64, i64* %10
%24 = call i64 @malloc(i64 %23)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %11
store i64 0, i64* %12
br label %26
26: ; preds = %38, %2
%27 = load i64, i64* %12
%28 = load i64, i64* %10
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %41
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = load i32*, i32** %11
%33 = load i64, i64* %12
%34 = getelementptr inbounds i32, i32* %32, i64 %33
%35 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %34)
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 2
store i8* %37, i8** %8
br label %38
38: ; preds = %30
%39 = load i64, i64* %12
%40 = add i64 %39, 1
store i64 %40, i64* %12
br label %26
41: ; preds = %26
%42 = call i32 @MD5_Init(i32* %6)
%43 = load i32*, i32** %11
%44 = load i64, i64* %10
%45 = call i32 @MD5_Update(i32* %6, i32* %43, i64 %44)
%46 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%47 = call i32 @MD5_Final(i32* %46, i32* %6)
%48 = load i32*, i32** %11
%49 = call i32 @free(i32* %48)
store i64 0, i64* %13
br label %50
50: ; preds = %58, %41
%51 = load i64, i64* %13
%52 = icmp ult i64 %51, 16
br i1 %52, label %53, label %61
53: ; preds = %50
%54 = load i64, i64* %13
%55 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %53
%59 = load i64, i64* %13
%60 = add i64 %59, 1
store i64 %60, i64* %13
br label %50
61: ; preds = %50
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%2hhx\00"
@.str.1 = [5 x i8] c"%02x\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [16 x i32]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [16 x i32]* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = lshr i64 %9, 1
%11 = tail call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i32*
%13 = icmp ult i64 %9, 2
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i64 @llvm.umax.i64(i64 %10, i64 1)
br label %70
16: ; preds = %70, %2
%17 = call i32 @MD5_Init(i32* %3)
%18 = call i32 @MD5_Update(i32* %3, i32* %12, i64 %10)
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%20 = call i32 @MD5_Final(i32* %19, i32* %3)
%21 = call i32 @free(i32* %12)
%22 = load i32, i32* %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 1
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 2
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 3
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 4
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 5
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 6
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 7
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 8
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 9
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 10
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 11
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 12
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 13
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 14
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 15
%67 = load i32, i32* %66
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %67)
%69 = call i32 @putchar(i32 10)
ret i32 0
70: ; preds = %14, %70
%71 = phi i64 [ %76, %70 ], [ 0, %14 ]
%72 = phi i8* [ %75, %70 ], [ %8, %14 ]
%73 = getelementptr inbounds i32, i32* %12, i64 %71
%74 = tail call i32 @sscanf(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %73)
%75 = getelementptr inbounds i8, i8* %72, i64 2
%76 = add nuw nsw i64 %71, 1
%77 = icmp eq i64 %76, %15
br i1 %77, label %16, label %70
}