#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*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void output_function_xml_record(unsigned long int host, int port, time_t time,
                                char *data, int len) {
  printf("  <response host=\"%lu.%lu.%lu.%lu\" port=\"%d\" time=\"%d\">\n",
         ((host & 0xFF000000) >> 24), ((host & 0x00FF0000) >> 16),
         ((host & 0x0000FF00) >> 8), ((host & 0x000000FF) >> 0), port, time);
  int i;
  for (i = 0; i < len; ++i) {
    switch (data[i]) {
    case '"':
      printf("&quot;");
      break;
    case '<':
      printf("&gt;");
      break;
    case '>':
      printf("&lt;");
      break;
    case '&':
      printf("&amp;");
      break;
    case '%':
      printf("&#37;");
      break;
    default:
      printf("%c", data[i]);
      break;
    }
  }
  printf("  </response>\n");
}


x86 assembly (clang, -O0):
<output_function_xml_record>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movabs $0xff000000,%rsi
and    -0x8(%rbp),%rsi
shr    $0x18,%rsi
mov    -0x8(%rbp),%rdx
and    $0xff0000,%rdx
shr    $0x10,%rdx
mov    -0x8(%rbp),%rcx
and    $0xff00,%rcx
shr    $0x8,%rcx
mov    -0x8(%rbp),%r8
and    $0xff,%r8
shr    $0x0,%r8
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%eax
lea    0xefd(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1252 <output_function_xml_record+0x142>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1c,%eax
ja     1225 <output_function_xml_record+0x115>
mov    -0x28(%rbp),%rax
lea    0xe43(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <output_function_xml_record+0x12f>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <output_function_xml_record+0x12f>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <output_function_xml_record+0x12f>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <output_function_xml_record+0x12f>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <output_function_xml_record+0x12f>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <output_function_xml_record+0x134>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1188 <output_function_xml_record+0x78>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_function_xml_record>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rcx,%rbx
mov    %esi,%r9d
mov    %rdi,%rax
movzbl %ah,%ecx
movzbl %al,%r8d
mov    %eax,%esi
shr    $0x18,%esi
shr    $0x10,%edi
movzbl %dil,%eax
mov    %edx,(%rsp)
lea    0xf10(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    11e9 <output_function_xml_record+0xb9>
mov    %ebp,%r14d
lea    0xe84(%rip),%r15
lea    0xf31(%rip),%r13
lea    0xf2f(%rip),%rbp
xor    %r12d,%r12d
jmp    11b0 <output_function_xml_record+0x80>
lea    0xf17(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     11e9 <output_function_xml_record+0xb9>
movsbl (%rbx,%r12,1),%edi
lea    -0x22(%rdi),%eax
cmp    $0x1c,%eax
ja     11cf <output_function_xml_record+0x9f>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xef7(%rip),%rdi
jmp    11a0 <output_function_xml_record+0x70>
call   1030 <putchar@plt>
jmp    11a7 <output_function_xml_record+0x77>
lea    0xee1(%rip),%rdi
jmp    11a0 <output_function_xml_record+0x70>
mov    %r13,%rdi
jmp    11a0 <output_function_xml_record+0x70>
mov    %rbp,%rdi
jmp    11a0 <output_function_xml_record+0x70>
lea    0xeda(%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 = [57 x i8] c" <response host=\22%lu.%lu.%lu.%lu\22 port=\22%d\22 time=\22%d\22>\0A\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [6 x i8] c"&amp;\00"
@.str.5 = [6 x i8] c"&;\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [15 x i8] c" </response>\0A\00"
define void @output_function_xml_record(i64 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i64 %0, i64* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i64, i64* %6
%13 = and i64 %12, 4278190080
%14 = lshr i64 %13, 24
%15 = load i64, i64* %6
%16 = and i64 %15, 16711680
%17 = lshr i64 %16, 16
%18 = load i64, i64* %6
%19 = and i64 %18, 65280
%20 = lshr i64 %19, 8
%21 = load i64, i64* %6
%22 = and i64 %21, 255
%23 = lshr i64 %22, 0
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %17, i64 %20, i64 %23, i32 %24, i32 %25)
store i32 0, i32* %11
br label %27
27: ; preds = %57, %5
%28 = load i32, i32* %11
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %60
31: ; preds = %27
%32 = load i8*, i8** %9
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
switch i32 %37, label %48 [
i32 34, label %38
i32 60, label %40
i32 62, label %42
i32 38, label %44
i32 37, label %46
]
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %56
40: ; preds = %31
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %56
42: ; preds = %31
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %56
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %56
46: ; preds = %31
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %56
48: ; preds = %31
%49 = load i8*, i8** %9
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %48, %46, %44, %42, %40, %38
br label %57
57: ; preds = %56
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
br label %27
60: ; preds = %27
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c" <response host=\22%lu.%lu.%lu.%lu\22 port=\22%d\22 time=\22%d\22>\0A\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [6 x i8] c"&amp;\00"
@.str.5 = [6 x i8] c"&;\00"
@str = [14 x i8] c" </response>\00"
define void @output_function_xml_record(i64 %0, i32 %1, i32 %2, i8* nocapture %3, i32 %4) {
%6 = lshr i64 %0, 24
%7 = and i64 %6, 255
%8 = lshr i64 %0, 16
%9 = and i64 %8, 255
%10 = lshr i64 %0, 8
%11 = and i64 %10, 255
%12 = and i64 %0, 255
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 %7, i64 %9, i64 %11, i64 %12, i32 %1, i32 %2)
%14 = icmp sgt i32 %4, 0
br i1 %14, label %15, label %37
15: ; preds = %5
%16 = zext i32 %4 to i64
br label %17
17: ; preds = %15, %34
%18 = phi i64 [ 0, %15 ], [ %35, %34 ]
%19 = getelementptr inbounds i8, i8* %3, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %32 [
i32 34, label %22
i32 60, label %24
i32 62, label %26
i32 38, label %28
i32 37, label %30
]
22: ; preds = %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %34
24: ; preds = %17
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %34
26: ; preds = %17
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %34
28: ; preds = %17
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %34
30: ; preds = %17
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %34
32: ; preds = %17
%33 = tail call i32 @putchar(i32 %21)
br label %34
34: ; preds = %22, %24, %26, %28, %30, %32
%35 = add nuw nsw i64 %18, 1
%36 = icmp eq i64 %35, %16
br i1 %36, label %37, label %17
37: ; preds = %34, %5
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret void
}