#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 {
  scalar_t__ gr_gid;
  char **gr_mem;
};
typedef scalar_t__ gid_t;

/* Variables and functions */
int /*<<< orphan*/ add_group(long *, long *, scalar_t__ **, long, scalar_t__);
scalar_t__ strcmp(char *, char const *);
int check_and_add_group(const char *user, gid_t group, long int *start,
                        long int *size, gid_t **groupsp, long int limit,
                        struct group *grp) {
  char **member;
  if (grp->gr_gid == group)
    return 0;
  for (member = grp->gr_mem; *member != NULL; ++member)
    if (strcmp(*member, user) == 0) {
      add_group(start, size, groupsp, limit, grp->gr_gid);
      return 0;
    }
  return 1;
}


x86 assembly (clang, -O0):
<check_and_add_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jne    1161 <check_and_add_group+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11da <check_and_add_group+0xba>
mov    0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmpq   $0x0,(%rax)
je     11d3 <check_and_add_group+0xb3>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <check_and_add_group+0x9d>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    (%rax),%r8
call   1040 <add_group@plt>
movl   $0x0,-0x4(%rbp)
jmp    11da <check_and_add_group+0xba>
jmp    11c2 <check_and_add_group+0xa2>
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
jmp    116d <check_and_add_group+0x4d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_and_add_group>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x50(%rsp),%r14
xor    %ebx,%ebx
cmp    %rsi,(%r14)
je     1198 <check_and_add_group+0x78>
mov    %rdi,%rbp
mov    0x8(%r14),%r15
mov    (%r15),%rdi
test   %rdi,%rdi
je     1179 <check_and_add_group+0x59>
mov    %rcx,%r12
mov    %rdx,%r13
mov    %r8,0x8(%rsp)
mov    %r9,0x10(%rsp)
add    $0x8,%r15
nopl   (%rax)
mov    %rbp,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1180 <check_and_add_group+0x60>
mov    (%r15),%rdi
add    $0x8,%r15
test   %rdi,%rdi
jne    1160 <check_and_add_group+0x40>
mov    $0x1,%ebx
jmp    1198 <check_and_add_group+0x78>
mov    (%r14),%r8
mov    %r13,%rdi
mov    %r12,%rsi
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
call   1040 <add_group@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.group = type { i64, i8** }
define i32 @check_and_add_group(i8* %0, i64 %1, i64* %2, i64* %3, i64** %4, i64 %5, %struct.group* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i64*
%13 = alloca i64**
%14 = alloca i64
%15 = alloca %struct.group*
%16 = alloca i8**
store i8* %0, i8** %9
store i64 %1, i64* %10
store i64* %2, i64** %11
store i64* %3, i64** %12
store i64** %4, i64*** %13
store i64 %5, i64* %14
store %struct.group* %6, %struct.group** %15
%17 = load %struct.group*, %struct.group** %15
%18 = getelementptr inbounds %struct.group, %struct.group* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* %10
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %7
store i32 0, i32* %8
br label %51
23: ; preds = %7
%24 = load %struct.group*, %struct.group** %15
%25 = getelementptr inbounds %struct.group, %struct.group* %24, i32 0, i32 1
%26 = load i8**, i8*** %25
store i8** %26, i8*** %16
br label %27
27: ; preds = %47, %23
%28 = load i8**, i8*** %16
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %50
31: ; preds = %27
%32 = load i8**, i8*** %16
%33 = load i8*, i8** %32
%34 = load i8*, i8** %9
%35 = call i64 @strcmp(i8* %33, i8* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %31
%38 = load i64*, i64** %11
%39 = load i64*, i64** %12
%40 = load i64**, i64*** %13
%41 = load i64, i64* %14
%42 = load %struct.group*, %struct.group** %15
%43 = getelementptr inbounds %struct.group, %struct.group* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = call i32 @add_group(i64* %38, i64* %39, i64** %40, i64 %41, i64 %44)
store i32 0, i32* %8
br label %51
46: ; preds = %31
br label %47
47: ; preds = %46
%48 = load i8**, i8*** %16
%49 = getelementptr inbounds i8*, i8** %48, i32 1
store i8** %49, i8*** %16
br label %27
50: ; preds = %27
store i32 1, i32* %8
br label %51
51: ; preds = %50, %37, %22
%52 = load i32, i32* %8
ret i32 %52
}

LLVM IR (-O2):
%struct.group = type { i64, i8** }
define i32 @check_and_add_group(i8* %0, i64 %1, i64* %2, i64* %3, i64** %4, i64 %5, %struct.group* nocapture %6) {
%8 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 0
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, %1
br i1 %10, label %28, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 1
%13 = load i8**, i8*** %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %28, label %19
16: ; preds = %19
%17 = load i8*, i8** %24
%18 = icmp eq i8* %17, null
br i1 %18, label %28, label %19
19: ; preds = %11, %16
%20 = phi i8* [ %17, %16 ], [ %14, %11 ]
%21 = phi i8** [ %24, %16 ], [ %13, %11 ]
%22 = tail call i64 @strcmp(i8* %20, i8* %0)
%23 = icmp eq i64 %22, 0
%24 = getelementptr inbounds i8*, i8** %21, i64 1
br i1 %23, label %25, label %16
25: ; preds = %19
%26 = load i64, i64* %8
%27 = tail call i32 @add_group(i64* %2, i64* %3, i64** %4, i64 %5, i64 %26)
br label %28
28: ; preds = %16, %11, %7, %25
%29 = phi i32 [ 0, %25 ], [ 0, %7 ], [ 1, %11 ], [ 1, %16 ]
ret i32 %29
}