#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*/ snprintf(char *, size_t const, char *, char const *, ...);
size_t strlen(char *);
size_t fillin_xml_column(const double val, char data[], const size_t sz_data,
                         const int is_monitored, const int is_column_present,
                         const char node_name[]) {
  size_t offset = 0;
  if (is_monitored) {
    snprintf(data, sz_data - 1, "\t<%s>%.1f</%s>\n", node_name, val, node_name);
    offset = strlen(data);
  } else if (is_column_present) {
    snprintf(data, sz_data - 1, "\t<%s></%s>\n", node_name, node_name);
    offset = strlen(data);
  }
  return offset;
}


x86 assembly (clang, -O0):
<fillin_xml_column>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118a <fillin_xml_column+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x28(%rbp),%rcx
movsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%r8
lea    0xe8f(%rip),%rdx
mov    $0x1,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
jmp    11c8 <fillin_xml_column+0xa8>
cmpl   $0x0,-0x20(%rbp)
je     11c3 <fillin_xml_column+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x28(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
jmp    11c8 <fillin_xml_column+0xa8>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillin_xml_column>:
push   %rbx
mov    %rdi,%rbx
test   %edx,%edx
je     1142 <fillin_xml_column+0x22>
add    $0xffffffffffffffff,%rsi
lea    0xecd(%rip),%rdx
mov    %rbx,%rdi
mov    %r8,%rcx
mov    $0x1,%al
call   1040 <snprintf@plt>
jmp    115e <fillin_xml_column+0x3e>
test   %ecx,%ecx
je     1167 <fillin_xml_column+0x47>
add    $0xffffffffffffffff,%rsi
lea    0xebf(%rip),%rdx
mov    %rbx,%rdi
mov    %r8,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <strlen@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\09<%s>%.1f</%s>\0A\00"
@.str.1 = [12 x i8] c"\09<%s></%s>\0A\00"
define i64 @fillin_xml_column(double %0, i8* %1, i64 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca double
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store double %0, double* %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
store i64 0, i64* %13
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %6
%17 = load i8*, i8** %8
%18 = load i64, i64* %9
%19 = sub i64 %18, 1
%20 = load i8*, i8** %12
%21 = load double, double* %7
%22 = load i8*, i8** %12
%23 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %17, i64 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %20, double %21, i8* %22)
%24 = load i8*, i8** %8
%25 = call i64 @strlen(i8* %24)
store i64 %25, i64* %13
br label %39
26: ; preds = %6
%27 = load i32, i32* %11
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i8*, i8** %8
%31 = load i64, i64* %9
%32 = sub i64 %31, 1
%33 = load i8*, i8** %12
%34 = load i8*, i8** %12
%35 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %30, i64 %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34)
%36 = load i8*, i8** %8
%37 = call i64 @strlen(i8* %36)
store i64 %37, i64* %13
br label %38
38: ; preds = %29, %26
br label %39
39: ; preds = %38, %16
%40 = load i64, i64* %13
ret i64 %40
}

LLVM IR (-O2):
@.str = [16 x i8] c"\09<%s>%.1f</%s>\0A\00"
@.str.1 = [12 x i8] c"\09<%s></%s>\0A\00"
define i64 @fillin_xml_column(double %0, i8* %1, i64 %2, i32 %3, i32 %4, i8* %5) {
%7 = icmp eq i32 %3, 0
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = add i64 %2, -1
%10 = tail call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %1, i64 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %5, double %0, i8* %5)
br label %16
11: ; preds = %6
%12 = icmp eq i32 %4, 0
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = add i64 %2, -1
%15 = tail call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %1, i64 %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %5)
br label %16
16: ; preds = %8, %13
%17 = tail call i64 @strlen(i8* dereferenceable(1) %1)
br label %18
18: ; preds = %16, %11
%19 = phi i64 [ 0, %11 ], [ %17, %16 ]
ret i64 %19
}