#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 netgroup {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ netgroup_debug_print_all(struct netgroup *,
                                            int /*<<< orphan*/,
                                            int /*<<< orphan*/);
int /*<<< orphan*/ netgroup_debug_print_group_unrolled(struct netgroup *,
                                                       int /*<<< orphan*/,
                                                       int /*<<< orphan*/);
struct netgroup *netgroup_find(struct netgroup *, char *);
struct netgroup *netgroup_parse_all();
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  struct netgroup *groups = netgroup_parse_all();
  if (argc == 1)
    netgroup_debug_print_all(groups, stdout, 0);
  else if (argc == 2) {
    struct netgroup *group = netgroup_find(groups, argv[1]);
    if (!group)
      return 1;
    netgroup_debug_print_group_unrolled(group, stdout, 0);
  }
  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    $0x0,%al
call   1040 <netgroup_parse_all@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1184 <main+0x44>
mov    -0x18(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <netgroup_debug_print_all@plt>
jmp    11d3 <main+0x93>
cmpl   $0x2,-0x8(%rbp)
jne    11ce <main+0x8e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <netgroup_find@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ba <main+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11da <main+0x9a>
mov    -0x20(%rbp),%rdi
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <netgroup_debug_print_group_unrolled@plt>
jmp    11d3 <main+0x93>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <netgroup_parse_all@plt>
cmp    $0x2,%ebp
je     1173 <main+0x33>
cmp    $0x1,%ebp
jne    11a0 <main+0x60>
mov    0x2e7d(%rip),%rcx
mov    (%rcx),%esi
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %edx,%edx
call   1060 <netgroup_debug_print_all@plt>
jmp    11a0 <main+0x60>
mov    0x8(%r14),%rsi
mov    %rax,%rdi
call   1030 <netgroup_find@plt>
test   %rax,%rax
je     119b <main+0x5b>
mov    0x2e55(%rip),%rcx
mov    (%rcx),%esi
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %edx,%edx
call   1050 <netgroup_debug_print_group_unrolled@plt>
jmp    11a0 <main+0x60>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.netgroup = type { i32 }
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.netgroup*
%7 = alloca %struct.netgroup*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call %struct.netgroup* (...) @netgroup_parse_all()
store %struct.netgroup* %8, %struct.netgroup** %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load %struct.netgroup*, %struct.netgroup** %6
%13 = load i32, i32* @stdout
%14 = call i32 @netgroup_debug_print_all(%struct.netgroup* %12, i32 %13, i32 0)
br label %32
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = load %struct.netgroup*, %struct.netgroup** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call %struct.netgroup* @netgroup_find(%struct.netgroup* %19, i8* %22)
store %struct.netgroup* %23, %struct.netgroup** %7
%24 = load %struct.netgroup*, %struct.netgroup** %7
%25 = icmp ne %struct.netgroup* %24, null
br i1 %25, label %27, label %26
26: ; preds = %18
store i32 1, i32* %3
br label %33
27: ; preds = %18
%28 = load %struct.netgroup*, %struct.netgroup** %7
%29 = load i32, i32* @stdout
%30 = call i32 @netgroup_debug_print_group_unrolled(%struct.netgroup* %28, i32 %29, i32 0)
br label %31
31: ; preds = %27, %15
br label %32
32: ; preds = %31, %11
store i32 0, i32* %3
br label %33
33: ; preds = %32, %26
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.netgroup = type { i32 }
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call %struct.netgroup* (...) @netgroup_parse_all()
switch i32 %0, label %15 [
i32 1, label %4
i32 2, label %7
]
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = tail call i32 @netgroup_debug_print_all(%struct.netgroup* %3, i32 %5, i32 0)
br label %15
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call %struct.netgroup* @netgroup_find(%struct.netgroup* %3, i8* %9)
%11 = icmp eq %struct.netgroup* %10, null
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = tail call i32 @netgroup_debug_print_group_unrolled(%struct.netgroup* %10, i32 %13, i32 0)
br label %15
15: ; preds = %7, %4, %2, %12
%16 = phi i32 [ 0, %12 ], [ 0, %2 ], [ 0, %4 ], [ 1, %7 ]
ret i32 %16
}