#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*/ printf(char *, unsigned char *);
void printbandiz(unsigned char *m, unsigned short len) {
  unsigned char *i, *j;
  i = j = m;
  while (i < m + len) {
    if (*i == 10) {
      *i = 0;
      printf("%s\n", j);
      j = i + 1;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<printbandiz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movzwl -0xa(%rbp),%edx
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    118e <printbandiz+0x7e>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
jne    117d <printbandiz+0x6d>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <printbandiz+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbandiz>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%eax
test   %esi,%esi
je     114f <printbandiz+0x3f>
mov    %rdi,%rsi
mov    %eax,%r15d
add    %rdi,%r15
lea    0xed5(%rip),%r14
mov    %rdi,%rbx
jmp    1139 <printbandiz+0x29>
add    $0x1,%rbx
cmp    %r15,%rbx
jae    114f <printbandiz+0x3f>
cmpb   $0xa,(%rbx)
jne    1130 <printbandiz+0x20>
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0x1(%rbx),%rsi
jmp    1130 <printbandiz+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @printbandiz(i8* %0, i16 zeroext %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i16 %1, i16* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %6
store i8* %7, i8** %5
br label %8
8: ; preds = %27, %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** %3
%11 = load i16, i16* %4
%12 = zext i16 %11 to i32
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = icmp ult i8* %9, %14
br i1 %15, label %16, label %30
16: ; preds = %8
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load i8*, i8** %5
store i8 0, i8* %22
%23 = load i8*, i8** %6
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %6
br label %27
27: ; preds = %21, %16
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
br label %8
30: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @printbandiz(i8* %0, i16 zeroext %1) {
%3 = zext i16 %1 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp eq i16 %1, 0
br i1 %5, label %18, label %6
6: ; preds = %2, %14
%7 = phi i8* [ %15, %14 ], [ %0, %2 ]
%8 = phi i8* [ %16, %14 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %14
11: ; preds = %6
store i8 0, i8* %8
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%13 = getelementptr inbounds i8, i8* %8, i64 1
br label %14
14: ; preds = %11, %6
%15 = phi i8* [ %13, %11 ], [ %7, %6 ]
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = icmp ult i8* %16, %4
br i1 %17, label %6, label %18
18: ; preds = %14, %2
ret void
}