#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*/ EnvActivateRouter(void *, char *);
int /*<<< orphan*/ EnvDeactivateRouter(void *, char *);
int /*<<< orphan*/ EnvPrintRouter(void *, char const *, char const *);
int /*<<< orphan*/ PutcDribbleBuffer(void *, char const);
int PrintDribble(void *theEnv, const char *logicalName, const char *str) {
  int i;
  for (i = 0; str[i] != '\0'; i++) {
    PutcDribbleBuffer(theEnv, str[i]);
  }
  EnvDeactivateRouter(theEnv, "dribble");
  EnvPrintRouter(theEnv, logicalName, str);
  EnvActivateRouter(theEnv, "dribble");
  return (1);
}


x86 assembly (clang, -O0):
<PrintDribble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1193 <PrintDribble+0x53>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <PutcDribbleBuffer@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <PrintDribble+0x1b>
mov    -0x8(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1060 <EnvDeactivateRouter@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <EnvPrintRouter@plt>
mov    -0x8(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1050 <EnvActivateRouter@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintDribble>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    (%rdx),%al
test   %al,%al
je     1176 <PrintDribble+0x36>
lea    0x1(%r14),%rbx
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r13,%rdi
call   1030 <PutcDribbleBuffer@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <PrintDribble+0x20>
lea    0xe83(%rip),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <EnvDeactivateRouter@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <EnvPrintRouter@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <EnvActivateRouter@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"dribble\00"
define i32 @PrintDribble(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %24, %3
%9 = load i8*, i8** %6
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %8
%17 = load i8*, i8** %4
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @PutcDribbleBuffer(i8* %17, i8 signext %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %8
27: ; preds = %8
%28 = load i8*, i8** %4
%29 = call i32 @EnvDeactivateRouter(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = load i8*, i8** %6
%33 = call i32 @EnvPrintRouter(i8* %30, i8* %31, i8* %32)
%34 = load i8*, i8** %4
%35 = call i32 @EnvActivateRouter(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [8 x i8] c"dribble\00"
define i32 @PrintDribble(i8* %0, i8* %1, i8* %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i64 [ %10, %6 ], [ 0, %3 ]
%8 = phi i8 [ %12, %6 ], [ %4, %3 ]
%9 = tail call i32 @PutcDribbleBuffer(i8* %0, i8 signext %8)
%10 = add nuw i64 %7, 1
%11 = getelementptr inbounds i8, i8* %2, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %3
%15 = tail call i32 @EnvDeactivateRouter(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @EnvPrintRouter(i8* %0, i8* %1, i8* %2)
%17 = tail call i32 @EnvActivateRouter(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 1
}