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

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ endgrent();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct group *getgrent();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct group *grp;
  while ((grp = getgrent()) != NULL) {
    printf("-------------------------------\n");
    printf("Group name: %s\n", grp->gr_name);
    printf("Group id: %d\n", grp->gr_gid);
    printf("Encrypted password: %s\n", grp->gr_passwd);
    for (; *(grp->gr_mem) != NULL; (grp->gr_mem)++) {
      printf("User: %s\n", *(grp->gr_mem));
    }
    printf("-------------------------------\n");
  }
  endgrent();
  exit(EXIT_SUCCESS);
}


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    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     120c <main+0xcc>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpq   $0x0,(%rax)
je     11f9 <main+0xb9>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rcx
add    $0x8,%rcx
mov    %rcx,0x18(%rax)
jmp    11b9 <main+0x79>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1156 <main+0x16>
mov    $0x0,%al
call   1030 <endgrent@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getgrent@plt>
test   %rax,%rax
jne    117c <main+0x2c>
xor    %eax,%eax
call   1030 <endgrent@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %rax,%rbx
lea    0xeba(%rip),%r13
lea    0xe73(%rip),%r14
lea    0xe7c(%rip),%r15
lea    0xe83(%rip),%r12
lea    0xe94(%rip),%rbp
jmp    11c7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1040 <getgrent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1167 <main+0x17>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    (%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rbx),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     11b0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%rax
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rbx)
mov    0x8(%rax),%rsi
test   %rsi,%rsi
jne    1210 <main+0xc0>
jmp    11b0 <main+0x60>

LLVM IR (-O0):
%struct.group = type { i8*, i32, i8*, i8** }
@.str = [33 x i8] c"-------------------------------\0A\00"
@.str.1 = [16 x i8] c"Group name: %s\0A\00"
@.str.2 = [14 x i8] c"Group id: %d\0A\00"
@.str.3 = [24 x i8] c"Encrypted password: %s\0A\00"
@.str.4 = [10 x i8] c"User: %s\0A\00"
@EXIT_SUCCESS = global i32 0
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 = %41, %2
%8 = call %struct.group* (...) @getgrent()
store %struct.group* %8, %struct.group** %6
%9 = icmp ne %struct.group* %8, null
br i1 %9, label %10, label %43
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = load %struct.group*, %struct.group** %6
%13 = getelementptr inbounds %struct.group, %struct.group* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load %struct.group*, %struct.group** %6
%17 = getelementptr inbounds %struct.group, %struct.group* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load %struct.group*, %struct.group** %6
%21 = getelementptr inbounds %struct.group, %struct.group* %20, i32 0, i32 2
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %36, %10
%25 = load %struct.group*, %struct.group** %6
%26 = getelementptr inbounds %struct.group, %struct.group* %25, i32 0, i32 3
%27 = load i8**, i8*** %26
%28 = load i8*, i8** %27
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %41
30: ; preds = %24
%31 = load %struct.group*, %struct.group** %6
%32 = getelementptr inbounds %struct.group, %struct.group* %31, i32 0, i32 3
%33 = load i8**, i8*** %32
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %30
%37 = load %struct.group*, %struct.group** %6
%38 = getelementptr inbounds %struct.group, %struct.group* %37, i32 0, i32 3
%39 = load i8**, i8*** %38
%40 = getelementptr inbounds i8*, i8** %39, i32 1
store i8** %40, i8*** %38
br label %24
41: ; preds = %24
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %7
43: ; preds = %7
%44 = call i32 (...) @endgrent()
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
%struct.group = type { i8*, i32, i8*, i8** }
@.str.1 = [16 x i8] c"Group name: %s\0A\00"
@.str.2 = [14 x i8] c"Group id: %d\0A\00"
@.str.3 = [24 x i8] c"Encrypted password: %s\0A\00"
@.str.4 = [10 x i8] c"User: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str.5 = [32 x i8] c"-------------------------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.group* (...) @getgrent()
%4 = icmp eq %struct.group* %3, null
br i1 %4, label %32, label %5
5: ; preds = %2, %28
%6 = phi %struct.group* [ %30, %28 ], [ %3, %2 ]
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%8 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 2
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 3
%18 = load i8**, i8*** %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %28, label %21
21: ; preds = %5, %21
%22 = phi i8* [ %26, %21 ], [ %19, %5 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = load i8**, i8*** %17
%25 = getelementptr inbounds i8*, i8** %24, i64 1
store i8** %25, i8*** %17
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %21
28: ; preds = %21, %5
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%30 = tail call %struct.group* (...) @getgrent()
%31 = icmp eq %struct.group* %30, null
br i1 %31, label %32, label %5
32: ; preds = %28, %2
%33 = tail call i32 (...) @endgrent()
%34 = load i32, i32* @EXIT_SUCCESS
%35 = tail call i32 @exit(i32 %34)
unreachable
}