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

/* Variables and functions */
int /*<<< orphan*/ endgrent();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct group *getgrent();
int /*<<< orphan*/ print_group(struct group *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/ *, char *);
int main(int argc, char **argv) {
  struct group *gr;
  int i;
  if (argc != 2) {
    fprintf(stderr, "usage: %s user\n", argv[0]);
    exit(1);
  }
  while ((gr = getgrent()) != NULL)
    for (i = 0; gr->gr_mem[i] != NULL; i++)
      if (strcmp(gr->gr_mem[i], argv[1]) == 0)
        print_group(gr);
  endgrent();
  exit(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)
cmpl   $0x2,-0x8(%rbp)
je     11a6 <main+0x46>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11ab <main+0x4b>
mov    $0x0,%al
call   1040 <getgrent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1224 <main+0xc4>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     121f <main+0xbf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <main+0xac>
mov    -0x18(%rbp),%rdi
call   1070 <print_group@plt>
jmp    1211 <main+0xb1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c7 <main+0x67>
jmp    11ab <main+0x4b>
mov    $0x0,%al
call   1030 <endgrent@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1187 <main+0x27>
xor    %eax,%eax
call   1040 <getgrent@plt>
test   %rax,%rax
jne    11a9 <main+0x49>
xor    %eax,%eax
call   1030 <endgrent@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe66(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %rax,%r15
jmp    11bf <main+0x5f>
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <getgrent@plt>
mov    %rax,%r15
test   %rax,%rax
je     1179 <main+0x19>
mov    (%r15),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     11b0 <main+0x50>
mov    $0x8,%ebx
jmp    11f0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%rax
mov    (%rax,%rbx,1),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11b0 <main+0x50>
mov    0x8(%r14),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e0 <main+0x80>
mov    %r15,%rdi
call   1070 <print_group@plt>
jmp    11e0 <main+0x80>

LLVM IR (-O0):
%struct.group = type { i32** }
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s user\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
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
br label %18
18: ; preds = %51, %17
%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 %52
21: ; preds = %18
store i32 0, i32* %7
br label %22
22: ; preds = %48, %21
%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 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %25, i64 %27
%29 = load i32*, i32** %28
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %51
31: ; preds = %22
%32 = load %struct.group*, %struct.group** %6
%33 = getelementptr inbounds %struct.group, %struct.group* %32, i32 0, i32 0
%34 = load i32**, i32*** %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32*, i32** %34, i64 %36
%38 = load i32*, i32** %37
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i64 @strcmp(i32* %38, i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %31
%45 = load %struct.group*, %struct.group** %6
%46 = call i32 @print_group(%struct.group* %45)
br label %47
47: ; preds = %44, %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %22
51: ; preds = %22
br label %18
52: ; preds = %18
%53 = call i32 (...) @endgrent()
%54 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.group = type { i32** }
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s user\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call %struct.group* (...) @getgrent()
%6 = icmp eq %struct.group* %5, null
br i1 %6, label %37, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8*, i8** %1, i64 1
br label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %31, %17
%15 = tail call %struct.group* (...) @getgrent()
%16 = icmp eq %struct.group* %15, null
br i1 %16, label %37, label %17
17: ; preds = %7, %14
%18 = phi %struct.group* [ %5, %7 ], [ %15, %14 ]
%19 = getelementptr inbounds %struct.group, %struct.group* %18, i64 0, i32 0
%20 = load i32**, i32*** %19
%21 = load i32*, i32** %20
%22 = icmp eq i32* %21, null
br i1 %22, label %14, label %23
23: ; preds = %17, %31
%24 = phi i64 [ %32, %31 ], [ 0, %17 ]
%25 = phi i32* [ %35, %31 ], [ %21, %17 ]
%26 = load i8*, i8** %8
%27 = tail call i64 @strcmp(i32* %25, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = tail call i32 @print_group(%struct.group* %18)
br label %31
31: ; preds = %23, %29
%32 = add nuw i64 %24, 1
%33 = load i32**, i32*** %19
%34 = getelementptr inbounds i32*, i32** %33, i64 %32
%35 = load i32*, i32** %34
%36 = icmp eq i32* %35, null
br i1 %36, label %14, label %23
37: ; preds = %14, %4
%38 = tail call i32 (...) @endgrent()
%39 = tail call i32 @exit(i32 0)
unreachable
}