#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 *, double const);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t const);
size_t fillin_text_column(const double val, char data[], const size_t sz_data,
                          const int is_monitored, const int is_column_present) {
  const char blank_column[] = "           ";
  size_t offset = 0;
  if (is_monitored) {
    snprintf(data, sz_data - 1, "%11.1f", val);
    offset = strlen(data);
  } else if (is_column_present) {
    strncpy(data, blank_column, sz_data - 1);
    offset = strlen(data);
  }
  return offset;
}


x86 assembly (clang, -O0):
<fillin_text_column>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11a0 <fillin_text_column+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    $0x1,%rsi
movsd  -0x8(%rbp),%xmm0
lea    0xe83(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
jmp    11d1 <fillin_text_column+0xa1>
cmpl   $0x0,-0x20(%rbp)
je     11cc <fillin_text_column+0x9c>
mov    -0x10(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    -0x18(%rbp),%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
jmp    11d1 <fillin_text_column+0xa1>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillin_text_column>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
movabs $0x2020202020202020,%rsi
20 20 20
mov    %rsi,(%rsp)
movl   $0x202020,0x8(%rsp)
test   %edx,%edx
je     1178 <fillin_text_column+0x48>
add    $0xffffffffffffffff,%rax
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <snprintf@plt>
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <strlen@plt>
test   %ecx,%ecx
je     1198 <fillin_text_column+0x68>
add    $0xffffffffffffffff,%rax
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
jmp    119a <fillin_text_column+0x6a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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