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

/* Variables and functions */
int /*<<< orphan*/ endgrent();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct group *getgrent();
struct group *getgrgid(int /*<<< orphan*/);
struct group *getgrnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setgrent();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  struct group *group;
  char **tmp_mem;
  int test_gid;
  fprintf(stderr, "Beginning test of libc/grp...\n");
  fprintf(stderr, "=> Testing setgrent(), getgrent(), endgrent()...\n");
  fprintf(stderr, "-> setgrent()...\n");
  setgrent();
  fprintf(stderr, "-> getgrent()...\n");
  printf("*********************************************************************"
         "***********\n");
  while ((group = getgrent()) != NULL) {
    printf("gr_name\t\t: %s\n", group->gr_name);
    printf("gr_passwd\t: %s\n", group->gr_passwd);
    printf("gr_gid\t\t: %d\n", (int)group->gr_gid);
    printf("gr_mem\t\t: ");
    fflush(stdout);
    tmp_mem = group->gr_mem;
    while (*tmp_mem != NULL) {
      printf("%s, ", *tmp_mem);
      tmp_mem++;
    }
    printf("\n*****************************************************************"
           "***************\n");
  }
  fprintf(stderr, "-> endgrent()...\n");
  endgrent();
  fprintf(stderr, "=> Test of setgrent(), getgrent(), endgrent() complete.\n");
  fprintf(stderr, "=> Testing getgrid(), getgrnam()...\n");
  fprintf(stderr, "-> getgrgid()...\n");
  printf("*********************************************************************"
         "***********\n");
  for (test_gid = 0; test_gid < 100; test_gid++) {
    fprintf(stderr, "-> getgrgid(%d)...\n", test_gid);
    group = getgrgid((gid_t)test_gid);
    if (group != NULL) {
      printf("gr_name\t: %s\n", group->gr_name);
      printf("gr_passwd\t: %s\n", group->gr_passwd);
      printf("gr_gid\t: %d\n", (int)group->gr_gid);
      printf("gr_mem\t\t: ");
      fflush(stdout);
      tmp_mem = group->gr_mem;
      while (*tmp_mem != NULL) {
        printf("%s, ", *tmp_mem);
        tmp_mem++;
      }
    }
    printf("\n*****************************************************************"
           "***************\n");
  }
  fprintf(stderr, "-> getgrnam()...\n");
  group = getgrnam("root");
  if (group == NULL) {
    printf(">NULL<\n");
  } else {
    printf("gr_name\t: %s\n", group->gr_name);
    printf("gr_passwd\t: %s\n", group->gr_passwd);
    printf("gr_gid\t: %d\n", (int)group->gr_gid);
    printf("gr_mem\t\t: ");
    fflush(stdout);
    tmp_mem = group->gr_mem;
    while (*tmp_mem != NULL) {
      printf("%s, ", *tmp_mem);
      tmp_mem++;
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1060 <setgrent@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12ce <main+0x14e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     12bb <main+0x13b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1287 <main+0x107>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1207 <main+0x87>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1030 <endgrent@plt>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    1441 <main+0x2c1>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x24(%rbp),%edi
call   1070 <getgrgid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1425 <main+0x2a5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%esi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1420 <main+0x2a0>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xca5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    13ec <main+0x26c>
jmp    1425 <main+0x2a5>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1346 <main+0x1c6>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    0xd69(%rip),%rdi
call   1090 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1486 <main+0x306>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1533 <main+0x3b3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xbda(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%esi
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbd2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2afa(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1525 <main+0x3a5>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xba0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    14f1 <main+0x371>
lea    0xbd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e2e(%rip),%rbx
mov    (%rbx),%edi
lea    0xe45(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1080 <setgrent@plt>
mov    (%rbx),%edi
lea    0xe71(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xf82(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1050 <getgrent@plt>
test   %rax,%rax
je     12cb <main+0x12b>
mov    %rax,%r14
lea    0xe83(%rip),%r13
mov    0x2db2(%rip),%r15
lea    0xf54(%rip),%r12
lea    0xe79(%rip),%rbp
jmp    1257 <main+0xb7>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1050 <getgrent@plt>
mov    %rax,%r14
test   %rax,%rax
je     12cb <main+0x12b>
mov    (%r14),%rsi
lea    0xe14(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%r14),%rsi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%r14),%esi
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%edi
call   10c0 <fflush@plt>
mov    0x10(%r14),%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1240 <main+0xa0>
add    $0x8,%rbx
xchg   %ax,%ax
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    12b0 <main+0x110>
jmp    1240 <main+0xa0>
mov    0x2d0e(%rip),%rbx
mov    (%rbx),%edi
lea    0xdd7(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   1030 <endgrent@plt>
mov    (%rbx),%edi
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe10(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xe62(%rip),%rdi
call   1060 <puts@plt>
lea    0xe08(%rip),%r14
lea    0xe4e(%rip),%rbx
lea    0xd73(%rip),%r15
xor    %r12d,%r12d
jmp    1356 <main+0x1b6>
nop
mov    %rbx,%rdi
call   1060 <puts@plt>
add    $0x1,%r12d
cmp    $0x64,%r12d
je     140c <main+0x26c>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12d,%edi
call   1090 <getgrgid@plt>
test   %rax,%rax
je     1340 <main+0x1a0>
mov    %rax,%r13
mov    (%rax),%rsi
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%r13),%rsi
lea    0xcec(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%r13),%esi
lea    0xdac(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    0x10(%r13),%rbp
mov    0x0(%rbp),%rsi
test   %rsi,%rsi
je     1340 <main+0x1a0>
add    $0x8,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    13f0 <main+0x250>
jmp    1340 <main+0x1a0>
mov    0x2bcd(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd4b(%rip),%rdi
call   10b0 <getgrnam@plt>
test   %rax,%rax
je     14d3 <main+0x333>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xd03(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xc2d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xcee(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc2c(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2b54(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    0x10(%rbx),%rbp
mov    0x0(%rbp),%rsi
test   %rsi,%rsi
je     14c7 <main+0x327>
add    $0x8,%rbp
lea    0xc0a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    14b0 <main+0x310>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    14df <main+0x33f>
lea    0xca0(%rip),%rdi
call   1060 <puts@plt>
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*, i8**, i64 }
@stderr = global i32 0
@.str = [31 x i8] c"Beginning test of libc/grp...\0A\00"
@.str.1 = [50 x i8] c"=> Testing setgrent(), getgrent(), endgrent()...\0A\00"
@.str.2 = [18 x i8] c"-> setgrent()...\0A\00"
@.str.3 = [18 x i8] c"-> getgrent()...\0A\00"
@.str.4 = [82 x i8] c"********************************************************************************\0A\00"
@.str.5 = [15 x i8] c"gr_name\09\09: %s\0A\00"
@.str.6 = [16 x i8] c"gr_passwd\09: %s\0A\00"
@.str.7 = [14 x i8] c"gr_gid\09\09: %d\0A\00"
@.str.8 = [11 x i8] c"gr_mem\09\09: \00"
@stdout = global i32 0
@.str.9 = [5 x i8] c"%s, \00"
@.str.10 = [83 x i8] c"\0A********************************************************************************\0A\00"
@.str.11 = [18 x i8] c"-> endgrent()...\0A\00"
@.str.12 = [57 x i8] c"=> Test of setgrent(), getgrent(), endgrent() complete.\0A\00"
@.str.13 = [37 x i8] c"=> Testing getgrid(), getgrnam()...\0A\00"
@.str.14 = [18 x i8] c"-> getgrgid()...\0A\00"
@.str.15 = [20 x i8] c"-> getgrgid(%d)...\0A\00"
@.str.16 = [14 x i8] c"gr_name\09: %s\0A\00"
@.str.17 = [13 x i8] c"gr_gid\09: %d\0A\00"
@.str.18 = [18 x i8] c"-> getgrnam()...\0A\00"
@.str.19 = [5 x i8] c"root\00"
@.str.20 = [8 x i8] c">NULL<\0A\00"
@.str.21 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.group*
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (...) @setgrent()
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %52, %2
%20 = call %struct.group* (...) @getgrent()
store %struct.group* %20, %struct.group** %6
%21 = icmp ne %struct.group* %20, null
br i1 %21, label %22, label %54
22: ; preds = %19
%23 = load %struct.group*, %struct.group** %6
%24 = getelementptr inbounds %struct.group, %struct.group* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = load %struct.group*, %struct.group** %6
%28 = getelementptr inbounds %struct.group, %struct.group* %27, i32 0, i32 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%31 = load %struct.group*, %struct.group** %6
%32 = getelementptr inbounds %struct.group, %struct.group* %31, i32 0, i32 3
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%37 = load i32, i32* @stdout
%38 = call i32 @fflush(i32 %37)
%39 = load %struct.group*, %struct.group** %6
%40 = getelementptr inbounds %struct.group, %struct.group* %39, i32 0, i32 2
%41 = load i8**, i8*** %40
store i8** %41, i8*** %7
br label %42
42: ; preds = %46, %22
%43 = load i8**, i8*** %7
%44 = load i8*, i8** %43
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %52
46: ; preds = %42
%47 = load i8**, i8*** %7
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %48)
%50 = load i8**, i8*** %7
%51 = getelementptr inbounds i8*, i8** %50, i32 1
store i8** %51, i8*** %7
br label %42
52: ; preds = %42
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.10, i64 0, i64 0))
br label %19
54: ; preds = %19
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%57 = call i32 (...) @endgrent()
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0))
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %65
65: ; preds = %109, %54
%66 = load i32, i32* %8
%67 = icmp slt i32 %66, 100
br i1 %67, label %68, label %112
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i32, i32* %8
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %70)
%72 = load i32, i32* %8
%73 = call %struct.group* @getgrgid(i32 %72)
store %struct.group* %73, %struct.group** %6
%74 = load %struct.group*, %struct.group** %6
%75 = icmp ne %struct.group* %74, null
br i1 %75, label %76, label %107
76: ; preds = %68
%77 = load %struct.group*, %struct.group** %6
%78 = getelementptr inbounds %struct.group, %struct.group* %77, i32 0, i32 0
%79 = load i8*, i8** %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* %79)
%81 = load %struct.group*, %struct.group** %6
%82 = getelementptr inbounds %struct.group, %struct.group* %81, i32 0, i32 1
%83 = load i8*, i8** %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %83)
%85 = load %struct.group*, %struct.group** %6
%86 = getelementptr inbounds %struct.group, %struct.group* %85, i32 0, i32 3
%87 = load i64, i64* %86
%88 = trunc i64 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%91 = load i32, i32* @stdout
%92 = call i32 @fflush(i32 %91)
%93 = load %struct.group*, %struct.group** %6
%94 = getelementptr inbounds %struct.group, %struct.group* %93, i32 0, i32 2
%95 = load i8**, i8*** %94
store i8** %95, i8*** %7
br label %96
96: ; preds = %100, %76
%97 = load i8**, i8*** %7
%98 = load i8*, i8** %97
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %106
100: ; preds = %96
%101 = load i8**, i8*** %7
%102 = load i8*, i8** %101
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %102)
%104 = load i8**, i8*** %7
%105 = getelementptr inbounds i8*, i8** %104, i32 1
store i8** %105, i8*** %7
br label %96
106: ; preds = %96
br label %107
107: ; preds = %106, %68
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.10, i64 0, i64 0))
br label %109
109: ; preds = %107
%110 = load i32, i32* %8
%111 = add nsw i32 %110, 1
store i32 %111, i32* %8
br label %65
112: ; preds = %65
%113 = load i32, i32* @stderr
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
%115 = call %struct.group* @getgrnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
store %struct.group* %115, %struct.group** %6
%116 = load %struct.group*, %struct.group** %6
%117 = icmp eq %struct.group* %116, null
br i1 %117, label %118, label %120
118: ; preds = %112
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0))
br label %152
120: ; preds = %112
%121 = load %struct.group*, %struct.group** %6
%122 = getelementptr inbounds %struct.group, %struct.group* %121, i32 0, i32 0
%123 = load i8*, i8** %122
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* %123)
%125 = load %struct.group*, %struct.group** %6
%126 = getelementptr inbounds %struct.group, %struct.group* %125, i32 0, i32 1
%127 = load i8*, i8** %126
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %127)
%129 = load %struct.group*, %struct.group** %6
%130 = getelementptr inbounds %struct.group, %struct.group* %129, i32 0, i32 3
%131 = load i64, i64* %130
%132 = trunc i64 %131 to i32
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %132)
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%135 = load i32, i32* @stdout
%136 = call i32 @fflush(i32 %135)
%137 = load %struct.group*, %struct.group** %6
%138 = getelementptr inbounds %struct.group, %struct.group* %137, i32 0, i32 2
%139 = load i8**, i8*** %138
store i8** %139, i8*** %7
br label %140
140: ; preds = %144, %120
%141 = load i8**, i8*** %7
%142 = load i8*, i8** %141
%143 = icmp ne i8* %142, null
br i1 %143, label %144, label %150
144: ; preds = %140
%145 = load i8**, i8*** %7
%146 = load i8*, i8** %145
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %146)
%148 = load i8**, i8*** %7
%149 = getelementptr inbounds i8*, i8** %148, i32 1
store i8** %149, i8*** %7
br label %140
150: ; preds = %140
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0))
br label %152
152: ; preds = %150, %118
ret i32 0
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i8**, i64 }
@stderr = global i32 0
@.str = [31 x i8] c"Beginning test of libc/grp...\0A\00"
@.str.1 = [50 x i8] c"=> Testing setgrent(), getgrent(), endgrent()...\0A\00"
@.str.2 = [18 x i8] c"-> setgrent()...\0A\00"
@.str.3 = [18 x i8] c"-> getgrent()...\0A\00"
@.str.5 = [15 x i8] c"gr_name\09\09: %s\0A\00"
@.str.6 = [16 x i8] c"gr_passwd\09: %s\0A\00"
@.str.7 = [14 x i8] c"gr_gid\09\09: %d\0A\00"
@.str.8 = [11 x i8] c"gr_mem\09\09: \00"
@stdout = global i32 0
@.str.9 = [5 x i8] c"%s, \00"
@.str.11 = [18 x i8] c"-> endgrent()...\0A\00"
@.str.12 = [57 x i8] c"=> Test of setgrent(), getgrent(), endgrent() complete.\0A\00"
@.str.13 = [37 x i8] c"=> Testing getgrid(), getgrnam()...\0A\00"
@.str.14 = [18 x i8] c"-> getgrgid()...\0A\00"
@.str.15 = [20 x i8] c"-> getgrgid(%d)...\0A\00"
@.str.16 = [14 x i8] c"gr_name\09: %s\0A\00"
@.str.17 = [13 x i8] c"gr_gid\09: %d\0A\00"
@.str.18 = [18 x i8] c"-> getgrnam()...\0A\00"
@.str.19 = [5 x i8] c"root\00"
@str.22 = [81 x i8] c"********************************************************************************\00"
@str.23 = [7 x i8] c">NULL<\00"
@str.25 = [82 x i8] c"\0A********************************************************************************\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @setgrent()
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.22, i64 0, i64 0))
%13 = tail call %struct.group* (...) @getgrent()
%14 = icmp eq %struct.group* %13, null
br i1 %14, label %45, label %15
15: ; preds = %2, %41
%16 = phi %struct.group* [ %43, %41 ], [ %13, %2 ]
%17 = getelementptr inbounds %struct.group, %struct.group* %16, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds %struct.group, %struct.group* %16, i64 0, i32 1
%21 = load i8*, i8** %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds %struct.group, %struct.group* %16, i64 0, i32 3
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = tail call i32 @fflush(i32 %28)
%30 = getelementptr inbounds %struct.group, %struct.group* %16, i64 0, i32 2
%31 = load i8**, i8*** %30
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
br i1 %33, label %41, label %34
34: ; preds = %15, %34
%35 = phi i8* [ %39, %34 ], [ %32, %15 ]
%36 = phi i8** [ %38, %34 ], [ %31, %15 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %35)
%38 = getelementptr inbounds i8*, i8** %36, i64 1
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %34
41: ; preds = %34, %15
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.25, i64 0, i64 0))
%43 = tail call %struct.group* (...) @getgrent()
%44 = icmp eq %struct.group* %43, null
br i1 %44, label %45, label %15
45: ; preds = %41, %2
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%48 = tail call i32 (...) @endgrent()
%49 = load i32, i32* @stderr
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.22, i64 0, i64 0))
br label %56
56: ; preds = %45, %87
%57 = phi i32 [ 0, %45 ], [ %89, %87 ]
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %57)
%60 = tail call %struct.group* @getgrgid(i32 %57)
%61 = icmp eq %struct.group* %60, null
br i1 %61, label %87, label %62
62: ; preds = %56
%63 = getelementptr inbounds %struct.group, %struct.group* %60, i64 0, i32 0
%64 = load i8*, i8** %63
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds %struct.group, %struct.group* %60, i64 0, i32 1
%67 = load i8*, i8** %66
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds %struct.group, %struct.group* %60, i64 0, i32 3
%70 = load i64, i64* %69
%71 = trunc i64 %70 to i32
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %71)
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* @stdout
%75 = tail call i32 @fflush(i32 %74)
%76 = getelementptr inbounds %struct.group, %struct.group* %60, i64 0, i32 2
%77 = load i8**, i8*** %76
%78 = load i8*, i8** %77
%79 = icmp eq i8* %78, null
br i1 %79, label %87, label %80
80: ; preds = %62, %80
%81 = phi i8* [ %85, %80 ], [ %78, %62 ]
%82 = phi i8** [ %84, %80 ], [ %77, %62 ]
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %81)
%84 = getelementptr inbounds i8*, i8** %82, i64 1
%85 = load i8*, i8** %84
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %80
87: ; preds = %80, %62, %56
%88 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.25, i64 0, i64 0))
%89 = add nuw nsw i32 %57, 1
%90 = icmp eq i32 %89, 100
br i1 %90, label %91, label %56
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = tail call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.18, i64 0, i64 0))
%94 = tail call %struct.group* @getgrnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
%95 = icmp eq %struct.group* %94, null
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0))
br label %125
98: ; preds = %91
%99 = getelementptr inbounds %struct.group, %struct.group* %94, i64 0, i32 0
%100 = load i8*, i8** %99
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i8* %100)
%102 = getelementptr inbounds %struct.group, %struct.group* %94, i64 0, i32 1
%103 = load i8*, i8** %102
%104 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %103)
%105 = getelementptr inbounds %struct.group, %struct.group* %94, i64 0, i32 3
%106 = load i64, i64* %105
%107 = trunc i64 %106 to i32
%108 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %107)
%109 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%110 = load i32, i32* @stdout
%111 = tail call i32 @fflush(i32 %110)
%112 = getelementptr inbounds %struct.group, %struct.group* %94, i64 0, i32 2
%113 = load i8**, i8*** %112
%114 = load i8*, i8** %113
%115 = icmp eq i8* %114, null
br i1 %115, label %123, label %116
116: ; preds = %98, %116
%117 = phi i8* [ %121, %116 ], [ %114, %98 ]
%118 = phi i8** [ %120, %116 ], [ %113, %98 ]
%119 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %117)
%120 = getelementptr inbounds i8*, i8** %118, i64 1
%121 = load i8*, i8** %120
%122 = icmp eq i8* %121, null
br i1 %122, label %123, label %116
123: ; preds = %116, %98
%124 = tail call i32 @putchar(i32 10)
br label %125
125: ; preds = %123, %96
ret i32 0
}