#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*/ sprintf(char *, char *, char);
char *bprint(char b[64]) {
  static char s[17];
  register int i;
  for (i = 0; i < 64; i += 4)
    sprintf(&s[i / 4], "%1x",
            b[i] << 3 | b[i + 1] << 2 | b[i + 2] << 1 | b[i + 3]);
  return (s);
}


x86 assembly (clang, -O0):
<bprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x40,-0xc(%rbp)
jge    11af <bprint+0x9f>
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
lea    0x2eff(%rip),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
shl    $0x3,%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x2,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x3,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
or     %ecx,%eax
lea    0xe67(%rip),%rsi
movsbl %al,%edx
call   1030 <sprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <bprint+0x13>
lea    0x2e8a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bprint>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xfffffffffffffffc,%rbx
lea    0x2f17(%rip),%r12
lea    0xed0(%rip),%r15
movzbl 0x4(%r14,%rbx,1),%eax
movzbl 0x5(%r14,%rbx,1),%ecx
shl    $0x3,%al
shl    $0x2,%cl
or     %al,%cl
movzbl 0x6(%r14,%rbx,1),%eax
add    %al,%al
or     %cl,%al
or     0x7(%r14,%rbx,1),%al
movsbl %al,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
add    $0x4,%rbx
add    $0x1,%r12
cmp    $0x3c,%rbx
jb     1130 <bprint+0x20>
lea    0x2eca(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@bprint.s = internal global [17 x i8] zeroinitializer
@.str = [4 x i8] c"%1x\00"
define i8* @bprint(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %47, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 64
br i1 %6, label %7, label %50
7: ; preds = %4
%8 = load i32, i32* %3
%9 = sdiv i32 %8, 4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [17 x i8], [17 x i8]* @bprint.s, i64 0, i64 %10
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = shl i32 %17, 3
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = shl i32 %25, 2
%27 = or i32 %18, %26
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = shl i32 %34, 1
%36 = or i32 %27, %35
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = or i32 %36, %43
%45 = trunc i32 %44 to i8
%46 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %45)
br label %47
47: ; preds = %7
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 4
store i32 %49, i32* %3
br label %4
50: ; preds = %4
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @bprint.s, i64 0, i64 0)
}

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