#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_var_line(FILE *fp, char *line, char *name, char *var,
                       char *note) {
  int max_first_len = 48;
  int len = 0;
  if (name[0] == '\0') {
    return 0;
  }
  if (var[0] == '\0') {
    sprintf(line, "  %s = ", name);
  } else {
    sprintf(line, "  %s = \"%s\"", 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_line>:
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_line+0x46>
movl   $0x0,-0x4(%rbp)
jmp    12bb <vs_config_var_line+0x16b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c1 <vs_config_var_line+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    11db <vs_config_var_line+0x8b>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a0 <vs_config_var_line+0x150>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    122a <vs_config_var_line+0xda>
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    124f <vs_config_var_line+0xff>
mov    -0x18(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1060 <strcat@plt>
jmp    129b <vs_config_var_line+0x14b>
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     1296 <vs_config_var_line+0x146>
mov    -0x18(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   1060 <strcat@plt>
jmp    129b <vs_config_var_line+0x14b>
jmp    12a0 <vs_config_var_line+0x150>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd65(%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_line>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdx)
je     1208 <vs_config_var_line+0xb8>
mov    %r8,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x0,(%rcx)
je     1185 <vs_config_var_line+0x35>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
cmpb   $0x0,(%r15)
jne    119c <vs_config_var_line+0x4c>
jmp    11f6 <vs_config_var_line+0xa6>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sprintf@plt>
cmpb   $0x0,(%r15)
je     11f6 <vs_config_var_line+0xa6>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2f,%eax
jg     11c4 <vs_config_var_line+0x74>
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     11e7 <vs_config_var_line+0x97>
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     11f6 <vs_config_var_line+0xa6>
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe17(%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 = [8 x i8] c" %s = \00"
@.str.1 = [12 x i8] c" %s = \22%s\22\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [5 x i8] c"%s\0D\0A\00"
define i32 @vs_config_var_line(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%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 i8* %3, i8** %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 %91
20: ; preds = %5
%21 = load i8*, i8** %10
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i8*, i8** %8
%28 = load i8*, i8** %9
%29 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %35
30: ; preds = %20
%31 = load i8*, i8** %8
%32 = load i8*, i8** %9
%33 = load i8*, i8** %10
%34 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %30, %26
%36 = load i8*, i8** %11
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %87
41: ; preds = %35
%42 = load i8*, i8** %8
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %13
%44 = load i32, i32* %13
%45 = load i32, i32* %12
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %60
47: ; preds = %41
%48 = load i8*, i8** %8
%49 = load i32, i32* %13
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i32, i32* %12
%53 = load i32, i32* %13
%54 = sub nsw i32 %52, %53
%55 = call i32 @memset(i8* %51, i8 signext 32, i32 %54)
%56 = load i8*, i8** %8
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
br label %60
60: ; preds = %47, %41
%61 = load i8*, i8** %11
%62 = getelementptr inbounds i8, i8* %61, i64 0
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = load i8*, i8** %8
%68 = call i32 @strcat(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %86
69: ; preds = %60
%70 = load i8*, i8** %8
%71 = load i8*, i8** %11
%72 = call i32 @strcat(i8* %70, i8* %71)
%73 = load i8*, i8** %11
%74 = load i8*, i8** %11
%75 = call i32 @strlen(i8* %74)
%76 = sub nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %73, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp ne i32 %80, 10
br i1 %81, label %82, label %85
82: ; preds = %69
%83 = load i8*, i8** %8
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %82, %69
br label %86
86: ; preds = %85, %66
br label %87
87: ; preds = %86, %35
%88 = load i32*, i32** %7
%89 = load i8*, i8** %8
%90 = call i32 @fprintf(i32* %88, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %89)
store i32 0, i32* %6
br label %91
91: ; preds = %87, %19
%92 = load i32, i32* %6
ret i32 %92
}

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