#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 strlen(char *);
void libwebsockets_00_spaceout(char *key, int spaces, int seed) {
  char *p;
  key++;
  while (spaces--) {
    if (*key && (seed & 1))
      key++;
    seed >>= 1;
    p = key + strlen(key);
    while (p >= key) {
      p[1] = p[0];
      p--;
    }
    *key++ = ' ';
  }
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11da <libwebsockets_00_spaceout+0xca>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116d <libwebsockets_00_spaceout+0x5d>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116d <libwebsockets_00_spaceout+0x5d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     11c3 <libwebsockets_00_spaceout+0xb3>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1197 <libwebsockets_00_spaceout+0x87>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x20,(%rax)
jmp    112e <libwebsockets_00_spaceout+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r14
push   %rbx
test   %esi,%esi
je     1181 <libwebsockets_00_spaceout+0x71>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rbp
jmp    113b <libwebsockets_00_spaceout+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sar    %ebx
movb   $0x20,0x0(%rbp)
test   %r14d,%r14d
je     1181 <libwebsockets_00_spaceout+0x71>
lea    0x1(%rbp),%rax
add    $0xffffffff,%r14d
lea    0x2(%rbp),%rcx
test   $0x1,%bl
cmove  %rax,%rcx
cmpb   $0x0,0x1(%rbp)
mov    %rcx,%rbp
cmove  %rax,%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     1130 <libwebsockets_00_spaceout+0x20>
mov    %eax,%eax
add    %rbp,%rax
nopw   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
mov    %cl,0x1(%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbp,%rax
jae    1170 <libwebsockets_00_spaceout+0x60>
jmp    1130 <libwebsockets_00_spaceout+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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