#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 *, char *);
int /*<<< orphan*/ reverseWords2(char *);
int main() {
  char s[] = " we love   leetcode  ";
  printf("original s: /%s/\n", s);
  reverseWords2(s);
  printf("after s: /%s/\n", s);
  char s2[] = "  leetcode  ";
  printf("original s2: /%s/\n", s2);
  reverseWords2(s2);
  printf("after s2: /%s/\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xebf(%rip),%ax
mov    %ax,-0xc(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <reverseWords2@plt>
lea    -0x20(%rbp),%rsi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    0xeae(%rip),%rax
mov    %rax,-0x2d(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x25(%rbp)
mov    0xea7(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2d(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x2d(%rbp),%rdi
call   1040 <reverseWords2@plt>
lea    -0x2d(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x202065646f6374,%r14
mov    %r14,0x1e(%rsp)
lea    0xecd(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <reverseWords2@plt>
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14,0x5(%rsp)
movabs $0x6f637465656c2020,%rax
74 63 6f
mov    %rax,(%rsp)
lea    0xebd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <reverseWords2@plt>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [22 x i8] c" we love leetcode \00"
@.str = [18 x i8] c"original s: /%s/\0A\00"
@.str.1 = [15 x i8] c"after s: /%s/\0A\00"
@__const.main.s2 = [13 x i8] c" leetcode \00"
@.str.2 = [19 x i8] c"original s2: /%s/\0A\00"
@.str.3 = [16 x i8] c"after s2: /%s/\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [22 x i8]
%3 = alloca [13 x i8]
store i32 0, i32* %1
%4 = bitcast [22 x i8]* %2 to i8*
%5 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%8 = call i32 @reverseWords2(i8* %7)
%9 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = bitcast [13 x i8]* %3 to i8*
%12 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%15 = call i32 @reverseWords2(i8* %14)
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [22 x i8] c" we love leetcode \00"
@.str = [18 x i8] c"original s: /%s/\0A\00"
@.str.1 = [15 x i8] c"after s: /%s/\0A\00"
@__const.main.s2 = [13 x i8] c" leetcode \00"
@.str.2 = [19 x i8] c"original s2: /%s/\0A\00"
@.str.3 = [16 x i8] c"after s2: /%s/\0A\00"
define i32 @main() {
%1 = alloca [22 x i8]
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @reverseWords2(i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 @reverseWords2(i8* %7)
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %7)
ret i32 0
}