#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*/ lineno;

/* Variables and functions */
scalar_t__ setenv(char *, char *, int);
int /*<<< orphan*/ sh_error(char *, int /*<<< orphan*/);
int const snprintf(char *, int const, char *, int /*<<< orphan*/);
void _lineno(void) {
  static unsigned int i = 1;
  char lineno[11];
  const int len = sizeof(lineno) - 1;
  if (snprintf(lineno, len, "%u", i++) >= len)
    lineno[len] = '\0';
  if (setenv("LINENO", lineno, 1) != 0)
    sh_error("setenv", 0);
}


x86 assembly (clang, -O0):
<_lineno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x10(%rbp)
lea    -0xb(%rbp),%rdi
mov    0x2eef(%rip),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,0x2ee4(%rip)
mov    $0xa,%esi
lea    0xea0(%rip),%rdx
call   1040 <snprintf@plt>
cmp    $0xa,%eax
jl     1172 <_lineno+0x42>
movb   $0x0,-0x1(%rbp)
lea    -0xb(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
je     119f <_lineno+0x6f>
lea    0xe72(%rip),%rdi
xor    %esi,%esi
call   1050 <sh_error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_lineno>:
sub    $0x18,%rsp
mov    0x2efe(%rip),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0x2ef5(%rip)
lea    0xeb6(%rip),%rdx
lea    0xd(%rsp),%rdi
mov    $0xa,%esi
call   1040 <snprintf@plt>
cmp    $0xa,%eax
jl     1163 <_lineno+0x33>
movb   $0x0,0x17(%rsp)
lea    0xe99(%rip),%rdi
lea    0xd(%rsp),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
test   %rax,%rax
je     118c <_lineno+0x5c>
lea    0xe85(%rip),%rdi
xor    %esi,%esi
call   1050 <sh_error@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@_lineno.i = internal global i32 1
@.str = [3 x i8] c"%u\00"
@.str.1 = [7 x i8] c"LINENO\00"
@.str.2 = [7 x i8] c"setenv\00"
define void @_lineno() {
%1 = alloca [11 x i8]
%2 = alloca i32
store i32 10, i32* %2
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @_lineno.i
%5 = add i32 %4, 1
store i32 %5, i32* @_lineno.i
%6 = call i32 @snprintf(i8* %3, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%7 = icmp sge i32 %6, 10
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 10
store i8 0, i8* %9
br label %10
10: ; preds = %8, %0
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%12 = call i64 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 1)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @sh_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %16
16: ; preds = %14, %10
ret void
}

LLVM IR (-O2):
@_lineno.i = internal unnamed_addr global i32 1
@.str = [3 x i8] c"%u\00"
@.str.1 = [7 x i8] c"LINENO\00"
@.str.2 = [7 x i8] c"setenv\00"
define void @_lineno() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @_lineno.i
%4 = add i32 %3, 1
store i32 %4, i32* @_lineno.i
%5 = call i32 @snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = icmp sgt i32 %5, 9
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 10
store i8 0, i8* %8
br label %9
9: ; preds = %7, %0
%10 = call i64 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @sh_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %14
14: ; preds = %12, %9
ret void
}