#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;
  int gr_gid;
  scalar_t__ *gr_mem;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct group *my_getgrnam(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, scalar_t__, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct group pwd;
  struct group *result;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s group\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  result = my_getgrnam(argv[1]);
  if (result == NULL) {
    perror("getgrnam");
    exit(EXIT_FAILURE);
  }
  pwd = *result;
  printf("Name: %s; GID: %d\n", pwd.gr_name, pwd.gr_gid);
  for (int i = 0; pwd.gr_mem[i] != 0; ++i)
    printf("  %s\n", pwd.gr_mem[i]);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <my_getgrnam@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d0 <main+0x80>
lea    0xe54(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,-0x28(%rbp)
mov    0x8(%rax),%rcx
mov    %rcx,-0x20(%rbp)
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1242 <main+0xf2>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1207 <main+0xb7>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1175 <main+0x25>
mov    0x8(%rsi),%rdi
call   1070 <my_getgrnam@plt>
test   %rax,%rax
jne    119b <main+0x4b>
lea    0xea3(%rip),%rdi
call   1050 <perror@plt>
jmp    118d <main+0x3d>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    0x10(%rax),%rbx
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11e6 <main+0x96>
add    $0x8,%rbx
lea    0xe67(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11d0 <main+0x80>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.group = type { i8*, i32, i64* }
@stderr = global i32 0
@.str = [17 x i8] c"Usage: %s group\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"getgrnam\00"
@.str.2 = [19 x i8] c"Name: %s; GID: %d\0A\00"
@.str.3 = [6 x i8] c" %s\0A\00"
@EXIT_SUCCESS = 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 %struct.group*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call %struct.group* @my_getgrnam(i8* %22)
store %struct.group* %23, %struct.group** %7
%24 = load %struct.group*, %struct.group** %7
%25 = icmp eq %struct.group* %24, null
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %19
%31 = load %struct.group*, %struct.group** %7
%32 = bitcast %struct.group* %6 to i8*
%33 = bitcast %struct.group* %31 to i8*
%34 = getelementptr inbounds %struct.group, %struct.group* %6, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = ptrtoint i8* %35 to i64
%37 = getelementptr inbounds %struct.group, %struct.group* %6, i32 0, i32 1
%38 = load i32, i32* %37
%39 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %36, i32 %38)
store i32 0, i32* %8
br label %40
40: ; preds = %56, %30
%41 = getelementptr inbounds %struct.group, %struct.group* %6, i32 0, i32 2
%42 = load i64*, i64** %41
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i64, i64* %42, i64 %44
%46 = load i64, i64* %45
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %59
48: ; preds = %40
%49 = getelementptr inbounds %struct.group, %struct.group* %6, i32 0, i32 2
%50 = load i64*, i64** %49
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i64, i64* %50, i64 %52
%54 = load i64, i64* %53
%55 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %54)
br label %56
56: ; preds = %48
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %40
59: ; preds = %40
%60 = load i32, i32* @EXIT_SUCCESS
%61 = call i32 @exit(i32 %60)
unreachable
}

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