#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 *, ...);
int strlen(char *);
void spaceHexString(char *hexStr, int interval) {
  int col, i, numColumns;
  numColumns = 160;
  col = 1;
  for (i = 0; i < strlen(hexStr); i++) {
    if (i > 0 && i % interval == 0)
      printf(" ");
    if (numColumns - col < interval) {
      printf("\n");
      col = 0;
    }
    col++;
    printf("%c", hexStr[i]);
  }
}


x86 assembly (clang, -O0):
<spaceHexString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xa0,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11dd <spaceHexString+0xbd>
cmpl   $0x0,-0x14(%rbp)
jle    1188 <spaceHexString+0x68>
mov    -0x14(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1188 <spaceHexString+0x68>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ac <spaceHexString+0x8c>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <spaceHexString+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spaceHexString>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
jle    11ce <spaceHexString+0xae>
mov    $0x2,%ebx
cmp    $0xa0,%r14d
jl     1157 <spaceHexString+0x37>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
movsbl (%r15),%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11ce <spaceHexString+0xae>
mov    $0x1,%ebp
jmp    11a0 <spaceHexString+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
movsbl (%r15,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11ce <spaceHexString+0xae>
mov    %ebp,%eax
cltd
idiv   %r14d
test   %edx,%edx
jne    11b4 <spaceHexString+0x94>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0xa0,%eax
sub    %ebx,%eax
cmp    %r14d,%eax
jge    1180 <spaceHexString+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1180 <spaceHexString+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @spaceHexString(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %40
5: ; preds = %2
%6 = icmp sgt i32 %1, 159
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @putchar(i32 10)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ 1, %7 ], [ 2, %5 ]
%11 = load i8, i8* %0
%12 = sext i8 %11 to i32
%13 = tail call i32 @putchar(i32 %12)
%14 = tail call i32 @strlen(i8* %0)
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %40
16: ; preds = %9, %29
%17 = phi i64 [ %36, %29 ], [ 1, %9 ]
%18 = phi i32 [ %31, %29 ], [ %10, %9 ]
%19 = trunc i64 %17 to i32
%20 = srem i32 %19, %1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = tail call i32 @putchar(i32 32)
br label %24
24: ; preds = %22, %16
%25 = sub nsw i32 160, %18
%26 = icmp slt i32 %25, %1
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @putchar(i32 10)
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ 0, %27 ], [ %18, %24 ]
%31 = add nsw i32 %30, 1
%32 = getelementptr inbounds i8, i8* %0, i64 %17
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = tail call i32 @putchar(i32 %34)
%36 = add nuw nsw i64 %17, 1
%37 = tail call i32 @strlen(i8* %0)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %36, %38
br i1 %39, label %16, label %40
40: ; preds = %29, %9, %2
ret void
}