#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 charToHex(char);
void strToHex(char p1[8], unsigned char h1[4], char p2[8],
              unsigned char h2[4]) {
  int i;
  for (i = 0; i < 4; i++) {
    h1[i] = (charToHex(p1[i * 2]) << 4) | charToHex(p1[i * 2 + 1]);
  }
  for (i = 0; i < 4; i++) {
    h2[i] = (charToHex(p2[i * 2]) << 4) | charToHex(p2[i * 2 + 1]);
  }
}


x86 assembly (clang, -O0):
<strToHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1190 <strToHex+0x80>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <charToHex@plt>
shl    $0x4,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <charToHex@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
or     %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <strToHex+0x1f>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11f8 <strToHex+0xe8>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <charToHex@plt>
shl    $0x4,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <charToHex@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
or     %ecx,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1197 <strToHex+0x87>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToHex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x1(%rbx),%edi
call   1030 <charToHex@plt>
or     %ebp,%eax
mov    %al,(%r15)
movsbl 0x2(%rbx),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x3(%rbx),%edi
call   1030 <charToHex@plt>
or     %ebp,%eax
mov    %al,0x1(%r15)
movsbl 0x4(%rbx),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x5(%rbx),%edi
call   1030 <charToHex@plt>
or     %ebp,%eax
mov    %al,0x2(%r15)
movsbl 0x6(%rbx),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x7(%rbx),%edi
call   1030 <charToHex@plt>
or     %ebp,%eax
mov    %al,0x3(%r15)
movsbl (%r12),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x1(%r12),%edi
call   1030 <charToHex@plt>
or     %ebx,%eax
mov    %al,(%r14)
movsbl 0x2(%r12),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x3(%r12),%edi
call   1030 <charToHex@plt>
or     %ebx,%eax
mov    %al,0x1(%r14)
movsbl 0x4(%r12),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x5(%r12),%edi
call   1030 <charToHex@plt>
or     %ebx,%eax
mov    %al,0x2(%r14)
movsbl 0x6(%r12),%edi
call   1030 <charToHex@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x7(%r12),%edi
call   1030 <charToHex@plt>
or     %ebx,%eax
mov    %al,0x3(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @strToHex(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
br label %10
10: ; preds = %36, %4
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %39
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = load i32, i32* %9
%16 = mul nsw i32 %15, 2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @charToHex(i8 signext %19)
%21 = shl i32 %20, 4
%22 = load i8*, i8** %5
%23 = load i32, i32* %9
%24 = mul nsw i32 %23, 2
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @charToHex(i8 signext %28)
%30 = or i32 %21, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %13
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %10
39: ; preds = %10
store i32 0, i32* %9
br label %40
40: ; preds = %66, %39
%41 = load i32, i32* %9
%42 = icmp slt i32 %41, 4
br i1 %42, label %43, label %69
43: ; preds = %40
%44 = load i8*, i8** %7
%45 = load i32, i32* %9
%46 = mul nsw i32 %45, 2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
%49 = load i8, i8* %48
%50 = call i32 @charToHex(i8 signext %49)
%51 = shl i32 %50, 4
%52 = load i8*, i8** %7
%53 = load i32, i32* %9
%54 = mul nsw i32 %53, 2
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %52, i64 %56
%58 = load i8, i8* %57
%59 = call i32 @charToHex(i8 signext %58)
%60 = or i32 %51, %59
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %8
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 %61, i8* %65
br label %66
66: ; preds = %43
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %40
69: ; preds = %40
ret void
}

LLVM IR (-O2):
define void @strToHex(i8* nocapture %0, i8* nocapture writeonly %1, i8* nocapture %2, i8* nocapture writeonly %3) {
%5 = load i8, i8* %0
%6 = tail call i32 @charToHex(i8 signext %5)
%7 = shl i32 %6, 4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call i32 @charToHex(i8 signext %9)
%11 = or i32 %10, %7
%12 = trunc i32 %11 to i8
store i8 %12, i8* %1
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = tail call i32 @charToHex(i8 signext %14)
%16 = shl i32 %15, 4
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = load i8, i8* %17
%19 = tail call i32 @charToHex(i8 signext %18)
%20 = or i32 %19, %16
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %21, i8* %22
%23 = getelementptr inbounds i8, i8* %0, i64 4
%24 = load i8, i8* %23
%25 = tail call i32 @charToHex(i8 signext %24)
%26 = shl i32 %25, 4
%27 = getelementptr inbounds i8, i8* %0, i64 5
%28 = load i8, i8* %27
%29 = tail call i32 @charToHex(i8 signext %28)
%30 = or i32 %29, %26
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %0, i64 6
%34 = load i8, i8* %33
%35 = tail call i32 @charToHex(i8 signext %34)
%36 = shl i32 %35, 4
%37 = getelementptr inbounds i8, i8* %0, i64 7
%38 = load i8, i8* %37
%39 = tail call i32 @charToHex(i8 signext %38)
%40 = or i32 %39, %36
%41 = trunc i32 %40 to i8
%42 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %41, i8* %42
%43 = load i8, i8* %2
%44 = tail call i32 @charToHex(i8 signext %43)
%45 = shl i32 %44, 4
%46 = getelementptr inbounds i8, i8* %2, i64 1
%47 = load i8, i8* %46
%48 = tail call i32 @charToHex(i8 signext %47)
%49 = or i32 %48, %45
%50 = trunc i32 %49 to i8
store i8 %50, i8* %3
%51 = getelementptr inbounds i8, i8* %2, i64 2
%52 = load i8, i8* %51
%53 = tail call i32 @charToHex(i8 signext %52)
%54 = shl i32 %53, 4
%55 = getelementptr inbounds i8, i8* %2, i64 3
%56 = load i8, i8* %55
%57 = tail call i32 @charToHex(i8 signext %56)
%58 = or i32 %57, %54
%59 = trunc i32 %58 to i8
%60 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %59, i8* %60
%61 = getelementptr inbounds i8, i8* %2, i64 4
%62 = load i8, i8* %61
%63 = tail call i32 @charToHex(i8 signext %62)
%64 = shl i32 %63, 4
%65 = getelementptr inbounds i8, i8* %2, i64 5
%66 = load i8, i8* %65
%67 = tail call i32 @charToHex(i8 signext %66)
%68 = or i32 %67, %64
%69 = trunc i32 %68 to i8
%70 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %69, i8* %70
%71 = getelementptr inbounds i8, i8* %2, i64 6
%72 = load i8, i8* %71
%73 = tail call i32 @charToHex(i8 signext %72)
%74 = shl i32 %73, 4
%75 = getelementptr inbounds i8, i8* %2, i64 7
%76 = load i8, i8* %75
%77 = tail call i32 @charToHex(i8 signext %76)
%78 = or i32 %77, %74
%79 = trunc i32 %78 to i8
%80 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %79, i8* %80
ret void
}