#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 */
typedef int int32_t;

/* Variables and functions */
char *optima_seek_line(char *str, int32_t len) {
  int i;
  for (i = 0; i < len; i++) {
    while (1) {
      char tmp = *str++;
      if (tmp == '\0')
        return NULL;
      if (tmp == '\n')
        break;
    }
  }
  return str;
}


x86 assembly (clang, -O0):
<optima_seek_line>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117b <optima_seek_line+0x7b>
jmp    1123 <optima_seek_line+0x23>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    1151 <optima_seek_line+0x51>
movq   $0x0,-0x8(%rbp)
jmp    1183 <optima_seek_line+0x83>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1163 <optima_seek_line+0x63>
jmp    1168 <optima_seek_line+0x68>
jmp    1123 <optima_seek_line+0x23>
jmp    116d <optima_seek_line+0x6d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1112 <optima_seek_line+0x12>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<optima_seek_line>:
mov    %rdi,%rax
test   %esi,%esi
jle    1150 <optima_seek_line+0x50>
xor    %r8d,%r8d
mov    $0x1,%edx
jmp    112d <optima_seek_line+0x2d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
test   %cl,%cl
cmove  %edx,%edi
test   %edi,%edi
jne    113e <optima_seek_line+0x3e>
movzbl (%rax),%ecx
mov    $0x6,%edi
cmp    $0xa,%cl
je     1120 <optima_seek_line+0x20>
xor    %edi,%edi
jmp    1120 <optima_seek_line+0x20>
cmp    $0x6,%edi
jne    114e <optima_seek_line+0x4e>
add    $0x1,%r8d
cmp    %esi,%r8d
jne    112d <optima_seek_line+0x2d>
jmp    1150 <optima_seek_line+0x50>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i8* @optima_seek_line(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %18
4: ; preds = %2, %15
%5 = phi i32 [ %16, %15 ], [ 0, %2 ]
%6 = phi i8* [ %9, %15 ], [ %0, %2 ]
br label %7
7: ; preds = %4, %7
%8 = phi i8* [ %9, %7 ], [ %6, %4 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 10
%12 = select i1 %11, i32 6, i32 0
%13 = icmp eq i8 %10, 0
%14 = select i1 %13, i32 1, i32 %12
switch i32 %14, label %18 [
i32 0, label %7
i32 6, label %15
]
15: ; preds = %7
%16 = add nuw nsw i32 %5, 1
%17 = icmp eq i32 %16, %1
br i1 %17, label %18, label %4
18: ; preds = %15, %7, %2
%19 = phi i8* [ %0, %2 ], [ null, %7 ], [ %9, %15 ]
ret i8* %19
}