#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*/ free(char *);
char *pl_strip(char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int main() {
  char whitespace[] = "   lots of space   ";
  char cool_nick[] = "xxxxTheDude99xxxx";
  char *ret_val = NULL;
  ret_val = pl_strip(whitespace, NULL);
  if (ret_val != NULL) {
    printf("Original: %s\nStriped: %s\n", whitespace, ret_val);
    free(ret_val);
  }
  ret_val = pl_strip(cool_nick, "x");
  if (ret_val != NULL) {
    printf("Striped: %s\n", ret_val);
    free(ret_val);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb5(%rip),%ax
mov    %ax,-0x30(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pl_strip@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     11c2 <main+0x92>
lea    -0x20(%rbp),%rsi
mov    -0x48(%rbp),%rdx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
lea    -0x40(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <pl_strip@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     11fc <main+0xcc>
mov    -0x48(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x202020,0x10(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movw   $0x78,0x30(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <pl_strip@plt>
test   %rax,%rax
je     1189 <main+0x59>
mov    %rax,%rbx
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xebc(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1050 <pl_strip@plt>
test   %rax,%rax
je     11bb <main+0x8b>
mov    %rax,%rbx
lea    0xe96(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.whitespace = [20 x i8] c" lots of space \00"
@__const.main.cool_nick = [18 x i8] c"xxxxTheDude99xxxx\00"
@.str = [26 x i8] c"Original: %s\0AStriped: %s\0A\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [13 x i8] c"Striped: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [18 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [20 x i8]* %2 to i8*
%6 = bitcast [18 x i8]* %3 to i8*
store i8* null, i8** %4
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = call i8* @pl_strip(i8* %7, i8* null)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
br label %17
17: ; preds = %11, %0
%18 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%19 = call i8* @pl_strip(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %22, %17
ret i32 0
}

LLVM IR (-O2):
@__const.main.whitespace = [20 x i8] c" lots of space \00"
@__const.main.cool_nick = [18 x i8] c"xxxxTheDude99xxxx\00"
@.str = [26 x i8] c"Original: %s\0AStriped: %s\0A\00"
@.str.1 = [2 x i8] c"x\00"
@.str.2 = [13 x i8] c"Striped: %s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [18 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%5 = call i8* @pl_strip(i8* %3, i8* null)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %5)
%9 = call i32 @free(i8* %5)
br label %10
10: ; preds = %7, %0
%11 = call i8* @pl_strip(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%15 = call i32 @free(i8* %11)
br label %16
16: ; preds = %13, %10
ret i32 0
}