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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
struct group *getgrnam(char const *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  struct group *ptr;
  if (argc != 2) {
    printf("wrong argument\n");
    exit(-1);
  }
  if ((ptr = getgrnam(argv[1])) != NULL) {
    printf("name = %s, passwd =%s, gid = %d\n", ptr->gr_name, ptr->gr_passwd,
           ptr->gr_gid);
    printf("group member:\n");
    while (*ptr->gr_mem != NULL) {
      printf("%s\n", *ptr->gr_mem);
      ptr->gr_mem++;
    }
  } else {
    printf("there is no group name %s\n", argv[1]);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     1168 <main+0x38>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11fa <main+0xca>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpq   $0x0,(%rax)
je     11f5 <main+0xc5>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rcx
add    $0x8,%rcx
mov    %rcx,0x18(%rax)
jmp    11b5 <main+0x85>
jmp    1210 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11c8 <main+0x88>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <getgrnam@plt>
test   %rax,%rax
je     11ac <main+0x6c>
mov    %rax,%rbx
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%ecx
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    0x18(%rbx),%rax
mov    (%rax),%rdi
nopl   0x0(%rax,%rax,1)
test   %rdi,%rdi
je     11be <main+0x7e>
call   1030 <puts@plt>
mov    0x18(%rbx),%rax
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rbx)
mov    0x8(%rax),%rdi
jmp    1190 <main+0x50>
mov    0x8(%r14),%rsi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i32, i8** }
@.str = [16 x i8] c"wrong argument\0A\00"
@.str.1 = [33 x i8] c"name = %s, passwd =%s, gid = %d\0A\00"
@.str.2 = [15 x i8] c"group member:\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [27 x i8] c"there is no group name %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
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.group* @getgrnam(i8* %15)
store %struct.group* %16, %struct.group** %6
%17 = icmp ne %struct.group* %16, null
br i1 %17, label %18, label %47
18: ; preds = %12
%19 = load %struct.group*, %struct.group** %6
%20 = getelementptr inbounds %struct.group, %struct.group* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = load %struct.group*, %struct.group** %6
%23 = getelementptr inbounds %struct.group, %struct.group* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = load %struct.group*, %struct.group** %6
%26 = getelementptr inbounds %struct.group, %struct.group* %25, i32 0, i32 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %24, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %36, %18
%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 = icmp ne i8* %34, null
br i1 %35, label %36, label %46
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 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = load %struct.group*, %struct.group** %6
%43 = getelementptr inbounds %struct.group, %struct.group* %42, i32 0, i32 3
%44 = load i8**, i8*** %43
%45 = getelementptr inbounds i8*, i8** %44, i32 1
store i8** %45, i8*** %43
br label %30
46: ; preds = %30
br label %52
47: ; preds = %12
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %47, %46
ret i32 0
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32, i8** }
@.str.1 = [33 x i8] c"name = %s, passwd =%s, gid = %d\0A\00"
@.str.4 = [27 x i8] c"there is no group name %s\0A\00"
@str = [14 x i8] c"group member:\00"
@str.5 = [15 x i8] c"wrong argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, 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 %32, label %12
12: ; preds = %7
%13 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 2
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16, i32 %18)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%21 = getelementptr inbounds %struct.group, %struct.group* %10, i64 0, i32 3
%22 = load i8**, i8*** %21
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
br i1 %24, label %35, label %25
25: ; preds = %12, %25
%26 = phi i8* [ %30, %25 ], [ %23, %12 ]
%27 = tail call i32 @puts(i8* %26)
%28 = load i8**, i8*** %21
%29 = getelementptr inbounds i8*, i8** %28, i64 1
store i8** %29, i8*** %21
%30 = load i8*, i8** %29
%31 = icmp eq i8* %30, null
br i1 %31, label %35, label %25
32: ; preds = %7
%33 = load i8*, i8** %8
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %25, %12, %32
ret i32 0
}