#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*/ isspace(unsigned char const);
void copy_until_space(unsigned char *method, size_t sizeof_method,
                      unsigned *r_method_length, const unsigned char *px,
                      unsigned length, unsigned *r_offset) {
  while (*r_offset < length && !isspace(px[*r_offset])) {
    if (*r_method_length < sizeof_method)
      method[(*r_method_length)++] = px[*r_offset];
    (*r_offset)++;
  }
}


x86 assembly (clang, -O0):
<copy_until_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x31(%rbp)
jae    1162 <copy_until_space+0x52>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1172 <copy_until_space+0x62>
jmp    11b5 <copy_until_space+0xa5>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x10(%rbp),%rax
jae    11a5 <copy_until_space+0x95>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1130 <copy_until_space+0x20>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_until_space>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%r9),%eax
cmp    %r8d,%eax
jae    1178 <copy_until_space+0x68>
mov    %r9,%rbx
mov    %r8d,%r14d
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
jmp    114c <copy_until_space+0x3c>
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
cmp    %r14d,%eax
jae    1178 <copy_until_space+0x68>
mov    %eax,%eax
movzbl 0x0(%rbp,%rax,1),%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1178 <copy_until_space+0x68>
mov    (%r15),%eax
cmp    %r12,%rax
jae    1140 <copy_until_space+0x30>
mov    (%rbx),%ecx
movzbl 0x0(%rbp,%rcx,1),%ecx
lea    0x1(%rax),%edx
mov    %edx,(%r15)
mov    %cl,0x0(%r13,%rax,1)
jmp    1140 <copy_until_space+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @copy_until_space(i8* %0, i64 %1, i32* %2, i8* %3, i32 %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32* %5, i32** %12
br label %13
13: ; preds = %49, %6
%14 = load i32*, i32** %12
%15 = load i32, i32* %14
%16 = load i32, i32* %11
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load i8*, i8** %10
%20 = load i32*, i32** %12
%21 = load i32, i32* %20
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @isspace(i8 zeroext %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %18, %13
%29 = phi i1 [ false, %13 ], [ %27, %18 ]
br i1 %29, label %30, label %53
30: ; preds = %28
%31 = load i32*, i32** %9
%32 = load i32, i32* %31
%33 = zext i32 %32 to i64
%34 = load i64, i64* %8
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %30
%37 = load i8*, i8** %10
%38 = load i32*, i32** %12
%39 = load i32, i32* %38
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = load i8*, i8** %7
%44 = load i32*, i32** %9
%45 = load i32, i32* %44
%46 = add i32 %45, 1
store i32 %46, i32* %44
%47 = zext i32 %45 to i64
%48 = getelementptr inbounds i8, i8* %43, i64 %47
store i8 %42, i8* %48
br label %49
49: ; preds = %36, %30
%50 = load i32*, i32** %12
%51 = load i32, i32* %50
%52 = add i32 %51, 1
store i32 %52, i32* %50
br label %13
53: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @copy_until_space(i8* nocapture writeonly %0, i64 %1, i32* nocapture %2, i8* nocapture %3, i32 %4, i32* nocapture %5) {
%7 = load i32, i32* %5
%8 = icmp ult i32 %7, %4
br i1 %8, label %9, label %31
9: ; preds = %6, %27
%10 = phi i32 [ %29, %27 ], [ %7, %6 ]
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @isspace(i8 zeroext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %9
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = icmp ult i64 %18, %1
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %3, i64 %22
%24 = load i8, i8* %23
%25 = add i32 %17, 1
store i32 %25, i32* %2
%26 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 %24, i8* %26
br label %27
27: ; preds = %20, %16
%28 = load i32, i32* %5
%29 = add i32 %28, 1
store i32 %29, i32* %5
%30 = icmp ult i32 %29, %4
br i1 %30, label %9, label %31
31: ; preds = %9, %27, %6
ret void
}