#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;
};
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
struct group *getgrgid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
void print_group(char *prefix, gid_t gid) {
  struct group *group_obj = getgrgid(gid);
  char *group_name = group_obj->gr_name;
  printf("%s%u", prefix, gid);
  if (group_name) {
    printf("(%s)", group_name);
  }
}


x86 assembly (clang, -O0):
<print_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <getgrgid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1178 <print_group+0x58>
mov    -0x20(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_group>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   1040 <getgrgid@plt>
mov    (%rax),%rbx
lea    0xec6(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   %rbx,%rbx
je     1160 <print_group+0x40>
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.group = type { i8* }
@.str = [5 x i8] c"%s%u\00"
@.str.1 = [5 x i8] c"(%s)\00"
define void @print_group(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.group*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call %struct.group* @getgrgid(i32 %7)
store %struct.group* %8, %struct.group** %5
%9 = load %struct.group*, %struct.group** %5
%10 = getelementptr inbounds %struct.group, %struct.group* %9, i32 0, i32 0
%11 = load i8*, i8** %10
store i8* %11, i8** %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %2
ret void
}

LLVM IR (-O2):
%struct.group = type { i8* }
@.str = [5 x i8] c"%s%u\00"
@.str.1 = [5 x i8] c"(%s)\00"
define void @print_group(i8* %0, i32 %1) {
%3 = tail call %struct.group* @getgrgid(i32 %1)
%4 = getelementptr inbounds %struct.group, %struct.group* %3, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%7 = icmp eq i8* %5, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %10
10: ; preds = %8, %2
ret void
}