#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 *, ...);
int strlen(char *);
void printFormatedString(char *string) {
  int i = 0;
  for (i = 0; i < strlen(string); i++) {
    printf("%c", string[i]);
    if ((i + 1) % 80 == 0) {
      printf("\n");
    }
  }
  printf("\n\n");
  return;
}


x86 assembly (clang, -O0):
<printFormatedString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11a8 <printFormatedString+0x88>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x50,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1195 <printFormatedString+0x75>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119a <printFormatedString+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <printFormatedString+0x1a>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFormatedString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1050 <strlen@plt>
test   %eax,%eax
jle    11a7 <printFormatedString+0x77>
mov    $0x1,%ebp
xor    %r12d,%r12d
mov    $0xcccccccd,%r14d
jmp    1172 <printFormatedString+0x42>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
add    $0x1,%ebp
cmp    %rax,%r12
jge    11a7 <printFormatedString+0x77>
mov    %r12,%r13
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x26,%rax
lea    (%rax,%rax,4),%ebx
shl    $0x4,%ebx
add    $0xffffffff,%ebx
movsbl (%r15,%r12,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %r13d,%ebx
jne    1160 <printFormatedString+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <printFormatedString+0x30>
lea    0xe52(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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