#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 */
scalar_t__ errno;
int /*<<< orphan*/ free(char *);
char *getenv(char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int strtoimax(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ xasprintf(char **, char *, int);
void eindent(void) {
  char *env = getenv("EINFO_INDENT");
  int amount = 0;
  char *num;
  if (env) {
    errno = 0;
    amount = strtoimax(env, NULL, 0);
    if (errno != 0)
      amount = 0;
  }
  amount += 2;
  if (amount > 40)
    amount = 40;
  xasprintf(&num, "%08d", amount);
  setenv("EINFO_INDENT", num, 1);
  free(num);
}


x86 assembly (clang, -O0):
<eindent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b7 <eindent+0x67>
mov    0x2e5f(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtoimax@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e3f(%rip),%rax
cmpq   $0x0,(%rax)
je     11b2 <eindent+0x62>
movl   $0x0,-0xc(%rbp)
jmp    11b7 <eindent+0x67>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x28,-0xc(%rbp)
jle    11d1 <eindent+0x81>
movl   $0x28,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    -0x18(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <xasprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x1,%edx
call   1060 <setenv@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eindent>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1030 <getenv@plt>
mov    $0x2,%ebx
test   %rax,%rax
je     1199 <eindent+0x49>
mov    0x2e6f(%rip),%r14
movq   $0x0,(%r14)
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtoimax@plt>
cmpq   $0x0,(%r14)
jne    1199 <eindent+0x49>
add    $0x2,%eax
mov    $0x28,%edx
mov    %eax,%ebx
cmp    $0x27,%eax
jg     119b <eindent+0x4b>
mov    %ebx,%edx
lea    0xe6b(%rip),%rsi
mov    %rsp,%rdi
call   1070 <xasprintf@plt>
mov    (%rsp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x1,%edx
call   1060 <setenv@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"EINFO_INDENT\00"
@errno = global i64 0
@.str.1 = [5 x i8] c"%08d\00"
define void @eindent() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
store i32 0, i32* %2
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %14
7: ; preds = %0
store i64 0, i64* @errno
%8 = load i8*, i8** %1
%9 = call i32 @strtoimax(i8* %8, i32* null, i32 0)
store i32 %9, i32* %2
%10 = load i64, i64* @errno
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
store i32 0, i32* %2
br label %13
13: ; preds = %12, %7
br label %14
14: ; preds = %13, %0
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 2
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 40
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 40, i32* %2
br label %20
20: ; preds = %19, %14
%21 = load i32, i32* %2
%22 = call i32 @xasprintf(i8** %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i8*, i8** %3
%24 = call i32 @setenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %23, i32 1)
%25 = load i8*, i8** %3
%26 = call i32 @free(i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"EINFO_INDENT\00"
@errno = global i64 0
@.str.1 = [5 x i8] c"%08d\00"
define void @eindent() {
%1 = alloca i8*
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i8** %1 to i8*
%4 = icmp eq i8* %2, null
br i1 %4, label %12, label %5
5: ; preds = %0
store i64 0, i64* @errno
%6 = tail call i32 @strtoimax(i8* %2, i32* null, i32 0)
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
%9 = add i32 %6, 2
br i1 %8, label %10, label %12
10: ; preds = %5
%11 = icmp slt i32 %9, 40
br i1 %11, label %12, label %14
12: ; preds = %0, %5, %10
%13 = phi i32 [ %9, %10 ], [ 2, %5 ], [ 2, %0 ]
br label %14
14: ; preds = %10, %12
%15 = phi i32 [ %13, %12 ], [ 40, %10 ]
%16 = call i32 @xasprintf(i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %1
%18 = call i32 @setenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17, i32 1)
%19 = load i8*, i8** %1
%20 = call i32 @free(i8* %19)
ret void
}