#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 *, ...);
void printDataElements(char *data, int length) {
  int i;
  printf("Printing %d dataelements\n", length);
  for (i = 0; i < length; i++) {
    if ((i + 1) % 50 == 0)
      printf("\n");
    printf("%c", data[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printDataElements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1190 <printDataElements+0x80>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1168 <printDataElements+0x58>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <printDataElements+0x27>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDataElements>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    118c <printDataElements+0x6c>
mov    %ebp,%r15d
mov    $0x1,%ebx
xor    %ebp,%ebp
jmp    1165 <printDataElements+0x45>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    %r12,%rbp
cmp    %r12,%r15
je     118c <printDataElements+0x6c>
lea    0x1(%rbp),%r12
mov    %ebx,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x24,%rax
imul   $0x32,%eax,%eax
add    $0xffffffff,%eax
cmp    %ebp,%eax
jne    1150 <printDataElements+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <printDataElements+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [26 x i8] c"Printing %d dataelements\0A\00"
define void @printDataElements(i8* nocapture %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %9, %15 ]
%9 = add nuw nsw i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = urem i32 %10, 50
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @putchar(i32 10)
br label %15
15: ; preds = %13, %7
%16 = getelementptr inbounds i8, i8* %0, i64 %8
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = tail call i32 @putchar(i32 %18)
%20 = icmp eq i64 %9, %6
br i1 %20, label %21, label %7
21: ; preds = %15, %2
%22 = tail call i32 @putchar(i32 10)
ret void
}