#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*/ memcpy(char *, char const *, int);
scalar_t__ strlen(char const *);
void MakeBase32Pretty(char *pcOut, const char *pcIn) {
  int n = (int)strlen(pcIn);
  int m;
  while (n > 0) {
    if (n % 4 == 0) {
      m = 4;
    } else {
      m = n % 4;
    }
    memcpy(pcOut, pcIn, m);
    pcOut += m;
    pcIn += m;
    n -= m;
    if (n > 0) {
      *pcOut++ = '-';
    }
  }
  *pcOut = '\0';
}


x86 assembly (clang, -O0):
<MakeBase32Pretty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11d2 <MakeBase32Pretty+0xb2>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1166 <MakeBase32Pretty+0x46>
movl   $0x4,-0x18(%rbp)
jmp    1174 <MakeBase32Pretty+0x54>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11cd <MakeBase32Pretty+0xad>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2d,(%rax)
jmp    113c <MakeBase32Pretty+0x1c>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeBase32Pretty>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
test   %r12d,%r12d
jle    119a <MakeBase32Pretty+0x7a>
mov    %r12d,%ebx
and    $0x3,%ebx
mov    $0x4,%ebp
cmove  %ebp,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
add    %rbx,%r15
sub    %ebx,%r12d
jle    119a <MakeBase32Pretty+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %rbx,%r14
lea    0x1(%r15),%rdi
movb   $0x2d,(%r15)
mov    %r12d,%ebx
and    $0x3,%ebx
cmove  %ebp,%ebx
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
add    %rbx,%r15
add    $0x1,%r15
sub    %ebx,%r12d
jg     1170 <MakeBase32Pretty+0x50>
movb   $0x0,(%r15)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MakeBase32Pretty(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %5
br label %10
10: ; preds = %42, %2
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %43
13: ; preds = %10
%14 = load i32, i32* %5
%15 = srem i32 %14, 4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 4, i32* %6
br label %21
18: ; preds = %13
%19 = load i32, i32* %5
%20 = srem i32 %19, 4
store i32 %20, i32* %6
br label %21
21: ; preds = %18, %17
%22 = load i8*, i8** %3
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = call i32 @memcpy(i8* %22, i8* %23, i32 %24)
%26 = load i32, i32* %6
%27 = load i8*, i8** %3
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8* %29, i8** %3
%30 = load i32, i32* %6
%31 = load i8*, i8** %4
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8* %33, i8** %4
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, %34
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %21
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %3
store i8 45, i8* %40
br label %42
42: ; preds = %39, %21
br label %10
43: ; preds = %10
%44 = load i8*, i8** %3
store i8 0, i8* %44
ret void
}

LLVM IR (-O2):
define void @MakeBase32Pretty(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %30
6: ; preds = %2
%7 = and i32 %4, 3
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 4, i32 %7
%10 = tail call i32 @memcpy(i8* %0, i8* %1, i32 %9)
%11 = zext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = sub nsw i32 %4, %9
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %30
15: ; preds = %6, %15
%16 = phi i32 [ %28, %15 ], [ %13, %6 ]
%17 = phi i8* [ %27, %15 ], [ %12, %6 ]
%18 = phi i64 [ %26, %15 ], [ %11, %6 ]
%19 = phi i8* [ %20, %15 ], [ %1, %6 ]
%20 = getelementptr inbounds i8, i8* %19, i64 %18
%21 = getelementptr inbounds i8, i8* %17, i64 1
store i8 45, i8* %17
%22 = and i32 %16, 3
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i32 4, i32 %22
%25 = tail call i32 @memcpy(i8* %21, i8* %20, i32 %24)
%26 = zext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %21, i64 %26
%28 = sub nsw i32 %16, %24
%29 = icmp sgt i32 %28, 0
br i1 %29, label %15, label %30
30: ; preds = %15, %6, %2
%31 = phi i8* [ %0, %2 ], [ %12, %6 ], [ %27, %15 ]
store i8 0, i8* %31
ret void
}