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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ endgrent();
struct group *getgrent();
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ setgrent();
int main(int argc, char **argv) {
  struct group *p;
  int gid;
  while (--argc > 0) {
    gid = atoi(*++argv);
    setgrent();
    while ((p = getgrent()) != NULL) {
      if (gid == p->gr_gid) {
        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    1233 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <setgrent@plt>
mov    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1227 <main+0xd7>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jne    1222 <main+0xd2>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpq   $0x0,(%rax)
je     121d <main+0xcd>
mov    -0x18(%rbp),%rcx
mov    0x18(%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,0x18(%rcx)
mov    (%rax),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e2 <main+0x92>
jmp    1227 <main+0xd7>
jmp    119a <main+0x4a>
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,%r12
mov    %edi,%r15d
lea    0xe9b(%rip),%r13
jmp    118d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <endgrent@plt>
cmp    $0x2,%r14d
jle    1201 <main+0xb1>
mov    %r15d,%r14d
lea    -0x1(%r14),%r15d
mov    0x8(%r12),%rdi
add    $0x8,%r12
call   1070 <atoi@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <setgrent@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getgrent@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    %rax,%rbx
cmp    (%rax),%ebp
jne    11b0 <main+0x60>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xe2e(%rip),%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rbx),%rax
cmpq   $0x0,(%rax)
je     1180 <main+0x30>
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rbx)
mov    (%rax),%rsi
mov    %r13,%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 { i32, i8*, i8*, 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*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %54, %2
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
store i32 %10, i32* %4
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %56
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = call i32 (...) @setgrent()
br label %18
18: ; preds = %53, %12
%19 = call %struct.group* (...) @getgrent()
store %struct.group* %19, %struct.group** %6
%20 = icmp ne %struct.group* %19, null
br i1 %20, label %21, label %54
21: ; preds = %18
%22 = load i32, i32* %7
%23 = load %struct.group*, %struct.group** %6
%24 = getelementptr inbounds %struct.group, %struct.group* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %22, %25
br i1 %26, label %27, label %53
27: ; preds = %21
%28 = load %struct.group*, %struct.group** %6
%29 = getelementptr inbounds %struct.group, %struct.group* %28, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = load %struct.group*, %struct.group** %6
%32 = getelementptr inbounds %struct.group, %struct.group* %31, i32 0, i32 2
%33 = load i8*, i8** %32
%34 = load %struct.group*, %struct.group** %6
%35 = getelementptr inbounds %struct.group, %struct.group* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %33, i32 %36)
br label %38
38: ; preds = %44, %27
%39 = load %struct.group*, %struct.group** %6
%40 = getelementptr inbounds %struct.group, %struct.group* %39, i32 0, i32 3
%41 = load i32**, i32*** %40
%42 = load i32*, i32** %41
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %52
44: ; preds = %38
%45 = load %struct.group*, %struct.group** %6
%46 = getelementptr inbounds %struct.group, %struct.group* %45, i32 0, i32 3
%47 = load i32**, i32*** %46
%48 = getelementptr inbounds i32*, i32** %47, i32 1
store i32** %48, i32*** %46
%49 = load i32*, i32** %47
%50 = bitcast i32* %49 to i8*
%51 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %50)
br label %38
52: ; preds = %38
br label %54
53: ; preds = %21
br label %18
54: ; preds = %52, %18
%55 = call i32 (...) @endgrent()
br label %8
56: ; preds = %8
ret i32 0
}

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