#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*/ left(char *, char *, long);
int /*<<< orphan*/ mid(char *, char *, long);
long pos(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strip(char *, char *, char *);
char *parseword(char *target, char *source) {
  long ipos;
  if (target == NULL)
    return NULL;
  if (source == NULL)
    target[0] = '\0';
  else {
    strip(source, source, "L");
    ipos = pos(" ", source);
    if (ipos == 0) {
      strcpy(target, source);
      strcpy(source, "");
    } else {
      left(target, source, ipos - 1);
      mid(source, source, ipos);
      strip(source, source, "L");
    }
  }
  return target;
}


x86 assembly (clang, -O0):
<parseword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1178 <parseword+0x28>
movq   $0x0,-0x8(%rbp)
jmp    122b <parseword+0xdb>
cmpq   $0x0,-0x18(%rbp)
jne    118f <parseword+0x3f>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    1223 <parseword+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe62(%rip),%rdx
call   1060 <strip@plt>
mov    -0x18(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1070 <pos@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e4 <parseword+0x94>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcpy@plt>
jmp    121e <parseword+0xce>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
sub    $0x1,%rdx
call   1040 <left@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <mid@plt>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xde7(%rip),%rdx
call   1060 <strip@plt>
jmp    1223 <parseword+0xd3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseword>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     11e6 <parseword+0x96>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11c6 <parseword+0x76>
lea    0xe90(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <strip@plt>
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
call   1070 <pos@plt>
test   %rax,%rax
je     11cc <parseword+0x7c>
mov    %rax,%r15
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <left@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <mid@plt>
lea    0xe47(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <strip@plt>
jmp    11e6 <parseword+0x96>
movb   $0x0,(%r14)
jmp    11e6 <parseword+0x96>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"L\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @parseword(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* null, i8** %3
br label %46
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
br label %44
16: ; preds = %10
%17 = load i8*, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @strip(i8* %17, i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %5
%21 = call i64 @pos(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i64 %21, i64* %6
%22 = load i64, i64* %6
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %16
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %5
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %43
30: ; preds = %16
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = load i64, i64* %6
%34 = sub nsw i64 %33, 1
%35 = call i32 @left(i8* %31, i8* %32, i64 %34)
%36 = load i8*, i8** %5
%37 = load i8*, i8** %5
%38 = load i64, i64* %6
%39 = call i32 @mid(i8* %36, i8* %37, i64 %38)
%40 = load i8*, i8** %5
%41 = load i8*, i8** %5
%42 = call i32 @strip(i8* %40, i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %30, %24
br label %44
44: ; preds = %43, %13
%45 = load i8*, i8** %4
store i8* %45, i8** %3
br label %46
46: ; preds = %44, %9
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
@.str = [2 x i8] c"L\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @parseword(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %7
6: ; preds = %4
store i8 0, i8* %0
br label %19
7: ; preds = %4
%8 = tail call i32 @strip(i8* %1, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = tail call i64 @pos(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @strcpy(i8* %0, i8* %1)
%13 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %19
14: ; preds = %7
%15 = add nsw i64 %9, -1
%16 = tail call i32 @left(i8* %0, i8* %1, i64 %15)
%17 = tail call i32 @mid(i8* %1, i8* %1, i64 %9)
%18 = tail call i32 @strip(i8* %1, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %6, %14, %11, %2
ret i8* %0
}