#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*/ nis_result;
typedef int /*<<< orphan*/ nis_error;
typedef int /*<<< orphan*/ leafbuf;
typedef int /*<<< orphan*/ domainbuf;
typedef char *const_nis_name;

/* Variables and functions */
int /*<<< orphan*/ NIS_FAIL;
int /*<<< orphan*/ NIS_RES_STATUS(int /*<<< orphan*/ *);
char *nis_domain_of_r(char *, char *, int);
int /*<<< orphan*/ nis_freeresult(int /*<<< orphan*/ *);
char *nis_leaf_of_r(char *, char *, int);
int /*<<< orphan*/ *nis_remove(char *, int /*<<< orphan*/ *);
char *stpcpy(char *, char *);
size_t strlen(char *);
nis_error nis_destroygroup(const_nis_name group) {
  if (group != NULL && group[0] != '\0') {
    size_t grouplen = strlen(group);
    char buf[grouplen + 50];
    char leafbuf[grouplen + 3];
    char domainbuf[grouplen + 3];
    nis_error status;
    nis_result *res;
    char *cp, *cp2;
    cp = stpcpy(buf, nis_leaf_of_r(group, leafbuf, sizeof(leafbuf) - 1));
    cp = stpcpy(cp, ".groups_dir");
    cp2 = nis_domain_of_r(group, domainbuf, sizeof(domainbuf) - 1);
    if (cp2 != NULL && cp2[0] != '\0') {
      *cp++ = '.';
      stpcpy(cp, cp2);
    }
    res = nis_remove(buf, NULL);
    status = NIS_RES_STATUS(res);
    nis_freeresult(res);
    return status;
  } else
    return NIS_FAIL;
}


x86 assembly (clang, -O0):
<nis_destroygroup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12da <nis_destroygroup+0x16a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12da <nis_destroygroup+0x16a>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    %rdx,%rax
add    $0x32,%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
add    $0x41,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0x3,%rax
add    $0x12,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    %rdi,%rcx
add    $0x3,%rcx
mov    %rcx,-0x60(%rbp)
add    $0x12,%rdi
and    $0xfffffffffffffff0,%rdi
mov    %rsp,%rdx
sub    %rdi,%rdx
mov    %rdx,-0x68(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rax
mov    %eax,%edx
call   1060 <nis_leaf_of_r@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,%rsi
call   1040 <stpcpy@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1040 <stpcpy@plt>
mov    -0x68(%rbp),%rsi
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
mov    %rcx,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rax
mov    %eax,%edx
call   1030 <nis_domain_of_r@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     12a2 <nis_destroygroup+0x132>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a2 <nis_destroygroup+0x132>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x2e,(%rax)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1040 <stpcpy@plt>
mov    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <nis_remove@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1080 <NIS_RES_STATUS@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x48(%rbp),%rdi
call   1090 <nis_freeresult@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    12e6 <nis_destroygroup+0x176>
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nis_destroygroup>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     125d <nis_destroygroup+0xdd>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     125d <nis_destroygroup+0xdd>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rsp,-0x30(%rbp)
mov    %rsp,%r14
lea    0x41(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
mov    %rsp,%rsi
lea    0x12(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rsi
mov    %rsi,%rsp
mov    %rsp,%r12
sub    %rcx,%r12
mov    %r12,%rsp
lea    0x2(%rax),%r13d
mov    %rbx,%rdi
mov    %r13d,%edx
call   1070 <nis_leaf_of_r@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <stpcpy@plt>
mov    %rax,%r15
movabs $0x5f7370756f72672e,%rax
70 73 5f
mov    %rax,(%r15)
movl   $0x726964,0x8(%r15)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1040 <nis_domain_of_r@plt>
test   %rax,%rax
je     1238 <nis_destroygroup+0xb8>
cmpb   $0x0,(%rax)
je     1238 <nis_destroygroup+0xb8>
mov    %r15,%rdi
add    $0xc,%rdi
movb   $0x2e,0xb(%r15)
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <nis_remove@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <NIS_RES_STATUS@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   10a0 <nis_freeresult@plt>
mov    -0x30(%rbp),%rsp
jmp    1266 <nis_destroygroup+0xe6>
mov    0x2d7c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c".groups_dir\00"
@NIS_FAIL = global i32 0
define i32 @nis_destroygroup(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %3
%13 = load i8*, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %67
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %67
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i64 @strlen(i8* %22)
store i64 %23, i64* %4
%24 = load i64, i64* %4
%25 = add i64 %24, 50
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %5
%27 = alloca i8, i64 %25
store i64 %25, i64* %6
%28 = load i64, i64* %4
%29 = add i64 %28, 3
%30 = alloca i8, i64 %29
store i64 %29, i64* %7
%31 = load i64, i64* %4
%32 = add i64 %31, 3
%33 = alloca i8, i64 %32
store i64 %32, i64* %8
%34 = load i8*, i8** %3
%35 = sub i64 %29, 1
%36 = trunc i64 %35 to i32
%37 = call i8* @nis_leaf_of_r(i8* %34, i8* %30, i32 %36)
%38 = call i8* @stpcpy(i8* %27, i8* %37)
store i8* %38, i8** %11
%39 = load i8*, i8** %11
%40 = call i8* @stpcpy(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %40, i8** %11
%41 = load i8*, i8** %3
%42 = sub i64 %32, 1
%43 = trunc i64 %42 to i32
%44 = call i8* @nis_domain_of_r(i8* %41, i8* %33, i32 %43)
store i8* %44, i8** %12
%45 = load i8*, i8** %12
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %59
47: ; preds = %21
%48 = load i8*, i8** %12
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %47
%54 = load i8*, i8** %11
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %11
store i8 46, i8* %54
%56 = load i8*, i8** %11
%57 = load i8*, i8** %12
%58 = call i8* @stpcpy(i8* %56, i8* %57)
br label %59
59: ; preds = %53, %47, %21
%60 = call i32* @nis_remove(i8* %27, i32* null)
store i32* %60, i32** %10
%61 = load i32*, i32** %10
%62 = call i32 @NIS_RES_STATUS(i32* %61)
store i32 %62, i32* %9
%63 = load i32*, i32** %10
%64 = call i32 @nis_freeresult(i32* %63)
%65 = load i32, i32* %9
store i32 %65, i32* %2
%66 = load i8*, i8** %5
br label %69
67: ; preds = %15, %1
%68 = load i32, i32* @NIS_FAIL
store i32 %68, i32* %2
br label %69
69: ; preds = %67, %59
%70 = load i32, i32* %2
ret i32 %70
}

LLVM IR (-O2):
@.str = [12 x i8] c".groups_dir\00"
@NIS_FAIL = global i32 0
define i32 @nis_destroygroup(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %31, label %6
6: ; preds = %3
%7 = tail call i64 @strlen(i8* %0)
%8 = add i64 %7, 50
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = add i64 %7, 3
%12 = alloca i8, i64 %11
%13 = alloca i8, i64 %11
%14 = trunc i64 %7 to i32
%15 = add i32 %14, 2
%16 = call i8* @nis_leaf_of_r(i8* %0, i8* %12, i32 %15)
%17 = call i8* @stpcpy(i8* %10, i8* %16)
%18 = getelementptr i8, i8* %17, i64 11
%19 = call i8* @nis_domain_of_r(i8* %0, i8* %13, i32 %15)
%20 = icmp eq i8* %19, null
br i1 %20, label %27, label %21
21: ; preds = %6
%22 = load i8, i8* %19
%23 = icmp eq i8 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = getelementptr i8, i8* %17, i64 12
store i8 46, i8* %18
%26 = call i8* @strcpy(i8* dereferenceable(1) %25, i8* %19)
br label %27
27: ; preds = %24, %21, %6
%28 = call i32* @nis_remove(i8* %10, i32* null)
%29 = call i32 @NIS_RES_STATUS(i32* %28)
%30 = call i32 @nis_freeresult(i32* %28)
br label %33
31: ; preds = %3, %1
%32 = load i32, i32* @NIS_FAIL
br label %33
33: ; preds = %31, %27
%34 = phi i32 [ %29, %27 ], [ %32, %31 ]
ret i32 %34
}