#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 swap_characters_in_word(char *words, int start_of_word) {
  int counterPos = 0;
  int counterNeg = 0;
  int get_length;
  int end_of_word;
  char temporary;
  get_length = strlen(words);
  words[get_length - 1] = ' ';
  for (counterPos = 0; words[counterPos] != '\0'; counterPos++) {
    if ((words[counterPos] == ' ') && (words[counterPos - 1] != ' ')) {
      end_of_word = counterPos - 1;
      for (counterNeg = (counterPos - 1);
           words[counterNeg] != '\0' && words[counterNeg] != ' ';
           counterNeg--) {
        start_of_word = counterNeg;
      }
      for (end_of_word = counterPos - 1; end_of_word >= start_of_word;
           end_of_word--) {
        temporary = words[end_of_word];
        words[end_of_word] = words[start_of_word];
        words[start_of_word] = temporary;
        start_of_word++;
      }
    }
  }
}


x86 assembly (clang, -O0):
<swap_characters_in_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1270 <swap_characters_in_word+0x160>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    125d <swap_characters_in_word+0x14d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     125d <swap_characters_in_word+0x14d>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e(%rbp)
je     11d6 <swap_characters_in_word+0xc6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    11e6 <swap_characters_in_word+0xd6>
jmp    11fa <swap_characters_in_word+0xea>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <swap_characters_in_word+0x97>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1258 <swap_characters_in_word+0x148>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1d(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1203 <swap_characters_in_word+0xf3>
jmp    125d <swap_characters_in_word+0x14d>
jmp    1262 <swap_characters_in_word+0x152>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <swap_characters_in_word+0x41>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_characters_in_word>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
movb   $0x20,-0x1(%rax,%rbx,1)
mov    $0xffffffffffffffff,%r8
xor    %edi,%edi
jmp    113c <swap_characters_in_word+0x2c>
nop
test   %dl,%dl
je     11a7 <swap_characters_in_word+0x97>
add    $0x1,%rdi
add    $0x1,%r8
mov    (%rbx,%rdi,1),%dl
cmp    $0x20,%dl
jne    1130 <swap_characters_in_word+0x20>
cmpb   $0x20,-0x1(%rdi,%rbx,1)
je     1134 <swap_characters_in_word+0x24>
mov    %r8,%rdx
testb  $0xdf,(%rbx,%rdx,1)
je     116c <swap_characters_in_word+0x5c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edx,%ebp
add    $0xffffffffffffffff,%rdx
testb  $0xdf,(%rbx,%rdx,1)
jne    1160 <swap_characters_in_word+0x50>
movslq %ebp,%rdx
cmp    %rdx,%rdi
jle    1134 <swap_characters_in_word+0x24>
add    $0x1,%rdx
mov    %rdi,%rsi
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx,%rsi,1),%eax
movzbl -0x1(%rbx,%rdx,1),%ecx
mov    %cl,-0x1(%rbx,%rsi,1)
mov    %al,-0x1(%rbx,%rdx,1)
add    $0xffffffffffffffff,%rsi
lea    0x1(%rdx),%rax
add    $0x1,%ebp
cmp    %rdx,%rsi
mov    %rax,%rdx
jg     1180 <swap_characters_in_word+0x70>
jmp    1134 <swap_characters_in_word+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @swap_characters_in_word(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %7
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8 32, i8* %16
store i32 0, i32* %5
br label %17
17: ; preds = %104, %2
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %107
25: ; preds = %17
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %103
33: ; preds = %25
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 32
br i1 %41, label %42, label %103
42: ; preds = %33
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, 1
store i32 %44, i32* %8
%45 = load i32, i32* %5
%46 = sub nsw i32 %45, 1
store i32 %46, i32* %6
br label %47
47: ; preds = %67, %42
%48 = load i8*, i8** %3
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %63
55: ; preds = %47
%56 = load i8*, i8** %3
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 32
br label %63
63: ; preds = %55, %47
%64 = phi i1 [ false, %47 ], [ %62, %55 ]
br i1 %64, label %65, label %70
65: ; preds = %63
%66 = load i32, i32* %6
store i32 %66, i32* %4
br label %67
67: ; preds = %65
%68 = load i32, i32* %6
%69 = add nsw i32 %68, -1
store i32 %69, i32* %6
br label %47
70: ; preds = %63
%71 = load i32, i32* %5
%72 = sub nsw i32 %71, 1
store i32 %72, i32* %8
br label %73
73: ; preds = %99, %70
%74 = load i32, i32* %8
%75 = load i32, i32* %4
%76 = icmp sge i32 %74, %75
br i1 %76, label %77, label %102
77: ; preds = %73
%78 = load i8*, i8** %3
%79 = load i32, i32* %8
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i8, i8* %81
store i8 %82, i8* %9
%83 = load i8*, i8** %3
%84 = load i32, i32* %4
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = load i8*, i8** %3
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
store i8 %87, i8* %91
%92 = load i8, i8* %9
%93 = load i8*, i8** %3
%94 = load i32, i32* %4
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
store i8 %92, i8* %96
%97 = load i32, i32* %4
%98 = add nsw i32 %97, 1
store i32 %98, i32* %4
br label %99
99: ; preds = %77
%100 = load i32, i32* %8
%101 = add nsw i32 %100, -1
store i32 %101, i32* %8
br label %73
102: ; preds = %73
br label %103
103: ; preds = %102, %33, %25
br label %104
104: ; preds = %103
%105 = load i32, i32* %5
%106 = add nsw i32 %105, 1
store i32 %106, i32* %5
br label %17
107: ; preds = %17
ret void
}

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