#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*/ printletter(char, int, int, int, int);
int strlen(char *);
void printstring(char *str, int x, int y, int cp_on, int cp_off) {
  int q, l;
  l = strlen(str);
  for (q = 0; q < l; q++) {
    printletter(str[q], x + q * 8, y, cp_on, cp_off);
  }
}


x86 assembly (clang, -O0):
<printstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    118e <printstring+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
movsbl %al,%edi
call   1040 <printletter@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <printstring+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,0x4(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r13
call   1030 <strlen@plt>
test   %eax,%eax
jle    1174 <printstring+0x54>
mov    %eax,%ebx
xor    %r14d,%r14d
nopl   0x0(%rax)
movsbl 0x0(%r13,%r14,1),%edi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    0x4(%rsp),%r8d
call   1040 <printletter@plt>
add    $0x1,%r14
add    $0x8,%ebp
cmp    %r14,%rbx
jne    1150 <printstring+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @printstring(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %18, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = trunc i64 %11 to i32
%15 = shl i32 %14, 3
%16 = add i32 %15, %1
%17 = tail call i32 @printletter(i8 signext %13, i32 %16, i32 %2, i32 %3, i32 %4)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %10
20: ; preds = %10, %5
ret void
}