#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 */
int /*<<< orphan*/ EINVAL;
int _CS_POSIX_V6_ILP32_OFF32_CFLAGS;
int /*<<< orphan*/ errno;
size_t snprintf(char *, size_t, char *, char const *);
size_t confstr(int name, char *buf, size_t len) {
  const char *s = "";
  if (!name) {
    s = "/bin:/usr/bin";
  } else if ((name & ~4U) != 1 &&
             name - _CS_POSIX_V6_ILP32_OFF32_CFLAGS > 33U) {
    errno = EINVAL;
    return 0;
  }
  return snprintf(buf, len, "%s", s) + 1;
}


x86 assembly (clang, -O0):
<confstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xee3(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1148 <confstr+0x38>
lea    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1190 <confstr+0x80>
mov    -0xc(%rbp),%eax
and    $0xfffffffb,%eax
cmp    $0x1,%eax
je     118b <confstr+0x7b>
mov    -0xc(%rbp),%eax
mov    0x2e7f(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x21,%eax
jbe    118b <confstr+0x7b>
mov    0x2e5d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e5c(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11b0 <confstr+0xa0>
jmp    1190 <confstr+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    0xe6b(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confstr>:
push   %rax
test   %edi,%edi
je     114a <confstr+0x3a>
mov    %edi,%eax
and    $0xfffffffb,%eax
lea    0xeec(%rip),%rcx
cmp    $0x1,%eax
je     1151 <confstr+0x41>
mov    0x2eb3(%rip),%rax
sub    (%rax),%edi
cmp    $0x22,%edi
jb     1151 <confstr+0x41>
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    0x2e94(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
pop    %rcx
ret
lea    0xeaf(%rip),%rcx
lea    0xeb6(%rip),%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
call   1030 <snprintf@plt>
add    $0x1,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"/bin:/usr/bin\00"
@_CS_POSIX_V6_ILP32_OFF32_CFLAGS = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define i64 @confstr(i32 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %3
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %24
12: ; preds = %3
%13 = load i32, i32* %5
%14 = and i32 %13, -5
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* %5
%18 = load i32, i32* @_CS_POSIX_V6_ILP32_OFF32_CFLAGS
%19 = sub nsw i32 %17, %18
%20 = icmp ugt i32 %19, 33
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i32, i32* @EINVAL
store i32 %22, i32* @errno
store i64 0, i64* %4
br label %30
23: ; preds = %16, %12
br label %24
24: ; preds = %23, %11
%25 = load i8*, i8** %6
%26 = load i64, i64* %7
%27 = load i8*, i8** %8
%28 = call i64 @snprintf(i8* %25, i64 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = add i64 %28, 1
store i64 %29, i64* %4
br label %30
30: ; preds = %24, %21
%31 = load i64, i64* %4
ret i64 %31
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"/bin:/usr/bin\00"
@_CS_POSIX_V6_ILP32_OFF32_CFLAGS = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define i64 @confstr(i32 %0, i8* %1, i64 %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = and i32 %0, -5
%7 = icmp eq i32 %6, 1
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = load i32, i32* @_CS_POSIX_V6_ILP32_OFF32_CFLAGS
%10 = sub nsw i32 %0, %9
%11 = icmp ugt i32 %10, 33
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i32, i32* @EINVAL
store i32 %13, i32* @errno
br label %18
14: ; preds = %3, %5, %8
%15 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %3 ]
%16 = tail call i64 @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = add i64 %16, 1
br label %18
18: ; preds = %14, %12
%19 = phi i64 [ 0, %12 ], [ %17, %14 ]
ret i64 %19
}