#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 insertStrToStringAfterFirstSpace(char strToInsert[], char inStr[],
                                      int maxLen) {
  int i, j;
  for (i = 0; i < strlen(inStr); i++)
    if (inStr[i] == ' ')
      break;
  j = ++i;
  i = maxLen;
  for (; j < strlen(strToInsert) && j < i; j++)
    inStr[j] = strToInsert[i];
}


x86 assembly (clang, -O0):
<insertStrToStringAfterFirstSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1173 <insertStrToStringAfterFirstSpace+0x63>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1160 <insertStrToStringAfterFirstSpace+0x50>
jmp    1173 <insertStrToStringAfterFirstSpace+0x63>
jmp    1165 <insertStrToStringAfterFirstSpace+0x55>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <insertStrToStringAfterFirstSpace+0x1a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x21(%rbp)
jge    11b2 <insertStrToStringAfterFirstSpace+0xa2>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11c2 <insertStrToStringAfterFirstSpace+0xb2>
jmp    11e6 <insertStrToStringAfterFirstSpace+0xd6>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <insertStrToStringAfterFirstSpace+0x75>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertStrToStringAfterFirstSpace>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    1149 <insertStrToStringAfterFirstSpace+0x39>
nop
cmpb   $0x20,(%rbx,%rbp,1)
je     1149 <insertStrToStringAfterFirstSpace+0x39>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1130 <insertStrToStringAfterFirstSpace+0x20>
lea    0x1(%rbp),%r12d
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r12d
jge    1191 <insertStrToStringAfterFirstSpace+0x81>
cmp    %r14d,%r12d
jge    1191 <insertStrToStringAfterFirstSpace+0x81>
movslq %r14d,%r12
mov    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r15,%r12,1),%eax
mov    %al,0x1(%rbx,%rbp,1)
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0x2(%rbp),%ecx
cmp    %ecx,%eax
jle    1191 <insertStrToStringAfterFirstSpace+0x81>
add    $0x1,%rbp
cmp    %r14d,%ecx
jl     1170 <insertStrToStringAfterFirstSpace+0x60>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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