#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 *, ...);
void print_bytes_sep(const char *msg, const unsigned char *buf,
                     unsigned int size, const char m2[], const char sep[]) {
  unsigned int i;
  printf("%s", msg);
  for (i = 0; i < size - 1; i++)
    printf("%02X%s", buf[i], sep);
  if (i < size)
    printf("%02X", buf[i]);
  printf("%s", m2);
}


x86 assembly (clang, -O0):
<print_bytes_sep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    1180 <print_bytes_sep+0x70>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movzbl (%rax,%rcx,1),%esi
mov    -0x28(%rbp),%rdx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1144 <print_bytes_sep+0x34>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11a5 <print_bytes_sep+0x95>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bytes_sep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,(%rsp)
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12d,%eax
add    $0xffffffff,%eax
mov    %eax,%ebp
je     116b <print_bytes_sep+0x5b>
lea    0xeb6(%rip),%r13
xor    %r14d,%r14d
nopl   (%rax)
movzbl (%r15,%r14,1),%esi
mov    %r13,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1150 <print_bytes_sep+0x40>
test   %r12d,%r12d
je     1183 <print_bytes_sep+0x73>
movzbl (%r15,%rbp,1),%esi
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"%02X%s\00"
@.str.2 = [5 x i8] c"%02X\00"
define void @print_bytes_sep(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %11
br label %14
14: ; preds = %28, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %8
%17 = sub i32 %16, 1
%18 = icmp ult i32 %15, %17
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i32, i32* %11
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = load i8*, i8** %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26)
br label %28
28: ; preds = %19
%29 = load i32, i32* %11
%30 = add i32 %29, 1
store i32 %30, i32* %11
br label %14
31: ; preds = %14
%32 = load i32, i32* %11
%33 = load i32, i32* %8
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %43
35: ; preds = %31
%36 = load i8*, i8** %7
%37 = load i32, i32* %11
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %35, %31
%44 = load i8*, i8** %9
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %44)
ret void
}

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