char *ltget_env(capname)
char *capname;
{
  char name[16];
  char *s;
  s = lgetenv("LESS_TERMCAP_DEBUG");
  if (s != 0 && *s != '\0') {
    struct env {
      struct env *next;
      char *name;
      char *value;
    };
    static struct env *envs = 0;
    struct env *p;
    for (p = envs; p != 0; p = p->next)
      if (strcmp(p->name, capname) == 0)
        return p->value;
    p = (struct env *)ecalloc(1, sizeof(struct env));
    p->name = save(capname);
    p->value = (char *)ecalloc(strlen(capname) + 3, sizeof(char));
    sprintf(p->value, "<%s>", capname);
    p->next = envs;
    envs = p;
    return p->value;
  }
  strcpy(name, "LESS_TERMCAP_");
  strcat(name, capname);
  return (lgetenv(name));
}


x86 assembly (clang, -O0):
<ltget_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   10a0 <lgetenv@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12a9 <ltget_env+0x129>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a9 <ltget_env+0x129>
mov    0x2ea6(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1211 <ltget_env+0x91>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11fc <ltget_env+0x7c>
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    12d7 <ltget_env+0x157>
jmp    1201 <ltget_env+0x81>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    11c6 <ltget_env+0x46>
mov    $0x1,%edi
mov    $0x18,%esi
mov    $0x0,%al
call   1040 <ecalloc@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <save@plt>
movslq %eax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x3,%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <ecalloc@plt>
movslq %eax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    0x2de2(%rip),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,0x2dd0(%rip)
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    12d7 <ltget_env+0x157>
lea    -0x20(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   10a0 <lgetenv@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltget_env>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1090 <lgetenv@plt>
test   %eax,%eax
je     123a <ltget_env+0xca>
cltq
cmpb   $0x0,(%rax)
je     123a <ltget_env+0xca>
mov    0x2ebc(%rip),%rbx
test   %rbx,%rbx
je     11cc <ltget_env+0x5c>
nopl   0x0(%rax)
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     127b <ltget_env+0x10b>
mov    (%rbx),%rbx
test   %rbx,%rbx
jne    11b0 <ltget_env+0x40>
mov    $0x18,%esi
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <ecalloc@plt>
movslq %eax,%r14
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <save@plt>
cltq
mov    %rax,0x8(%r14)
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x3(%rax),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <ecalloc@plt>
movslq %eax,%rdi
lea    0x10(%r14),%rbx
mov    %rdi,0x10(%r14)
lea    0xdf9(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    0x2e35(%rip),%rax
mov    %rax,(%r14)
mov    %r14,0x2e2b(%rip)
mov    (%rbx),%rax
jmp    1271 <ltget_env+0x101>
movabs $0x5f5041434d5245,%rax
mov    %rax,0x6(%rsp)
movabs $0x5245545f5353454c,%rax
54 45 52
mov    %rax,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <lgetenv@plt>
cltq
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0x10,%rbx
mov    (%rbx),%rax
jmp    1271 <ltget_env+0x101>

LLVM IR (-O0):
%struct.env = type { %struct.env*, i8*, i8* }
@.str = [19 x i8] c"LESS_TERMCAP_DEBUG\00"
@ltget_env.envs = internal global %struct.env* null
@.str.1 = [5 x i8] c"<%s>\00"
@.str.2 = [14 x i8] c"LESS_TERMCAP_\00"
define i8* @ltget_env(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [16 x i8]
%5 = alloca i8*
%6 = alloca %struct.env*
store i8* %0, i8** %3
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @lgetenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %68
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %68
17: ; preds = %12
%18 = load %struct.env*, %struct.env** @ltget_env.envs
store %struct.env* %18, %struct.env** %6
br label %19
19: ; preds = %34, %17
%20 = load %struct.env*, %struct.env** %6
%21 = icmp ne %struct.env* %20, null
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load %struct.env*, %struct.env** %6
%24 = getelementptr inbounds %struct.env, %struct.env* %23, i32 0, i32 1
%25 = load i8*, i8** %24
%26 = load i8*, i8** %3
%27 = call i32 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = load %struct.env*, %struct.env** %6
%31 = getelementptr inbounds %struct.env, %struct.env* %30, i32 0, i32 2
%32 = load i8*, i8** %31
store i8* %32, i8** %2
br label %78
33: ; preds = %22
br label %34
34: ; preds = %33
%35 = load %struct.env*, %struct.env** %6
%36 = getelementptr inbounds %struct.env, %struct.env* %35, i32 0, i32 0
%37 = load %struct.env*, %struct.env** %36
store %struct.env* %37, %struct.env** %6
br label %19
38: ; preds = %19
%39 = call i32 (i32, i64, ...) bitcast (i32 (...)* @ecalloc to i32 (i32, i64, ...)*)(i32 1, i64 24)
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to %struct.env*
store %struct.env* %41, %struct.env** %6
%42 = load i8*, i8** %3
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @save to i32 (i8*, ...)*)(i8* %42)
%44 = sext i32 %43 to i64
%45 = inttoptr i64 %44 to i8*
%46 = load %struct.env*, %struct.env** %6
%47 = getelementptr inbounds %struct.env, %struct.env* %46, i32 0, i32 1
store i8* %45, i8** %47
%48 = load i8*, i8** %3
%49 = call i64 @strlen(i8* %48)
%50 = add i64 %49, 3
%51 = call i32 (i64, i64, ...) bitcast (i32 (...)* @ecalloc to i32 (i64, i64, ...)*)(i64 %50, i64 1)
%52 = sext i32 %51 to i64
%53 = inttoptr i64 %52 to i8*
%54 = load %struct.env*, %struct.env** %6
%55 = getelementptr inbounds %struct.env, %struct.env* %54, i32 0, i32 2
store i8* %53, i8** %55
%56 = load %struct.env*, %struct.env** %6
%57 = getelementptr inbounds %struct.env, %struct.env* %56, i32 0, i32 2
%58 = load i8*, i8** %57
%59 = load i8*, i8** %3
%60 = call i32 (i8*, i8*, ...) @sprintf(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %59)
%61 = load %struct.env*, %struct.env** @ltget_env.envs
%62 = load %struct.env*, %struct.env** %6
%63 = getelementptr inbounds %struct.env, %struct.env* %62, i32 0, i32 0
store %struct.env* %61, %struct.env** %63
%64 = load %struct.env*, %struct.env** %6
store %struct.env* %64, %struct.env** @ltget_env.envs
%65 = load %struct.env*, %struct.env** %6
%66 = getelementptr inbounds %struct.env, %struct.env* %65, i32 0, i32 2
%67 = load i8*, i8** %66
store i8* %67, i8** %2
br label %78
68: ; preds = %12, %1
%69 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%70 = call i8* @strcpy(i8* %69, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%72 = load i8*, i8** %3
%73 = call i8* @strcat(i8* %71, i8* %72)
%74 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%75 = call i32 (i8*, ...) bitcast (i32 (...)* @lgetenv to i32 (i8*, ...)*)(i8* %74)
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i8*
store i8* %77, i8** %2
br label %78
78: ; preds = %68, %38, %29
%79 = load i8*, i8** %2
ret i8* %79
}

LLVM IR (-O2):
%struct.env = type { %struct.env*, i8*, i8* }
@.str = [19 x i8] c"LESS_TERMCAP_DEBUG\00"
@ltget_env.envs = internal unnamed_addr global %struct.env* null
@.str.1 = [5 x i8] c"<%s>\00"
@.str.2 = [14 x i8] c"LESS_TERMCAP_\00"
define i8* @ltget_env(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @lgetenv to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %46, label %6
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = inttoptr i64 %7 to i8*
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %46, label %11
11: ; preds = %6
%12 = load %struct.env*, %struct.env** @ltget_env.envs
%13 = icmp eq %struct.env* %12, null
br i1 %13, label %26, label %14
14: ; preds = %11, %22
%15 = phi %struct.env* [ %24, %22 ], [ %12, %11 ]
%16 = getelementptr inbounds %struct.env, %struct.env* %15, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(1) %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = getelementptr inbounds %struct.env, %struct.env* %15, i64 0, i32 2
br label %43
22: ; preds = %14
%23 = getelementptr inbounds %struct.env, %struct.env* %15, i64 0, i32 0
%24 = load %struct.env*, %struct.env** %23
%25 = icmp eq %struct.env* %24, null
br i1 %25, label %26, label %14
26: ; preds = %22, %11
%27 = tail call i32 (i32, i64, ...) bitcast (i32 (...)* @ecalloc to i32 (i32, i64, ...)*)(i32 1, i64 24)
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to %struct.env*
%30 = tail call i32 (i8*, ...) bitcast (i32 (...)* @save to i32 (i8*, ...)*)(i8* %0)
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
%33 = getelementptr inbounds %struct.env, %struct.env* %29, i64 0, i32 1
store i8* %32, i8** %33
%34 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%35 = add i64 %34, 3
%36 = tail call i32 (i64, i64, ...) bitcast (i32 (...)* @ecalloc to i32 (i64, i64, ...)*)(i64 %35, i64 1)
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i8*
%39 = getelementptr inbounds %struct.env, %struct.env* %29, i64 0, i32 2
store i8* %38, i8** %39
%40 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %38, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%41 = load %struct.env*, %struct.env** @ltget_env.envs
%42 = getelementptr inbounds %struct.env, %struct.env* %29, i64 0, i32 0
store %struct.env* %41, %struct.env** %42
store %struct.env* %29, %struct.env** @ltget_env.envs
br label %43
43: ; preds = %26, %20
%44 = phi i8** [ %21, %20 ], [ %39, %26 ]
%45 = load i8*, i8** %44
br label %51
46: ; preds = %6, %1
%47 = call i8* @strcat(i8* %3, i8* dereferenceable(1) %0)
%48 = call i32 (i8*, ...) bitcast (i32 (...)* @lgetenv to i32 (i8*, ...)*)(i8* %3)
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i8*
br label %51
51: ; preds = %46, %43
%52 = phi i8* [ %45, %43 ], [ %50, %46 ]
ret i8* %52
}