#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;
};

/* Variables and functions */
int /*<<< orphan*/ endgrent();
struct group *getgrent();
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ putchar(char);
int main(int argc, char **argv) {
  struct group *g;
  int i;
  while ((g = getgrent()) != NULL) {
    printf("%s:%s:%ld:", g->gr_name, g->gr_passwd, (long)g->gr_gid);
    for (i = 0; g->gr_mem[i] != NULL; i++) {
      printf("%s", g->gr_mem[i]);
      if (g->gr_mem[i + 1] != NULL)
        putchar(',');
    }
    putchar('\n');
  }
  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    $0x0,%al
call   1050 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1214 <main+0xd4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1205 <main+0xc5>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11f2 <main+0xb2>
mov    $0x2c,%edi
call   1040 <putchar@plt>
jmp    11f7 <main+0xb7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1197 <main+0x57>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1156 <main+0x16>
mov    $0x0,%al
call   1030 <endgrent@plt>
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   1050 <getgrent@plt>
test   %rax,%rax
je     11f7 <main+0xb7>
mov    %rax,%r12
lea    0xe9e(%rip),%r14
lea    0xea2(%rip),%r15
jmp    1189 <main+0x49>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1050 <getgrent@plt>
mov    %rax,%r12
test   %rax,%rax
je     11f7 <main+0xb7>
mov    (%r12),%rsi
mov    0x8(%r12),%rdx
mov    0x18(%r12),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r12),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     1170 <main+0x30>
mov    $0x8,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%r12),%rax
cmpq   $0x0,(%rax,%rbx,1)
je     1170 <main+0x30>
mov    $0x2c,%edi
call   1040 <putchar@plt>
mov    0x10(%r12),%rax
mov    (%rax,%rbx,1),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11c0 <main+0x80>
jmp    1170 <main+0x30>
xor    %eax,%eax
call   1030 <endgrent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i8**, i64 }
@.str = [11 x i8] c"%s:%s:%ld:\00"
@.str.1 = [3 x i8] c"%s\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 = %55, %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 %57
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 3
%20 = load i64, i64* %19
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %17, i64 %20)
store i32 0, i32* %7
br label %22
22: ; preds = %52, %11
%23 = load %struct.group*, %struct.group** %6
%24 = getelementptr inbounds %struct.group, %struct.group* %23, i32 0, i32 2
%25 = load i8**, i8*** %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %55
31: ; preds = %22
%32 = load %struct.group*, %struct.group** %6
%33 = getelementptr inbounds %struct.group, %struct.group* %32, i32 0, i32 2
%34 = load i8**, i8*** %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = load %struct.group*, %struct.group** %6
%41 = getelementptr inbounds %struct.group, %struct.group* %40, i32 0, i32 2
%42 = load i8**, i8*** %41
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %51
49: ; preds = %31
%50 = call i32 @putchar(i8 signext 44)
br label %51
51: ; preds = %49, %31
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %22
55: ; preds = %22
%56 = call i32 @putchar(i8 signext 10)
br label %8
57: ; preds = %8
%58 = call i32 (...) @endgrent()
ret i32 0
}

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