#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*/ memcpy(char *, char *, int);
void next_field(char **line, char *output, int n) {
  char *l = *line;
  int i;
  memcpy(output, *line, n);
  *line = &l[n];
  for (i = n - 1; i > 0; i--) {
    if (output[i] != ' ')
      break;
    output[i] = '\0';
  }
}


x86 assembly (clang, -O0):
<next_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rcx
movslq -0x14(%rbp),%rax
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    119a <next_field+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1180 <next_field+0x70>
jmp    119a <next_field+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <next_field+0x4c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_field>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rdi),%rbp
mov    %rsi,%rdi
mov    %rbp,%rsi
call   1030 <memcpy@plt>
movslq %r14d,%rax
add    %rax,%rbp
mov    %rbp,(%r15)
cmp    $0x2,%eax
jl     1167 <next_field+0x57>
mov    %r14d,%eax
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x2(%rax),%ecx
cmpb   $0x20,(%rbx,%rcx,1)
jne    1167 <next_field+0x57>
movb   $0x0,(%rbx,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x2,%rax
ja     1150 <next_field+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @next_field(i8** nocapture %0, i8* %1, i32 %2) {
%4 = load i8*, i8** %0
%5 = tail call i32 @memcpy(i8* %1, i8* %4, i32 %2)
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %4, i64 %6
store i8* %7, i8** %0
%8 = icmp sgt i32 %2, 1
br i1 %8, label %9, label %20
9: ; preds = %3
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %18
%12 = phi i64 [ %10, %9 ], [ %13, %18 ]
%13 = add nsw i64 %12, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
br i1 %17, label %18, label %20
18: ; preds = %11
store i8 0, i8* %15
%19 = icmp ugt i64 %12, 2
br i1 %19, label %11, label %20
20: ; preds = %18, %11, %3
ret void
}