#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 */
scalar_t__ errno;
int fprintf(int /*<<< orphan*/ *, char *, char *);
char *getenv(char *);
int /*<<< orphan*/ memset(char *, char, int);
int strtoimax(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int _eindent(FILE *stream) {
  char *env = getenv("EINFO_INDENT");
  int amount = 0;
  char indent[40];
  if (env) {
    errno = 0;
    amount = strtoimax(env, NULL, 0);
    if (errno != 0 || amount < 0)
      amount = 0;
    else if (amount > 40)
      amount = 40;
    if (amount > 0)
      memset(indent, ' ', (size_t)amount);
  }
  memset(indent + amount, 0, 1);
  return fprintf(stream, "%s", indent);
}


x86 assembly (clang, -O0):
<_eindent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ee <_eindent+0xae>
mov    0x2e6b(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtoimax@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e4b(%rip),%rax
cmpq   $0x0,(%rax)
jne    11a9 <_eindent+0x69>
cmpl   $0x0,-0x14(%rbp)
jge    11b5 <_eindent+0x75>
movl   $0x0,-0x14(%rbp)
jmp    11cb <_eindent+0x8b>
cmpl   $0x28,-0x14(%rbp)
jle    11c6 <_eindent+0x86>
movl   $0x28,-0x14(%rbp)
jmp    11cb <_eindent+0x8b>
cmpl   $0x0,-0x14(%rbp)
jle    11e9 <_eindent+0xa9>
lea    -0x40(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    %eax,%edx
mov    $0x20,%esi
call   1050 <memset@plt>
jmp    11ee <_eindent+0xae>
lea    -0x40(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xdf9(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_eindent>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
lea    0xeac(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11a6 <_eindent+0x66>
mov    0x2e79(%rip),%r15
movq   $0x0,(%r15)
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtoimax@plt>
cmp    $0x28,%eax
mov    $0x28,%ebp
cmovl  %eax,%ebp
test   %eax,%eax
cmovs  %ebx,%ebp
cmpq   $0x0,(%r15)
cmovne %ebx,%ebp
test   %ebp,%ebp
jle    11a6 <_eindent+0x66>
mov    %rsp,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
mov    %ebp,%ebx
lea    (%rsp,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    0xe50(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   1060 <fprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"EINFO_INDENT\00"
@errno = global i64 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @_eindent(i32* nocapture %0) {
%2 = alloca [40 x i8]
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = icmp eq i8* %3, null
br i1 %5, label %19, label %6
6: ; preds = %1
store i64 0, i64* @errno
%7 = tail call i32 @strtoimax(i8* %3, i32* null, i32 0)
%8 = load i64, i64* @errno
%9 = icmp ne i64 %8, 0
%10 = icmp slt i32 %7, 0
%11 = select i1 %9, i1 true, i1 %10
%12 = icmp slt i32 %7, 40
%13 = select i1 %12, i32 %7, i32 40
%14 = select i1 %11, i32 0, i32 %13
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %6
%17 = call i32 @memset(i8* %4, i8 signext 32, i32 %14)
%18 = zext i32 %14 to i64
br label %19
19: ; preds = %6, %16, %1
%20 = phi i64 [ %18, %16 ], [ 0, %6 ], [ 0, %1 ]
%21 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %20
%22 = call i32 @memset(i8* %21, i8 signext 0, i32 1)
%23 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 %23
}