#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*/ outprintf(char *, ...);
void write_string(char *begin, char *end) {
  outprintf("\n/* Start of generated code */\n");
  for (char *iter = begin; iter < end; ++iter) {
    outprintf("%c", *iter);
  }
  outprintf("\n/* End of generated code */\n");
}


x86 assembly (clang, -O0):
<write_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <outprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    116a <write_string+0x5a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <outprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1136 <write_string+0x26>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <outprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xedb(%rip),%rdi
xor    %eax,%eax
call   1030 <outprintf@plt>
cmp    %r12,%r14
jae    1158 <write_string+0x48>
sub    %r14,%r12
lea    0xee5(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <outprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <write_string+0x30>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <outprintf@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\0A/* Start of generated code */\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [30 x i8] c"\0A/* End of generated code */\0A\00"
define void @write_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %17, %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp ult i8* %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
br label %8
20: ; preds = %8
%21 = call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A/* Start of generated code */\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [30 x i8] c"\0A/* End of generated code */\0A\00"
define void @write_string(i8* %0, i8* readnone %1) {
%3 = tail call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = icmp ult i8* %0, %1
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = getelementptr i8, i8* %0, i64 %8
br label %12
10: ; preds = %12, %2
%11 = tail call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
ret void
12: ; preds = %5, %12
%13 = phi i8* [ %17, %12 ], [ %0, %5 ]
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = tail call i32 (i8*, ...) @outprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = icmp eq i8* %17, %9
br i1 %18, label %10, label %12
}