char *mprog_next_command(char *clist) {
  char *pointer = clist;
  while (*pointer != '\n' && *pointer != '\0')
    pointer++;
  if (*pointer == '\n')
    *pointer++ = '\0';
  if (*pointer == '\r')
    *pointer++ = '\0';
  return (pointer);
}


x86 assembly (clang, -O0):
<mprog_next_command>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     1135 <mprog_next_command+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1145 <mprog_next_command+0x45>
jmp    1156 <mprog_next_command+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <mprog_next_command+0x10>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1178 <mprog_next_command+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    119a <mprog_next_command+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mprog_next_command>:
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rax
movzbl -0x1(%rax),%ecx
test   %cl,%cl
je     1132 <mprog_next_command+0x32>
cmp    $0xa,%cl
jne    1110 <mprog_next_command+0x10>
movb   $0x0,-0x1(%rax)
cmpb   $0xd,(%rax)
jne    1136 <mprog_next_command+0x36>
movb   $0x0,(%rax)
add    $0x1,%rax
ret
add    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
define i8* @mprog_next_command(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %17, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %5
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
store i8 0, i8* %26
br label %28
28: ; preds = %25, %20
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 13
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
store i8 0, i8* %34
br label %36
36: ; preds = %33, %28
%37 = load i8*, i8** %3
ret i8* %37
}

LLVM IR (-O2):
define i8* @mprog_next_command(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 10, label %7
i8 0, label %13
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 1
store i8 0, i8* %3
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 13
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %3, i64 2
store i8 0, i8* %8
br label %13
13: ; preds = %2, %11, %7
%14 = phi i8* [ %12, %11 ], [ %8, %7 ], [ %3, %2 ]
ret i8* %14
}