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

/* Variables and functions */
struct group *getgrnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main() {
  int i;
  struct group *gr = getgrnam("fnord");
  if (!gr)
    gr = getgrnam("uucp");
  if (!gr) {
    puts("not found");
    return 0;
  }
  printf("name %s\tpassword %s\tgid %u\t[", gr->gr_name, gr->gr_passwd,
         gr->gr_gid);
  for (i = 0; i < 8; ++i) {
    if (gr->gr_mem[i])
      printf("%s%s", gr->gr_mem[i], gr->gr_mem[i + 1] ? "," : "");
    else
      break;
  }
  printf("]\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1050 <getgrnam@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116a <main+0x3a>
lea    0xea5(%rip),%rdi
call   1050 <getgrnam@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118d <main+0x5d>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1254 <main+0x124>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%ecx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    123f <main+0x10f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x8(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1227 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe36(%rip),%rdx
lea    0xe2b(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122c <main+0xfc>
jmp    123f <main+0x10f>
jmp    1231 <main+0x101>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b8 <main+0x88>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rdi
call   1050 <getgrnam@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1161 <main+0x31>
lea    0xeb6(%rip),%rdi
call   1050 <getgrnam@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12e6 <main+0x1b6>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%ecx
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    (%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x8(%rax)
lea    0xea3(%rip),%r15
lea    0xe9b(%rip),%r14
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x8(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x10(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x10(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x18(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x18(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x20(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x20(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x28(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xddc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x28(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x30(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xdb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x30(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x38(%rax)
mov    %r14,%rdx
cmove  %r15,%rdx
lea    0xd8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0x38(%rax),%rsi
test   %rsi,%rsi
je     12d2 <main+0x1a2>
cmpq   $0x0,0x40(%rax)
cmove  %r15,%r14
lea    0xd6a(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd60(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd1e(%rip),%rdi
jmp    12d9 <main+0x1a9>

LLVM IR (-O0):
%struct.group = type { i8*, i8*, i32, i8** }
@.str = [6 x i8] c"fnord\00"
@.str.1 = [5 x i8] c"uucp\00"
@.str.2 = [10 x i8] c"not found\00"
@.str.3 = [29 x i8] c"name %s\09password %s\09gid %u\09[\00"
@.str.4 = [5 x i8] c"%s%s\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [3 x i8] c"]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.group*
store i32 0, i32* %1
%4 = call %struct.group* @getgrnam(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store %struct.group* %4, %struct.group** %3
%5 = load %struct.group*, %struct.group** %3
%6 = icmp ne %struct.group* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call %struct.group* @getgrnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store %struct.group* %8, %struct.group** %3
br label %9
9: ; preds = %7, %0
%10 = load %struct.group*, %struct.group** %3
%11 = icmp ne %struct.group* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %64
14: ; preds = %9
%15 = load %struct.group*, %struct.group** %3
%16 = getelementptr inbounds %struct.group, %struct.group* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = load %struct.group*, %struct.group** %3
%19 = getelementptr inbounds %struct.group, %struct.group* %18, i32 0, i32 1
%20 = load i8*, i8** %19
%21 = load %struct.group*, %struct.group** %3
%22 = getelementptr inbounds %struct.group, %struct.group* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %20, i32 %23)
store i32 0, i32* %2
br label %25
25: ; preds = %59, %14
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 8
br i1 %27, label %28, label %62
28: ; preds = %25
%29 = load %struct.group*, %struct.group** %3
%30 = getelementptr inbounds %struct.group, %struct.group* %29, i32 0, i32 3
%31 = load i8**, i8*** %30
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %57
37: ; preds = %28
%38 = load %struct.group*, %struct.group** %3
%39 = getelementptr inbounds %struct.group, %struct.group* %38, i32 0, i32 3
%40 = load i8**, i8*** %39
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = load %struct.group*, %struct.group** %3
%46 = getelementptr inbounds %struct.group, %struct.group* %45, i32 0, i32 3
%47 = load i8**, i8*** %46
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %47, i64 %50
%52 = load i8*, i8** %51
%53 = icmp ne i8* %52, null
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %44, i8* %55)
br label %58
57: ; preds = %28
br label %62
58: ; preds = %37
br label %59
59: ; preds = %58
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %25
62: ; preds = %57, %25
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %64
64: ; preds = %62, %12
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
%struct.group = type { i8*, i8*, i32, i8** }
@.str = [6 x i8] c"fnord\00"
@.str.1 = [5 x i8] c"uucp\00"
@.str.2 = [10 x i8] c"not found\00"
@.str.3 = [29 x i8] c"name %s\09password %s\09gid %u\09[\00"
@.str.4 = [5 x i8] c"%s%s\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [1 x i8] zeroinitializer
@str = [2 x i8] c"]\00"
define i32 @main() {
%1 = tail call %struct.group* @getgrnam(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq %struct.group* %1, null
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call %struct.group* @getgrnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq %struct.group* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %99
8: ; preds = %0, %3
%9 = phi %struct.group* [ %4, %3 ], [ %1, %0 ]
%10 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 2
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* %13, i32 %15)
%17 = getelementptr inbounds %struct.group, %struct.group* %9, i64 0, i32 3
%18 = load i8**, i8*** %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %97, label %21
21: ; preds = %8
%22 = getelementptr inbounds i8*, i8** %18, i64 1
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
%25 = select i1 %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %19, i8* %25)
%27 = load i8**, i8*** %17
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %97, label %31
31: ; preds = %21
%32 = getelementptr inbounds i8*, i8** %27, i64 2
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
%35 = select i1 %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %29, i8* %35)
%37 = load i8**, i8*** %17
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %97, label %41
41: ; preds = %31
%42 = getelementptr inbounds i8*, i8** %37, i64 3
%43 = load i8*, i8** %42
%44 = icmp eq i8* %43, null
%45 = select i1 %44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %39, i8* %45)
%47 = load i8**, i8*** %17
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = icmp eq i8* %49, null
br i1 %50, label %97, label %51
51: ; preds = %41
%52 = getelementptr inbounds i8*, i8** %47, i64 4
%53 = load i8*, i8** %52
%54 = icmp eq i8* %53, null
%55 = select i1 %54, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %49, i8* %55)
%57 = load i8**, i8*** %17
%58 = getelementptr inbounds i8*, i8** %57, i64 4
%59 = load i8*, i8** %58
%60 = icmp eq i8* %59, null
br i1 %60, label %97, label %61
61: ; preds = %51
%62 = getelementptr inbounds i8*, i8** %57, i64 5
%63 = load i8*, i8** %62
%64 = icmp eq i8* %63, null
%65 = select i1 %64, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %59, i8* %65)
%67 = load i8**, i8*** %17
%68 = getelementptr inbounds i8*, i8** %67, i64 5
%69 = load i8*, i8** %68
%70 = icmp eq i8* %69, null
br i1 %70, label %97, label %71
71: ; preds = %61
%72 = getelementptr inbounds i8*, i8** %67, i64 6
%73 = load i8*, i8** %72
%74 = icmp eq i8* %73, null
%75 = select i1 %74, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %69, i8* %75)
%77 = load i8**, i8*** %17
%78 = getelementptr inbounds i8*, i8** %77, i64 6
%79 = load i8*, i8** %78
%80 = icmp eq i8* %79, null
br i1 %80, label %97, label %81
81: ; preds = %71
%82 = getelementptr inbounds i8*, i8** %77, i64 7
%83 = load i8*, i8** %82
%84 = icmp eq i8* %83, null
%85 = select i1 %84, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %79, i8* %85)
%87 = load i8**, i8*** %17
%88 = getelementptr inbounds i8*, i8** %87, i64 7
%89 = load i8*, i8** %88
%90 = icmp eq i8* %89, null
br i1 %90, label %97, label %91
91: ; preds = %81
%92 = getelementptr inbounds i8*, i8** %87, i64 8
%93 = load i8*, i8** %92
%94 = icmp eq i8* %93, null
%95 = select i1 %94, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %89, i8* %95)
br label %97
97: ; preds = %91, %81, %71, %61, %51, %41, %31, %21, %8
%98 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %99
99: ; preds = %97, %6
ret i32 0
}