#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ RB_XMLDB_Generate_Char(int /*<<< orphan*/ *, unsigned char);
int strlen(char *);
void RB_XMLDB_Generate_String(FILE *dest_doc, char *a_string) {
  int i;
  int l = strlen(a_string);
  unsigned char c;
  for (i = 0; i < l; ++i) {
    c = a_string[i];
    RB_XMLDB_Generate_Char(dest_doc, c);
  }
}


x86 assembly (clang, -O0):
<RB_XMLDB_Generate_String>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1178 <RB_XMLDB_Generate_String+0x58>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x19(%rbp),%esi
call   1040 <RB_XMLDB_Generate_Char@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <RB_XMLDB_Generate_String+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RB_XMLDB_Generate_String>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1156 <RB_XMLDB_Generate_String+0x36>
mov    %eax,%r12d
xor    %ebx,%ebx
nop
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1040 <RB_XMLDB_Generate_Char@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <RB_XMLDB_Generate_String+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @RB_XMLDB_Generate_String(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
store i32 0, i32* %5
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* %7
%20 = load i32*, i32** %3
%21 = load i8, i8* %7
%22 = call i32 @RB_XMLDB_Generate_Char(i32* %20, i8 zeroext %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %10
26: ; preds = %10
ret void
}

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