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

/* Variables and functions */
int /*<<< orphan*/ _id_error(char *, int /*<<< orphan*/);
struct group *getgrgid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ putchar(char);
struct group *_print_gid(gid_t gid) {
  struct group *gr;
  if ((gr = getgrgid(gid)) == NULL) {
    putchar('\n');
    _id_error("getgrgid", 0);
  } else
    printf("gid=%u(%s)", gr->gr_gid, gr->gr_name);
  return gr;
}


x86 assembly (clang, -O0):
<_print_gid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <getgrgid@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117e <_print_gid+0x3e>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe8e(%rip),%rdi
xor    %esi,%esi
call   1060 <_id_error@plt>
jmp    1198 <_print_gid+0x58>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_print_gid>:
push   %rbx
call   1050 <getgrgid@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1162 <_print_gid+0x22>
mov    (%rbx),%esi
mov    0x8(%rbx),%rdx
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
jmp    117a <_print_gid+0x3a>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe8d(%rip),%rdi
xor    %esi,%esi
call   1060 <_id_error@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

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