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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct group *getgrnam(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct group *p;
  while (--argc > 0) {
    if ((p = getgrnam(*++argv)) == NULL) {
      fprintf(stderr, "getgruid failed: %s\n", strerror(errno));
      continue;
    }
    printf("%s, %s, %d\n", p->gr_name, p->gr_passwd, p->gr_gid);
    while (*p->gr_mem != NULL) {
      printf("\t\t%s\n", *p->gr_mem++);
    }
  }
  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    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1223 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1050 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bf <main+0x7f>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe4b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1156 <main+0x16>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpq   $0x0,(%rax)
je     121e <main+0xde>
mov    -0x18(%rbp),%rcx
mov    0x18(%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,0x18(%rcx)
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xa3>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1201 <main+0xc1>
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xe9f(%rip),%r15
lea    0xead(%rip),%r12
lea    0xeb2(%rip),%r13
jmp    11b5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2e59(%rip),%rax
mov    (%rax),%ebp
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <fprintf@plt>
lea    -0x1(%r14),%eax
add    $0x8,%rbx
cmp    $0x2,%r14d
mov    %eax,%r14d
jle    1201 <main+0xc1>
mov    0x8(%rbx),%rdi
call   1050 <getgrnam@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    %rax,%rbp
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%ecx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
nopw   0x0(%rax,%rax,1)
mov    0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a4 <main+0x64>
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rbp)
mov    (%rax),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e0 <main+0xa0>
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*, i32, i32** }
@stderr = global i32 0
@.str = [21 x i8] c"getgruid failed: %s\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"%s, %s, %d\0A\00"
@.str.2 = [6 x i8] c"\09\09%s\0A\00"
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 = %47, %17, %2
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %48
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
%14 = load i8*, i8** %13
%15 = call %struct.group* @getgrnam(i8* %14)
store %struct.group* %15, %struct.group** %6
%16 = icmp eq %struct.group* %15, null
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %7
22: ; preds = %11
%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 = load %struct.group*, %struct.group** %6
%27 = getelementptr inbounds %struct.group, %struct.group* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = load %struct.group*, %struct.group** %6
%30 = getelementptr inbounds %struct.group, %struct.group* %29, i32 0, i32 2
%31 = load i32, i32* %30
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %28, i32 %31)
br label %33
33: ; preds = %39, %22
%34 = load %struct.group*, %struct.group** %6
%35 = getelementptr inbounds %struct.group, %struct.group* %34, i32 0, i32 3
%36 = load i32**, i32*** %35
%37 = load i32*, i32** %36
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %47
39: ; preds = %33
%40 = load %struct.group*, %struct.group** %6
%41 = getelementptr inbounds %struct.group, %struct.group* %40, i32 0, i32 3
%42 = load i32**, i32*** %41
%43 = getelementptr inbounds i32*, i32** %42, i32 1
store i32** %43, i32*** %41
%44 = load i32*, i32** %42
%45 = bitcast i32* %44 to i8*
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %33
47: ; preds = %33
br label %7
48: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32, i32** }
@stderr = global i32 0
@.str = [21 x i8] c"getgruid failed: %s\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"%s, %s, %d\0A\00"
@.str.2 = [6 x i8] c"\09\09%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %40
4: ; preds = %2, %17
%5 = phi i32 [ %7, %17 ], [ %0, %2 ]
%6 = phi i8** [ %8, %17 ], [ %1, %2 ]
%7 = add nsw i32 %5, -1
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = tail call %struct.group* @getgrnam(i8* %9)
%11 = icmp eq %struct.group* %10, null
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %31, %19, %12
%18 = icmp sgt i32 %5, 2
br i1 %18, label %4, label %40
19: ; preds = %4
%20 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 2
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %23, i32 %25)
%27 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 3
%28 = load i32**, i32*** %27
%29 = load i32*, i32** %28
%30 = icmp eq i32* %29, null
br i1 %30, label %17, label %31
31: ; preds = %19, %31
%32 = phi i32** [ %37, %31 ], [ %28, %19 ]
%33 = getelementptr inbounds i32*, i32** %32, i64 1
store i32** %33, i32*** %27
%34 = bitcast i32** %32 to i8**
%35 = load i8*, i8** %34
%36 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i32**, i32*** %27
%38 = load i32*, i32** %37
%39 = icmp eq i32* %38, null
br i1 %39, label %17, label %31
40: ; preds = %17, %2
ret i32 0
}