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


x86 assembly (clang, -O0):
<vs_config_var_line2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x30,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1196 <vs_config_var_line2+0x46>
movl   $0x0,-0x4(%rbp)
jmp    128e <vs_config_var_line2+0x13e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe57(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1273 <vs_config_var_line2+0x123>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11fd <vs_config_var_line2+0xad>
mov    -0x18(%rbp),%rdi
movslq -0x38(%rbp),%rax
add    %rax,%rdi
mov    -0x34(%rbp),%edx
sub    -0x38(%rbp),%edx
mov    $0x20,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1222 <vs_config_var_line2+0xd2>
mov    -0x18(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1060 <strcat@plt>
jmp    126e <vs_config_var_line2+0x11e>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1269 <vs_config_var_line2+0x119>
mov    -0x18(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1060 <strcat@plt>
jmp    126e <vs_config_var_line2+0x11e>
jmp    1273 <vs_config_var_line2+0x123>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd89(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vs_config_var_line2>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdx)
je     11e8 <vs_config_var_line2+0x98>
mov    %r8,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1070 <sprintf@plt>
cmpb   $0x0,(%r15)
je     11d6 <vs_config_var_line2+0x86>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2f,%eax
jg     11a4 <vs_config_var_line2+0x54>
movslq %eax,%rdi
add    %rbx,%rdi
mov    $0x30,%edx
sub    %eax,%edx
mov    $0x20,%esi
call   1040 <memset@plt>
movb   $0x0,0x30(%rbx)
cmpb   $0x0,(%r15)
je     11c7 <vs_config_var_line2+0x77>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r15,1)
je     11d6 <vs_config_var_line2+0x86>
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe2e(%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 = [11 x i8] c" %s = %ld\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%s\0D\0A\00"
define i32 @vs_config_var_line2(i32* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i32 48, i32* %12
store i32 0, i32* %13
%14 = load i8*, i8** %9
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %5
store i32 0, i32* %6
br label %80
20: ; preds = %5
%21 = load i8*, i8** %8
%22 = load i8*, i8** %9
%23 = load i64, i64* %10
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22, i64 %23)
%25 = load i8*, i8** %11
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %76
30: ; preds = %20
%31 = load i8*, i8** %8
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %13
%33 = load i32, i32* %13
%34 = load i32, i32* %12
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %30
%37 = load i8*, i8** %8
%38 = load i32, i32* %13
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i32, i32* %12
%42 = load i32, i32* %13
%43 = sub nsw i32 %41, %42
%44 = call i32 @memset(i8* %40, i8 signext 32, i32 %43)
%45 = load i8*, i8** %8
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 0, i8* %48
br label %49
49: ; preds = %36, %30
%50 = load i8*, i8** %11
%51 = getelementptr inbounds i8, i8* %50, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i8*, i8** %8
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %75
58: ; preds = %49
%59 = load i8*, i8** %8
%60 = load i8*, i8** %11
%61 = call i32 @strcat(i8* %59, i8* %60)
%62 = load i8*, i8** %11
%63 = load i8*, i8** %11
%64 = call i32 @strlen(i8* %63)
%65 = sub nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %62, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 10
br i1 %70, label %71, label %74
71: ; preds = %58
%72 = load i8*, i8** %8
%73 = call i32 @strcat(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %74
74: ; preds = %71, %58
br label %75
75: ; preds = %74, %55
br label %76
76: ; preds = %75, %20
%77 = load i32*, i32** %7
%78 = load i8*, i8** %8
%79 = call i32 @fprintf(i32* %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %78)
store i32 0, i32* %6
br label %80
80: ; preds = %76, %19
%81 = load i32, i32* %6
ret i32 %81
}

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