#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 {
  char *gr_name;
  char *gr_passwd;
  int gr_gid;
  int /*<<< orphan*/ **gr_mem;
};

/* Variables and functions */
int /*<<< orphan*/ endgrent();
struct group *getgrent();
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ setgrent();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  struct group *p;
  while (--argc > 0) {
    setgrent();
    argv++;
    while ((p = getgrent()) != NULL) {
      if (strcmp(*argv, p->gr_name) == 0) {
        printf("%s, %s, %d\n", p->gr_name, p->gr_passwd, p->gr_gid);
        while (*p->gr_mem != NULL) {
          printf("\t\t%s\n", *p->gr_mem++);
        }
        break;
      }
    }
    endgrent();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1232 <main+0xe2>
mov    $0x0,%al
call   1060 <setgrent@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1226 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <main+0xd1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpq   $0x0,(%rax)
je     121c <main+0xcc>
mov    -0x18(%rbp),%rcx
mov    0x18(%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,0x18(%rcx)
mov    (%rax),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e1 <main+0x91>
jmp    1226 <main+0xd6>
jmp    118b <main+0x3b>
mov    $0x0,%al
call   1030 <endgrent@plt>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1201 <main+0xb1>
mov    %rsi,%rbx
mov    %edi,%r15d
lea    0xe8f(%rip),%r14
lea    0xe94(%rip),%r12
jmp    118d <main+0x3d>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <endgrent@plt>
cmp    $0x2,%r13d
jle    1201 <main+0xb1>
mov    %r15d,%r13d
lea    -0x1(%r13),%r15d
xor    %eax,%eax
call   1060 <setgrent@plt>
add    $0x8,%rbx
nop
xor    %eax,%eax
call   1040 <getgrent@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    %rax,%rbp
mov    (%rbx),%rdi
mov    (%rax),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    0x0(%rbp),%rsi
mov    0x8(%rbp),%rdx
mov    0x10(%rbp),%ecx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1180 <main+0x30>
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rbp)
mov    (%rax),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i32, i32** }
@.str = [12 x i8] c"%s, %s, %d\0A\00"
@.str.1 = [6 x i8] c"\09\09%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.group*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %53, %2
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %55
11: ; preds = %7
%12 = call i32 (...) @setgrent()
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
br label %15
15: ; preds = %52, %11
%16 = call %struct.group* (...) @getgrent()
store %struct.group* %16, %struct.group** %6
%17 = icmp ne %struct.group* %16, null
br i1 %17, label %18, label %53
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = load %struct.group*, %struct.group** %6
%22 = getelementptr inbounds %struct.group, %struct.group* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %20, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %52
26: ; preds = %18
%27 = load %struct.group*, %struct.group** %6
%28 = getelementptr inbounds %struct.group, %struct.group* %27, i32 0, i32 0
%29 = load i8*, i8** %28
%30 = load %struct.group*, %struct.group** %6
%31 = getelementptr inbounds %struct.group, %struct.group* %30, i32 0, i32 1
%32 = load i8*, i8** %31
%33 = load %struct.group*, %struct.group** %6
%34 = getelementptr inbounds %struct.group, %struct.group* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %32, i32 %35)
br label %37
37: ; preds = %43, %26
%38 = load %struct.group*, %struct.group** %6
%39 = getelementptr inbounds %struct.group, %struct.group* %38, i32 0, i32 3
%40 = load i32**, i32*** %39
%41 = load i32*, i32** %40
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %51
43: ; preds = %37
%44 = load %struct.group*, %struct.group** %6
%45 = getelementptr inbounds %struct.group, %struct.group* %44, i32 0, i32 3
%46 = load i32**, i32*** %45
%47 = getelementptr inbounds i32*, i32** %46, i32 1
store i32** %47, i32*** %45
%48 = load i32*, i32** %46
%49 = bitcast i32* %48 to i8*
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %49)
br label %37
51: ; preds = %37
br label %53
52: ; preds = %18
br label %15
53: ; preds = %51, %15
%54 = call i32 (...) @endgrent()
br label %7
55: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32, i32** }
@.str = [12 x i8] c"%s, %s, %d\0A\00"
@.str.1 = [6 x i8] c"\09\09%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %43
4: ; preds = %2, %40
%5 = phi i32 [ %7, %40 ], [ %0, %2 ]
%6 = phi i8** [ %9, %40 ], [ %1, %2 ]
%7 = add nsw i32 %5, -1
%8 = tail call i32 (...) @setgrent()
%9 = getelementptr inbounds i8*, i8** %6, i64 1
br label %10
10: ; preds = %13, %4
%11 = tail call %struct.group* (...) @getgrent()
%12 = icmp eq %struct.group* %11, null
br i1 %12, label %40, label %13
13: ; preds = %10
%14 = load i8*, i8** %9
%15 = getelementptr inbounds %struct.group, %struct.group* %11, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %14, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %13
%20 = getelementptr inbounds %struct.group, %struct.group* %11, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.group, %struct.group* %11, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.group, %struct.group* %11, i64 0, i32 2
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %23, i32 %25)
%27 = getelementptr inbounds %struct.group, %struct.group* %11, i64 0, i32 3
%28 = load i32**, i32*** %27
%29 = load i32*, i32** %28
%30 = icmp eq i32* %29, null
br i1 %30, label %40, label %31
31: ; preds = %19, %31
%32 = phi i32** [ %37, %31 ], [ %28, %19 ]
%33 = getelementptr inbounds i32*, i32** %32, i64 1
store i32** %33, i32*** %27
%34 = bitcast i32** %32 to i8**
%35 = load i8*, i8** %34
%36 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i32**, i32*** %27
%38 = load i32*, i32** %37
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %31
40: ; preds = %10, %31, %19
%41 = tail call i32 (...) @endgrent()
%42 = icmp sgt i32 %5, 2
br i1 %42, label %4, label %43
43: ; preds = %40, %2
ret i32 0
}