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

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
struct group *getgrent();
int /*<<< orphan*/ printf(char *, char *, char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  struct group *gr;
  char **mp;
  while ((gr = getgrent()) != NULL) {
    printf("%s:%s:%d:", gr->gr_name, gr->gr_passwd, gr->gr_gid);
    for (mp = gr->gr_mem; *mp != NULL; ++mp) {
      if (mp != gr->gr_mem)
        putchar(',');
      fputs(*mp, stdout);
    }
    putchar('\n');
  }
  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    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11f8 <main+0xb8>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e9 <main+0xa9>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    0x18(%rcx),%rax
je     11c3 <main+0x83>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1199 <main+0x59>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getgrent@plt>
test   %rax,%rax
je     11ee <main+0xae>
mov    %rax,%r12
lea    0xe9e(%rip),%r14
mov    0x2e77(%rip),%r15
jmp    1189 <main+0x49>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getgrent@plt>
mov    %rax,%r12
test   %rax,%rax
je     11ee <main+0xae>
mov    (%r12),%rsi
mov    0x8(%r12),%rdx
mov    0x10(%r12),%ecx
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x18(%r12),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1170 <main+0x30>
mov    %rax,%rbx
cmp    %rax,%rbx
je     11cd <main+0x8d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    (%rbx),%rdi
mov    (%r15),%esi
call   1060 <fputs@plt>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1170 <main+0x30>
add    $0x8,%rbx
mov    0x18(%r12),%rax
cmp    %rax,%rbx
jne    11c0 <main+0x80>
jmp    11cd <main+0x8d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i32, i8** }
@.str = [10 x i8] c"%s:%s:%d:\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.group*
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %45, %2
%9 = call %struct.group* (...) @getgrent()
store %struct.group* %9, %struct.group** %6
%10 = icmp ne %struct.group* %9, null
br i1 %10, label %11, label %47
11: ; preds = %8
%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 = load %struct.group*, %struct.group** %6
%16 = getelementptr inbounds %struct.group, %struct.group* %15, i32 0, i32 1
%17 = load i8*, i8** %16
%18 = load %struct.group*, %struct.group** %6
%19 = getelementptr inbounds %struct.group, %struct.group* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %17, i32 %20)
%22 = load %struct.group*, %struct.group** %6
%23 = getelementptr inbounds %struct.group, %struct.group* %22, i32 0, i32 3
%24 = load i8**, i8*** %23
store i8** %24, i8*** %7
br label %25
25: ; preds = %42, %11
%26 = load i8**, i8*** %7
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i8**, i8*** %7
%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 = icmp ne i8** %30, %33
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @putchar(i8 signext 44)
br label %37
37: ; preds = %35, %29
%38 = load i8**, i8*** %7
%39 = load i8*, i8** %38
%40 = load i32, i32* @stdout
%41 = call i32 @fputs(i8* %39, i32 %40)
br label %42
42: ; preds = %37
%43 = load i8**, i8*** %7
%44 = getelementptr inbounds i8*, i8** %43, i32 1
store i8** %44, i8*** %7
br label %25
45: ; preds = %25
%46 = call i32 @putchar(i8 signext 10)
br label %8
47: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32, i8** }
@.str = [10 x i8] c"%s:%s:%d:\00"
@stdout = global i32 0
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 %39, label %5
5: ; preds = %2, %35
%6 = phi %struct.group* [ %37, %35 ], [ %3, %2 ]
%7 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 2
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %10, i32 %12)
%14 = getelementptr inbounds %struct.group, %struct.group* %6, i64 0, i32 3
%15 = load i8**, i8*** %14
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %35, label %18
18: ; preds = %5, %33
%19 = phi i8* [ %31, %33 ], [ %16, %5 ]
%20 = phi i8** [ %34, %33 ], [ %15, %5 ]
%21 = phi i8** [ %30, %33 ], [ %15, %5 ]
%22 = icmp eq i8** %21, %20
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = tail call i32 @putchar(i8 signext 44)
%25 = load i8*, i8** %21
br label %26
26: ; preds = %23, %18
%27 = phi i8* [ %25, %23 ], [ %19, %18 ]
%28 = load i32, i32* @stdout
%29 = tail call i32 @fputs(i8* %27, i32 %28)
%30 = getelementptr inbounds i8*, i8** %21, i64 1
%31 = load i8*, i8** %30
%32 = icmp eq i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %26
%34 = load i8**, i8*** %14
br label %18
35: ; preds = %26, %5
%36 = tail call i32 @putchar(i8 signext 10)
%37 = tail call %struct.group* (...) @getgrent()
%38 = icmp eq %struct.group* %37, null
br i1 %38, label %39, label %5
39: ; preds = %35, %2
ret i32 0
}