#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*/ rpgp_is_newline(char);
int rpgp_line_length(char *p) {
  int len = 0;
  while (*p && !rpgp_is_newline(*p)) {
    len++;
    p++;
  }
  return len;
}


x86 assembly (clang, -O0):
<rpgp_line_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     114f <rpgp_line_length+0x3f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <rpgp_is_newline@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    115f <rpgp_line_length+0x4f>
jmp    1179 <rpgp_line_length+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <rpgp_line_length+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpgp_line_length>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     113c <rpgp_line_length+0x2c>
mov    %rdi,%r14
xor    %ebx,%ebx
nop
movsbl %al,%edi
call   1030 <rpgp_is_newline@plt>
test   %eax,%eax
jne    113e <rpgp_line_length+0x2e>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1120 <rpgp_line_length+0x10>
jmp    113e <rpgp_line_length+0x2e>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @rpgp_line_length(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %17, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i32 @rpgp_is_newline(i8 signext %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br label %15
15: ; preds = %9, %4
%16 = phi i1 [ false, %4 ], [ %14, %9 ]
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %4
22: ; preds = %15
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @rpgp_line_length(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %10
%5 = phi i8 [ %13, %10 ], [ %2, %1 ]
%6 = phi i32 [ %11, %10 ], [ 0, %1 ]
%7 = phi i8* [ %12, %10 ], [ %0, %1 ]
%8 = tail call i32 @rpgp_is_newline(i8 signext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = add nuw nsw i32 %6, 1
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4, %10, %1
%16 = phi i32 [ 0, %1 ], [ %11, %10 ], [ %6, %4 ]
ret i32 %16
}