#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 */
struct group {
  int /*<<< orphan*/ **gr_mem;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct group *getgrnam(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int match_group(char *dict_group, char *username) {
  struct group *g;
  dict_group++;
  if ((g = getgrnam(dict_group)) == NULL) {
    fprintf(stderr, "helper: Group does not exist '%s'\n", dict_group);
    return 0;
  } else {
    while (*(g->gr_mem) != NULL) {
      if (strcmp(*((g->gr_mem)++), username) == 0) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getgrnam@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1188 <match_group+0x58>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <match_group+0xb4>
jmp    118d <match_group+0x5d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmpq   $0x0,(%rax)
je     11d8 <match_group+0xa8>
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%rax
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d3 <match_group+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <match_group+0xb4>
jmp    118d <match_group+0x5d>
jmp    11dd <match_group+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_group>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
add    $0x1,%r15
mov    %r15,%rdi
call   1050 <getgrnam@plt>
test   %rax,%rax
je     1176 <match_group+0x46>
mov    %rax,%rbx
nop
mov    (%rbx),%rax
cmpq   $0x0,(%rax)
je     118e <match_group+0x5e>
lea    0x8(%rax),%rcx
mov    %rcx,(%rbx)
mov    (%rax),%edi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1150 <match_group+0x20>
mov    $0x1,%eax
jmp    1190 <match_group+0x60>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.group = type { i32** }
@stderr = global i32 0
@.str = [35 x i8] c"helper: Group does not exist '%s'\0A\00"
define i32 @match_group(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.group*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call %struct.group* @getgrnam(i8* %9)
store %struct.group* %10, %struct.group** %6
%11 = icmp eq %struct.group* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %3
br label %37
16: ; preds = %2
br label %17
17: ; preds = %34, %16
%18 = load %struct.group*, %struct.group** %6
%19 = getelementptr inbounds %struct.group, %struct.group* %18, i32 0, i32 0
%20 = load i32**, i32*** %19
%21 = load i32*, i32** %20
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %35
23: ; preds = %17
%24 = load %struct.group*, %struct.group** %6
%25 = getelementptr inbounds %struct.group, %struct.group* %24, i32 0, i32 0
%26 = load i32**, i32*** %25
%27 = getelementptr inbounds i32*, i32** %26, i32 1
store i32** %27, i32*** %25
%28 = load i32*, i32** %26
%29 = ptrtoint i32* %28 to i32
%30 = load i8*, i8** %5
%31 = call i64 @strcmp(i32 %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %23
store i32 1, i32* %3
br label %37
34: ; preds = %23
br label %17
35: ; preds = %17
br label %36
36: ; preds = %35
store i32 0, i32* %3
br label %37
37: ; preds = %36, %33, %12
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.group = type { i32** }
@stderr = global i32 0
@.str = [35 x i8] c"helper: Group does not exist '%s'\0A\00"
define i32 @match_group(i8* %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = tail call %struct.group* @getgrnam(i8* %3)
%5 = icmp eq %struct.group* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.group, %struct.group* %4, i64 0, i32 0
br label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %22
11: ; preds = %6, %15
%12 = load i32**, i32*** %7
%13 = load i32*, i32** %12
%14 = icmp eq i32* %13, null
br i1 %14, label %22, label %15
15: ; preds = %11
%16 = getelementptr inbounds i32*, i32** %12, i64 1
store i32** %16, i32*** %7
%17 = load i32*, i32** %12
%18 = ptrtoint i32* %17 to i64
%19 = trunc i64 %18 to i32
%20 = tail call i64 @strcmp(i32 %19, i8* %1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %11, %15, %8
%23 = phi i32 [ 0, %8 ], [ 0, %11 ], [ 1, %15 ]
ret i32 %23
}