#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_mem;
  char *gr_name;
  char *gr_passwd;
  int gr_gid;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void dump(struct group *g) {
  char mem[2048];
  char **p;
  int doit = (g->gr_mem && *(g->gr_mem));
  p = g->gr_mem;
  strcpy(mem, "");
  while (doit) {
    if (p != g->gr_mem)
      strcat(mem, ",");
    strcat(mem, *p);
    if (*(++p) == NULL)
      break;
  }
  printf("%s:%s:%d:%s\n", g->gr_name, g->gr_passwd, g->gr_gid, mem);
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x81d(%rbp)
je     1169 <dump+0x39>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x81d(%rbp)
mov    -0x81d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x81c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0x81c(%rbp)
je     120f <dump+0xdf>
mov    -0x818(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
je     11cf <dump+0x9f>
lea    -0x810(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x810(%rbp),%rdi
mov    -0x818(%rbp),%rax
mov    (%rax),%rsi
call   1050 <strcat@plt>
mov    -0x818(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x818(%rbp)
cmpq   $0x0,0x8(%rax)
jne    120a <dump+0xda>
jmp    120f <dump+0xdf>
jmp    119b <dump+0x6b>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%ecx
lea    -0x810(%rbp),%r8
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%r12
mov    (%rdi),%rbx
test   %rbx,%rbx
je     1199 <dump+0x69>
mov    (%rbx),%r14
lea    0xebb(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
test   %r14,%r14
je     11a8 <dump+0x78>
mov    %rsp,%r14
lea    0xe96(%rip),%r15
jmp    1186 <dump+0x56>
nopl   0x0(%rax)
mov    (%rbx),%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
cmpq   $0x0,0x8(%rbx)
lea    0x8(%rbx),%rbx
je     11a8 <dump+0x78>
cmp    (%r12),%rbx
je     1170 <dump+0x40>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
jmp    1170 <dump+0x40>
lea    0xe6e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x8(%r12),%rsi
mov    0x10(%r12),%rdx
mov    0x18(%r12),%ecx
lea    0xe44(%rip),%rdi
mov    %rsp,%r8
call   1040 <printf@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.group = type { i8**, i8*, i8*, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c",\00"
@.str.2 = [13 x i8] c"%s:%s:%d:%s\0A\00"
define void @dump(%struct.group* %0) {
%2 = alloca %struct.group*
%3 = alloca [2048 x i8]
%4 = alloca i8**
%5 = alloca i32
store %struct.group* %0, %struct.group** %2
%6 = load %struct.group*, %struct.group** %2
%7 = getelementptr inbounds %struct.group, %struct.group* %6, i32 0, i32 0
%8 = load i8**, i8*** %7
%9 = icmp ne i8** %8, null
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load %struct.group*, %struct.group** %2
%12 = getelementptr inbounds %struct.group, %struct.group* %11, i32 0, i32 0
%13 = load i8**, i8*** %12
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br label %16
16: ; preds = %10, %1
%17 = phi i1 [ false, %1 ], [ %15, %10 ]
%18 = zext i1 %17 to i32
store i32 %18, i32* %5
%19 = load %struct.group*, %struct.group** %2
%20 = getelementptr inbounds %struct.group, %struct.group* %19, i32 0, i32 0
%21 = load i8**, i8*** %20
store i8** %21, i8*** %4
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %46, %16
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = load i8**, i8*** %4
%29 = load %struct.group*, %struct.group** %2
%30 = getelementptr inbounds %struct.group, %struct.group* %29, i32 0, i32 0
%31 = load i8**, i8*** %30
%32 = icmp ne i8** %28, %31
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %33, %27
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%38 = load i8**, i8*** %4
%39 = load i8*, i8** %38
%40 = call i32 @strcat(i8* %37, i8* %39)
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i32 1
store i8** %42, i8*** %4
%43 = load i8*, i8** %42
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %46
45: ; preds = %36
br label %47
46: ; preds = %36
br label %24
47: ; preds = %45, %24
%48 = load %struct.group*, %struct.group** %2
%49 = getelementptr inbounds %struct.group, %struct.group* %48, i32 0, i32 1
%50 = load i8*, i8** %49
%51 = load %struct.group*, %struct.group** %2
%52 = getelementptr inbounds %struct.group, %struct.group* %51, i32 0, i32 2
%53 = load i8*, i8** %52
%54 = load %struct.group*, %struct.group** %2
%55 = getelementptr inbounds %struct.group, %struct.group* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%58 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %50, i8* %53, i32 %56, i8* %57)
ret void
}

LLVM IR (-O2):
%struct.group = type { i8**, i8*, i8*, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c",\00"
@.str.2 = [13 x i8] c"%s:%s:%d:%s\0A\00"
define void @dump(%struct.group* nocapture %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds %struct.group, %struct.group* %0, i64 0, i32 0
%5 = load i8**, i8*** %4
%6 = icmp eq i8** %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %25
9: ; preds = %1
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
%12 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br i1 %11, label %25, label %13
13: ; preds = %9, %19
%14 = phi i8** [ %22, %19 ], [ %5, %9 ]
%15 = load i8**, i8*** %4
%16 = icmp eq i8** %14, %15
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = load i8*, i8** %14
%21 = call i32 @strcat(i8* %3, i8* %20)
%22 = getelementptr inbounds i8*, i8** %14, i64 1
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %13
25: ; preds = %19, %7, %9
%26 = getelementptr inbounds %struct.group, %struct.group* %0, i64 0, i32 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.group, %struct.group* %0, i64 0, i32 2
%29 = load i8*, i8** %28
%30 = getelementptr inbounds %struct.group, %struct.group* %0, i64 0, i32 3
%31 = load i32, i32* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %29, i32 %31, i8* %3)
ret void
}