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

/* Variables and functions */
struct gp *add_to_groups(struct gp *, char *, int);
int get_para(int, char **);
int /*<<< orphan*/ print_groups(struct gp *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ readvar(char *, int);
int main(int argc, char *argv[]) {
  char var[256];
  int maxlen = 256;
  int first_n = 0;
  struct gp *groups = NULL;
  if ((first_n = get_para(argc, argv)) < 0) {
    printf("%s: input group flag n.\n", argv[0]);
    return -1;
  }
  while (readvar(var, maxlen) > 0) {
    groups = add_to_groups(groups, var, first_n);
  }
  print_groups(groups);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x100,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
movq   $0x0,-0x120(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <get_para@plt>
mov    %eax,-0x118(%rbp)
cmp    $0x0,%eax
jge    11c2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121b <main+0xcb>
jmp    11c7 <main+0x77>
lea    -0x110(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   1060 <readvar@plt>
cmp    $0x0,%rax
jle    1208 <main+0xb8>
mov    -0x120(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%edx
call   1040 <add_to_groups@plt>
mov    %rax,-0x120(%rbp)
jmp    11c7 <main+0x77>
mov    -0x120(%rbp),%rdi
call   1030 <print_groups@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
call   1070 <get_para@plt>
test   %eax,%eax
js     11bd <main+0x6d>
mov    %eax,%r15d
mov    %rsp,%rdi
mov    $0x100,%esi
call   1060 <readvar@plt>
xor    %r14d,%r14d
xor    %ebx,%ebx
test   %rax,%rax
jle    11b3 <main+0x63>
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1040 <add_to_groups@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x100,%esi
call   1060 <readvar@plt>
test   %rax,%rax
jg     1190 <main+0x40>
mov    %rbx,%rdi
call   1030 <print_groups@plt>
jmp    11d2 <main+0x82>
mov    (%rbx),%rsi
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.gp = type { i32 }
@.str = [25 x i8] c"%s: input group flag n.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.gp*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 256, i32* %7
store i32 0, i32* %8
store %struct.gp* null, %struct.gp** %9
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @get_para(i32 %10, i8** %11)
store i32 %12, i32* %8
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 -1, i32* %3
br label %33
19: ; preds = %2
br label %20
20: ; preds = %25, %19
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%22 = load i32, i32* %7
%23 = call i64 @readvar(i8* %21, i32 %22)
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load %struct.gp*, %struct.gp** %9
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = load i32, i32* %8
%29 = call %struct.gp* @add_to_groups(%struct.gp* %26, i8* %27, i32 %28)
store %struct.gp* %29, %struct.gp** %9
br label %20
30: ; preds = %20
%31 = load %struct.gp*, %struct.gp** %9
%32 = call i32 @print_groups(%struct.gp* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %30, %14
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.gp = type { i32 }
@.str = [25 x i8] c"%s: input group flag n.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @get_para(i32 %0, i8** %1)
%6 = icmp slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i64 @readvar(i8* %4, i32 256)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %13, label %18
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %21
13: ; preds = %7, %13
%14 = phi %struct.gp* [ %15, %13 ], [ null, %7 ]
%15 = call %struct.gp* @add_to_groups(%struct.gp* %14, i8* %4, i32 %5)
%16 = call i64 @readvar(i8* %4, i32 256)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %13, label %18
18: ; preds = %13, %7
%19 = phi %struct.gp* [ null, %7 ], [ %15, %13 ]
%20 = call i32 @print_groups(%struct.gp* %19)
br label %21
21: ; preds = %18, %10
%22 = phi i32 [ -1, %10 ], [ 0, %18 ]
ret i32 %22
}