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

/* Variables and functions */
int CHAR_BIT;
int /*<<< orphan*/ EINVAL;
#define _CS_PATH 141
#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 140
#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 139
#define _CS_POSIX_V6_ILP32_OFF32_LIBS 138
#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 137
#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 136
#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 135
#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 134
#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 133
#define _CS_POSIX_V6_LP64_OFF64_LIBS 132
#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 131
#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 130
#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 129
#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 128
char *_PATH_STDPATH;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ strlcpy(char *, char const *, size_t);
int /*<<< orphan*/ strlen(char const *);
size_t confstr(int name, char *buf, size_t len) {
  const char *p;
  const char UPE[] = "unsupported programming environment";
  switch (name) {
  case _CS_PATH:
    p = _PATH_STDPATH;
    goto docopy;
  case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
  case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
  case _CS_POSIX_V6_ILP32_OFF32_LIBS:
  case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
  case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:
  case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:
    p = UPE;
    goto docopy;
  case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
  case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
  case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
    if (sizeof(long) * CHAR_BIT == 32 && sizeof(off_t) > sizeof(long))
      p = "";
    else
      p = UPE;
    goto docopy;
  case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
  case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
  case _CS_POSIX_V6_LP64_OFF64_LIBS:
    if (sizeof(long) * CHAR_BIT >= 64 && sizeof(void *) * CHAR_BIT >= 64 &&
        sizeof(int) * CHAR_BIT >= 32 && sizeof(off_t) >= sizeof(long))
      p = "";
    else
      p = UPE;
    goto docopy;
  case _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS:
    if (sizeof(long) * CHAR_BIT >= 64)
      p = "_POSIX_V6_LP64_OFF64";
    else
      p = "_POSIX_V6_ILP32_OFFBIG";
    goto docopy;
  docopy:
    if (len != 0 && buf != NULL)
      strlcpy(buf, p, len);
    return (strlen(p) + 1);
  default:
    errno = EINVAL;
    return (0);
  }
}


x86 assembly (clang, -O0):
<confstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movaps 0xf16(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0xefb(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movl   $0x746e65,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0xd,%eax
ja     12c7 <confstr+0x1a7>
mov    -0x58(%rbp),%rax
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1289 <confstr+0x169>
lea    -0x50(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1289 <confstr+0x169>
mov    0x2e40(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
cmp    $0x20,%rax
jne    11d0 <confstr+0xb0>
xor    %eax,%eax
test   $0x1,%al
jne    11c0 <confstr+0xa0>
jmp    11d0 <confstr+0xb0>
lea    0xeb1(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d8 <confstr+0xb8>
lea    -0x50(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1289 <confstr+0x169>
mov    0x2dfc(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
cmp    $0x40,%rax
jb     1244 <confstr+0x124>
mov    0x2de4(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
cmp    $0x40,%rax
jb     1244 <confstr+0x124>
mov    0x2dcc(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
cmp    $0x20,%rax
jb     1244 <confstr+0x124>
xor    %eax,%eax
test   $0x1,%al
jne    1234 <confstr+0x114>
jmp    1244 <confstr+0x124>
lea    0xe3d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    124c <confstr+0x12c>
lea    -0x50(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1289 <confstr+0x169>
mov    0x2d88(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
cmp    $0x40,%rax
jb     1279 <confstr+0x159>
lea    0xdf4(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1284 <confstr+0x164>
lea    0xdf9(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1289 <confstr+0x169>
cmpq   $0x0,-0x20(%rbp)
je     12b0 <confstr+0x190>
cmpq   $0x0,-0x18(%rbp)
je     12b0 <confstr+0x190>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <strlcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    12e1 <confstr+0x1c1>
mov    0x2cfa(%rip),%rax
mov    (%rax),%ecx
mov    0x2cf9(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confstr>:
push   %rbx
sub    $0x30,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x746e65,0x20(%rsp)
lea    -0x81(%rdi),%eax
cmp    $0xc,%eax
jae    117a <confstr+0x5a>
mov    %rsp,%rbx
test   %rsi,%rsi
je     1167 <confstr+0x47>
test   %rdx,%rdx
je     1167 <confstr+0x47>
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1040 <strlcpy@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
add    $0x30,%rsp
pop    %rbx
ret
cmp    $0x80,%edi
je     1196 <confstr+0x76>
cmp    $0x8d,%edi
jne    11c1 <confstr+0xa1>
mov    0x2e47(%rip),%rax
mov    (%rax),%rbx
jmp    1152 <confstr+0x32>
mov    0x2e43(%rip),%rax
movslq (%rax),%rax
movabs $0x1ffffffffffffff8,%rcx
ff ff 1f
test   %rcx,%rax
lea    0xe85(%rip),%rax
lea    0xe69(%rip),%rbx
cmove  %rax,%rbx
jmp    1152 <confstr+0x32>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    0x2dff(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
jmp    1174 <confstr+0x54>

LLVM IR (-O0):
@__const.confstr.UPE = [36 x i8] c"unsupported programming environment\00"
@_PATH_STDPATH = global i8* null
@CHAR_BIT = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [21 x i8] c"_POSIX_V6_LP64_OFF64\00"
@.str.2 = [23 x i8] c"_POSIX_V6_ILP32_OFFBIG\00"
@EINVAL = global i32 0
@errno = global i32 0
define i64 @confstr(i32 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca [36 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%10 = bitcast [36 x i8]* %9 to i8*
%11 = load i32, i32* %5
switch i32 %11, label %70 [
i32 141, label %12
i32 140, label %14
i32 139, label %14
i32 138, label %14
i32 131, label %14
i32 130, label %14
i32 129, label %14
i32 137, label %16
i32 136, label %16
i32 135, label %16
i32 134, label %26
i32 133, label %26
i32 132, label %26
i32 128, label %46
]
12: ; preds = %3
%13 = load i8*, i8** @_PATH_STDPATH
store i8* %13, i8** %8
br label %54
14: ; preds = %3, %3, %3, %3, %3, %3
%15 = getelementptr inbounds [36 x i8], [36 x i8]* %9, i64 0, i64 0
store i8* %15, i8** %8
br label %54
16: ; preds = %3, %3, %3
%17 = load i32, i32* @CHAR_BIT
%18 = sext i32 %17 to i64
%19 = mul i64 8, %18
%20 = icmp eq i64 %19, 32
br i1 %20, label %21, label %23
21: ; preds = %16
br i1 false, label %22, label %23
22: ; preds = %21
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %25
23: ; preds = %21, %16
%24 = getelementptr inbounds [36 x i8], [36 x i8]* %9, i64 0, i64 0
store i8* %24, i8** %8
br label %25
25: ; preds = %23, %22
br label %54
26: ; preds = %3, %3, %3
%27 = load i32, i32* @CHAR_BIT
%28 = sext i32 %27 to i64
%29 = mul i64 8, %28
%30 = icmp uge i64 %29, 64
br i1 %30, label %31, label %43
31: ; preds = %26
%32 = load i32, i32* @CHAR_BIT
%33 = sext i32 %32 to i64
%34 = mul i64 8, %33
%35 = icmp uge i64 %34, 64
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = load i32, i32* @CHAR_BIT
%38 = sext i32 %37 to i64
%39 = mul i64 4, %38
%40 = icmp uge i64 %39, 32
br i1 %40, label %41, label %43
41: ; preds = %36
br i1 false, label %42, label %43
42: ; preds = %41
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %45
43: ; preds = %41, %36, %31, %26
%44 = getelementptr inbounds [36 x i8], [36 x i8]* %9, i64 0, i64 0
store i8* %44, i8** %8
br label %45
45: ; preds = %43, %42
br label %54
46: ; preds = %3
%47 = load i32, i32* @CHAR_BIT
%48 = sext i32 %47 to i64
%49 = mul i64 8, %48
%50 = icmp uge i64 %49, 64
br i1 %50, label %51, label %52
51: ; preds = %46
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %53
52: ; preds = %46
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %53
53: ; preds = %52, %51
br label %54
54: ; preds = %53, %45, %25, %14, %12
%55 = load i64, i64* %7
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %65
57: ; preds = %54
%58 = load i8*, i8** %6
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i8*, i8** %6
%62 = load i8*, i8** %8
%63 = load i64, i64* %7
%64 = call i32 @strlcpy(i8* %61, i8* %62, i64 %63)
br label %65
65: ; preds = %60, %57, %54
%66 = load i8*, i8** %8
%67 = call i32 @strlen(i8* %66)
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
store i64 %69, i64* %4
br label %72
70: ; preds = %3
%71 = load i32, i32* @EINVAL
store i32 %71, i32* @errno
store i64 0, i64* %4
br label %72
72: ; preds = %70, %65
%73 = load i64, i64* %4
ret i64 %73
}

LLVM IR (-O2):
@__const.confstr.UPE = [36 x i8] c"unsupported programming environment\00"
@_PATH_STDPATH = global i8* null
@CHAR_BIT = global i32 0
@.str.1 = [21 x i8] c"_POSIX_V6_LP64_OFF64\00"
@.str.2 = [23 x i8] c"_POSIX_V6_ILP32_OFFBIG\00"
@EINVAL = global i32 0
@errno = global i32 0
define i64 @confstr(i32 %0, i8* %1, i64 %2) {
%4 = alloca [36 x i8]
%5 = getelementptr inbounds [36 x i8], [36 x i8]* %4, i64 0, i64 0
switch i32 %0, label %25 [
i32 141, label %6
i32 140, label %14
i32 139, label %14
i32 138, label %14
i32 131, label %14
i32 130, label %14
i32 129, label %14
i32 137, label %14
i32 136, label %14
i32 135, label %14
i32 134, label %14
i32 133, label %14
i32 132, label %14
i32 128, label %8
]
6: ; preds = %3
%7 = load i8*, i8** @_PATH_STDPATH
br label %14
8: ; preds = %3
%9 = load i32, i32* @CHAR_BIT
%10 = sext i32 %9 to i64
%11 = and i64 %10, 2305843009213693944
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0)
br label %14
14: ; preds = %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %8, %6
%15 = phi i8* [ %7, %6 ], [ %13, %8 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ], [ %5, %3 ]
%16 = icmp ne i64 %2, 0
%17 = icmp ne i8* %1, null
%18 = and i1 %17, %16
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @strlcpy(i8* %1, i8* %15, i64 %2)
br label %21
21: ; preds = %19, %14
%22 = call i32 @strlen(i8* %15)
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
br label %27
25: ; preds = %3
%26 = load i32, i32* @EINVAL
store i32 %26, i32* @errno
br label %27
27: ; preds = %25, %21
%28 = phi i64 [ 0, %25 ], [ %24, %21 ]
ret i64 %28
}