#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 */
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void toi_uu(char *str) {
  int i, j;
  char *newStr;
  newStr = malloc(100 * sizeof(char));
  i = 0;
  while (str[i] == ' ')
    i++;
  newStr = str + i;
  j = strlen(newStr);
  while (newStr[j - 1] == ' ')
    j--;
  newStr[j] = '\0';
  strcpy(str, newStr);
}


x86 assembly (clang, -O0):
<toi_uu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1174 <toi_uu+0x44>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <toi_uu+0x21>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11b7 <toi_uu+0x87>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    118f <toi_uu+0x5f>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toi_uu>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0xffffffffffffffff,%rax
nop
cmpb   $0x20,0x1(%rbx,%rax,1)
lea    0x1(%rax),%rax
je     1130 <toi_uu+0x10>
mov    %eax,%r15d
lea    (%rbx,%r15,1),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    %rcx,%rdx
shl    $0x20,%rdx
movabs $0x100000000,%rax
add    %rdx,%rax
add    %rbx,%rcx
add    %r15,%rcx
add    $0xffffffffffffffff,%rcx
movabs $0xffffffff00000000,%rdx
ff ff ff
cs nopw 0x0(%rax,%rax,1)
nop
add    %rdx,%rax
cmpb   $0x20,(%rcx)
lea    -0x1(%rcx),%rcx
je     1180 <toi_uu+0x60>
sar    $0x20,%rax
movb   $0x0,(%r14,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
define void @toi_uu(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 32
%7 = add nuw i64 %3, 1
br i1 %6, label %2, label %8
8: ; preds = %2
%9 = and i64 %3, 4294967295
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
br label %13
13: ; preds = %13, %8
%14 = phi i64 [ %15, %13 ], [ %12, %8 ]
%15 = add i64 %14, -1
%16 = getelementptr inbounds i8, i8* %10, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
br i1 %18, label %13, label %19
19: ; preds = %13
%20 = shl i64 %14, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds i8, i8* %10, i64 %21
store i8 0, i8* %22
%23 = tail call i32 @strcpy(i8* %0, i8* %10)
ret void
}