#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int vs_config_box_line(FILE *fp, char *line, char *name, char *note) {
  int max_first_len = 48;
  int len = 0;
  sprintf(line, "[%s]", name);
  if (note[0] != '\0') {
    len = strlen(line);
    if (len < max_first_len) {
      memset(line + len, ' ', max_first_len - len);
      line[max_first_len] = '\0';
    }
    strcat(line, note);
  }
  fprintf(fp, "%s\r\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<vs_config_box_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x30,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e6 <vs_config_box_line+0x96>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d9 <vs_config_box_line+0x89>
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
mov    -0x24(%rbp),%edx
sub    -0x28(%rbp),%edx
mov    $0x20,%esi
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe10(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vs_config_box_line>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <sprintf@plt>
cmpb   $0x0,(%r15)
je     11a6 <vs_config_box_line+0x56>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2f,%eax
jg     119b <vs_config_box_line+0x4b>
movslq %eax,%rdi
add    %rbx,%rdi
mov    $0x30,%edx
sub    %eax,%edx
mov    $0x20,%esi
call   1040 <memset@plt>
movb   $0x0,0x30(%rbx)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
lea    0xe58(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"[%s]\00"
@.str.1 = [5 x i8] c"%s\0D\0A\00"
define i32 @vs_config_box_line(i32* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 48, i32* %9
store i32 0, i32* %10
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %8
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %42
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = load i32, i32* %9
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %19
%26 = load i8*, i8** %6
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = sub nsw i32 %30, %31
%33 = call i32 @memset(i8* %29, i8 signext 32, i32 %32)
%34 = load i8*, i8** %6
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %25, %19
%39 = load i8*, i8** %6
%40 = load i8*, i8** %8
%41 = call i32 @strcat(i8* %39, i8* %40)
br label %42
42: ; preds = %38, %4
%43 = load i32*, i32** %5
%44 = load i8*, i8** %6
%45 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"[%s]\00"
@.str.1 = [5 x i8] c"%s\0D\0A\00"
define i32 @vs_config_box_line(i32* nocapture %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %4
%9 = tail call i32 @strlen(i8* %1)
%10 = icmp slt i32 %9, 48
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = sext i32 %9 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = sub nsw i32 48, %9
%15 = tail call i32 @memset(i8* %13, i8 signext 32, i32 %14)
%16 = getelementptr inbounds i8, i8* %1, i64 48
store i8 0, i8* %16
br label %17
17: ; preds = %11, %8
%18 = tail call i32 @strcat(i8* %1, i8* %3)
br label %19
19: ; preds = %17, %4
%20 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1)
ret i32 0
}