#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*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int make_xml(int count, char **list, char *buf) {
  char key[128] = {
      0,
  };
  char value[1024] = {
      0,
  };
  char temp[1024] = {
      0,
  };
  char *p1 = NULL, *p2 = NULL;
  int len = 0;
  int i = 0;
  if (list == NULL)
    return -1;
  for (i = 0; i < count; i++) {
    if (list[i][0] == '<' && (p2 = strchr(list[i], '>'))) {
      p1 = ++list[i];
      len = p2 - p1;
      strncpy(key, p1, (len < 128 ? len : 128));
      len = 0;
      p1 = ++p2;
      len = strlen(p1);
      strncpy(value, p1, (len < 1024 ? len : 1024));
      printf("\n%s \n%s\n", key, value);
    } else {
      continue;
    }
    sprintf(temp, "<%s>%s</%s>%s", key, value, key, " \n");
    strcat(buf, temp);
    temp[0] = '\0';
    printf(buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<make_xml>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8f0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x4a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x8a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
movq   $0x0,-0x8a8(%rbp)
movq   $0x0,-0x8b0(%rbp)
movl   $0x0,-0x8b4(%rbp)
movl   $0x0,-0x8b8(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1200 <make_xml+0x90>
movl   $0xffffffff,-0x4(%rbp)
jmp    1426 <make_xml+0x2b6>
movl   $0x0,-0x8b8(%rbp)
mov    -0x8b8(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    141f <make_xml+0x2af>
mov    -0x10(%rbp),%rax
movslq -0x8b8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    13b5 <make_xml+0x245>
mov    -0x10(%rbp),%rax
movslq -0x8b8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3e,%esi
call   1050 <strchr@plt>
mov    %rax,-0x8b0(%rbp)
cmp    $0x0,%rax
je     13b5 <make_xml+0x245>
mov    -0x10(%rbp),%rcx
movslq -0x8b8(%rbp),%rdx
mov    (%rcx,%rdx,8),%rax
add    $0x1,%rax
mov    %rax,(%rcx,%rdx,8)
mov    %rax,-0x8a8(%rbp)
mov    -0x8b0(%rbp),%rax
mov    -0x8a8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x8b4(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x8c8(%rbp)
mov    -0x8a8(%rbp),%rax
mov    %rax,-0x8c0(%rbp)
cmpl   $0x80,-0x8b4(%rbp)
jge    12d0 <make_xml+0x160>
mov    -0x8b4(%rbp),%eax
mov    %eax,-0x8cc(%rbp)
jmp    12e0 <make_xml+0x170>
mov    $0x80,%eax
mov    %eax,-0x8cc(%rbp)
jmp    12e0 <make_xml+0x170>
mov    -0x8c0(%rbp),%rsi
mov    -0x8c8(%rbp),%rdi
mov    -0x8cc(%rbp),%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x8b4(%rbp)
mov    -0x8b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8b0(%rbp)
mov    %rax,-0x8a8(%rbp)
mov    -0x8a8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8b4(%rbp)
lea    -0x4a0(%rbp),%rax
mov    %rax,-0x8e0(%rbp)
mov    -0x8a8(%rbp),%rax
mov    %rax,-0x8d8(%rbp)
cmpl   $0x400,-0x8b4(%rbp)
jge    136b <make_xml+0x1fb>
mov    -0x8b4(%rbp),%eax
mov    %eax,-0x8e4(%rbp)
jmp    137b <make_xml+0x20b>
mov    $0x400,%eax
mov    %eax,-0x8e4(%rbp)
jmp    137b <make_xml+0x20b>
mov    -0x8d8(%rbp),%rsi
mov    -0x8e0(%rbp),%rdi
mov    -0x8e4(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0xa0(%rbp),%rsi
lea    -0x4a0(%rbp),%rdx
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13ba <make_xml+0x24a>
jmp    140b <make_xml+0x29b>
lea    -0x8a0(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    -0x4a0(%rbp),%rcx
lea    -0xa0(%rbp),%r8
lea    0xc2c(%rip),%rsi
lea    0xc33(%rip),%r9
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
call   1080 <strcat@plt>
movb   $0x0,-0x8a0(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8b8(%rbp)
jmp    120a <make_xml+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_xml>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x898,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x490(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0x90(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
test   %r15,%r15
je     12ed <make_xml+0x17d>
test   %ebx,%ebx
jle    12f6 <make_xml+0x186>
mov    %ebx,%ebx
xor    %r14d,%r14d
jmp    120d <make_xml+0x9d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,%rbx
je     12f4 <make_xml+0x184>
mov    (%r15,%r14,8),%rbp
cmpb   $0x3c,0x0(%rbp)
jne    1200 <make_xml+0x90>
mov    %rbp,%rdi
mov    $0x3e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1200 <make_xml+0x90>
mov    %rax,%r13
add    $0x1,%rbp
mov    %rbp,(%r15,%r14,8)
mov    %r13d,%edx
sub    %ebp,%edx
cmp    $0x80,%edx
mov    $0x80,%eax
cmovge %eax,%edx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
add    $0x1,%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    $0x400,%eax
mov    $0x400,%ecx
cmovge %ecx,%eax
lea    0x490(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    0xd74(%rip),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%r13
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
lea    0xd5b(%rip),%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
lea    0xd59(%rip),%r9
call   1090 <sprintf@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rbx
call   1080 <strcat@plt>
movb   $0x0,0x90(%rsp)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1200 <make_xml+0x90>
mov    $0xffffffff,%ebp
jmp    12f6 <make_xml+0x186>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x898,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"\0A%s \0A%s\0A\00"
@.str.1 = [14 x i8] c"<%s>%s</%s>%s\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @make_xml(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca [128 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%15 = bitcast [128 x i8]* %8 to i8*
%16 = bitcast [1024 x i8]* %9 to i8*
%17 = bitcast [1024 x i8]* %10 to i8*
store i8* null, i8** %11
store i8* null, i8** %12
store i32 0, i32* %13
store i32 0, i32* %14
%18 = load i8**, i8*** %6
%19 = icmp eq i8** %18, null
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 -1, i32* %4
br label %101
21: ; preds = %3
store i32 0, i32* %14
br label %22
22: ; preds = %97, %21
%23 = load i32, i32* %14
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %100
26: ; preds = %22
%27 = load i8**, i8*** %6
%28 = load i32, i32* %14
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 60
br i1 %35, label %36, label %84
36: ; preds = %26
%37 = load i8**, i8*** %6
%38 = load i32, i32* %14
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i8* @strchr(i8* %41, i8 signext 62)
store i8* %42, i8** %12
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %84
44: ; preds = %36
%45 = load i8**, i8*** %6
%46 = load i32, i32* %14
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %48
store i8* %50, i8** %11
%51 = load i8*, i8** %12
%52 = load i8*, i8** %11
%53 = ptrtoint i8* %51 to i64
%54 = ptrtoint i8* %52 to i64
%55 = sub i64 %53, %54
%56 = trunc i64 %55 to i32
store i32 %56, i32* %13
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%58 = load i8*, i8** %11
%59 = load i32, i32* %13
%60 = icmp slt i32 %59, 128
br i1 %60, label %61, label %63
61: ; preds = %44
%62 = load i32, i32* %13
br label %64
63: ; preds = %44
br label %64
64: ; preds = %63, %61
%65 = phi i32 [ %62, %61 ], [ 128, %63 ]
%66 = call i32 @strncpy(i8* %57, i8* %58, i32 %65)
store i32 0, i32* %13
%67 = load i8*, i8** %12
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %12
store i8* %68, i8** %11
%69 = load i8*, i8** %11
%70 = call i32 @strlen(i8* %69)
store i32 %70, i32* %13
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%72 = load i8*, i8** %11
%73 = load i32, i32* %13
%74 = icmp slt i32 %73, 1024
br i1 %74, label %75, label %77
75: ; preds = %64
%76 = load i32, i32* %13
br label %78
77: ; preds = %64
br label %78
78: ; preds = %77, %75
%79 = phi i32 [ %76, %75 ], [ 1024, %77 ]
%80 = call i32 @strncpy(i8* %71, i8* %72, i32 %79)
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %81, i8* %82)
br label %85
84: ; preds = %36, %26
br label %97
85: ; preds = %78
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%87 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%89 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%90 = call i32 @sprintf(i8* %86, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %87, i8* %88, i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%91 = load i8*, i8** %7
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%93 = call i32 @strcat(i8* %91, i8* %92)
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
store i8 0, i8* %94
%95 = load i8*, i8** %7
%96 = call i32 (i8*, ...) @printf(i8* %95)
br label %97
97: ; preds = %85, %84
%98 = load i32, i32* %14
%99 = add nsw i32 %98, 1
store i32 %99, i32* %14
br label %22
100: ; preds = %22
store i32 0, i32* %4
br label %101
101: ; preds = %100, %20
%102 = load i32, i32* %4
ret i32 %102
}

LLVM IR (-O2):
@.str = [9 x i8] c"\0A%s \0A%s\0A\00"
@.str.1 = [14 x i8] c"<%s>%s</%s>%s\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @make_xml(i32 %0, i8** %1, i8* %2) {
%4 = alloca [128 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = icmp eq i8** %1, null
br i1 %10, label %45, label %11
11: ; preds = %3
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %45
13: ; preds = %11
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %42
%16 = phi i64 [ 0, %13 ], [ %43, %42 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 60
br i1 %20, label %21, label %42
21: ; preds = %15
%22 = call i8* @strchr(i8* %18, i8 signext 62)
%23 = icmp eq i8* %22, null
br i1 %23, label %42, label %24
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %18, i64 1
store i8* %25, i8** %17
%26 = ptrtoint i8* %22 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = icmp slt i32 %29, 128
%31 = select i1 %30, i32 %29, i32 128
%32 = call i32 @strncpy(i8* %7, i8* %25, i32 %31)
%33 = getelementptr inbounds i8, i8* %22, i64 1
%34 = call i32 @strlen(i8* %33)
%35 = icmp slt i32 %34, 1024
%36 = select i1 %35, i32 %34, i32 1024
%37 = call i32 @strncpy(i8* %8, i8* %33, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%39 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %8, i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @strcat(i8* %2, i8* %9)
store i8 0, i8* %9
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2)
br label %42
42: ; preds = %15, %21, %24
%43 = add nuw nsw i64 %16, 1
%44 = icmp eq i64 %43, %14
br i1 %44, label %45, label %15
45: ; preds = %42, %11, %3
%46 = phi i32 [ -1, %3 ], [ 0, %11 ], [ 0, %42 ]
ret i32 %46
}