#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*/ skip_space(char **);
char *strchr(char *, char);
int strlen(char *);
void next_line(char **str) {
  char *pos;
  int len;
  skip_space(str);
  pos = strchr(*str, '\n');
  if (pos) {
    (*str) = pos + 1;
  } else {
    len = strlen(*str);
    (*str) += len;
  }
  skip_space(str);
}


x86 assembly (clang, -O0):
<next_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <skip_space@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1179 <next_line+0x49>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    119b <next_line+0x6b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <skip_space@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <skip_space@plt>
mov    (%rbx),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1157 <next_line+0x27>
add    $0x1,%rax
jmp    1164 <next_line+0x34>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
add    (%rbx),%rax
mov    %rax,(%rbx)
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <skip_space@plt>

LLVM IR (-O0):
define void @next_line(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = call i32 @skip_space(i8** %5)
%7 = load i8**, i8*** %2
%8 = load i8*, i8** %7
%9 = call i8* @strchr(i8* %8, i8 signext 10)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8**, i8*** %2
store i8* %14, i8** %15
br label %25
16: ; preds = %1
%17 = load i8**, i8*** %2
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = load i8**, i8*** %2
%22 = load i8*, i8** %21
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8* %24, i8** %21
br label %25
25: ; preds = %16, %12
%26 = load i8**, i8*** %2
%27 = call i32 @skip_space(i8** %26)
ret void
}

LLVM IR (-O2):
define void @next_line(i8** %0) {
%2 = tail call i32 @skip_space(i8** %0)
%3 = load i8*, i8** %0
%4 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 10)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %13
8: ; preds = %1
%9 = tail call i32 @strlen(i8* %3)
%10 = load i8*, i8** %0
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %10, i64 %11
br label %13
13: ; preds = %8, %6
%14 = phi i8* [ %12, %8 ], [ %7, %6 ]
store i8* %14, i8** %0
%15 = tail call i32 @skip_space(i8** %0)
ret void
}