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

/* Variables and functions */
int /*<<< orphan*/ errx(int, char *);
struct group *getgrnam(char const *);
int /*<<< orphan*/ id(char const *, char *);
gid_t a_gid(const char *s) {
  struct group *gr;
  if (*s == '\0')
    errx(1, "group must be specified when the owner is");
  return ((gr = getgrnam(s)) == NULL) ? id(s, "group") : gr->gr_gid;
}


x86 assembly (clang, -O0):
<a_gid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115d <a_gid+0x2d>
mov    $0x1,%edi
lea    0xea8(%rip),%rsi
call   1030 <errx@plt>
mov    -0x8(%rbp),%rdi
call   1040 <getgrnam@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118c <a_gid+0x5c>
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <id@plt>
mov    %eax,-0x14(%rbp)
jmp    1195 <a_gid+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_gid>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
jne    114a <a_gid+0x1a>
lea    0xec0(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
mov    %rbx,%rdi
call   1040 <getgrnam@plt>
test   %rax,%rax
je     115b <a_gid+0x2b>
mov    (%rax),%eax
pop    %rbx
ret
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <id@plt>

LLVM IR (-O0):
%struct.group = type { i32 }
@.str = [42 x i8] c"group must be specified when the owner is\00"
@.str.1 = [6 x i8] c"group\00"
define i32 @a_gid(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.group*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %2
%12 = call %struct.group* @getgrnam(i8* %11)
store %struct.group* %12, %struct.group** %3
%13 = icmp eq %struct.group* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i32 @id(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = load %struct.group*, %struct.group** %3
%19 = getelementptr inbounds %struct.group, %struct.group* %18, i32 0, i32 0
%20 = load i32, i32* %19
br label %21
21: ; preds = %17, %14
%22 = phi i32 [ %16, %14 ], [ %20, %17 ]
ret i32 %22
}

LLVM IR (-O2):
%struct.group = type { i32 }
@.str = [42 x i8] c"group must be specified when the owner is\00"
@.str.1 = [6 x i8] c"group\00"
define i32 @a_gid(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call %struct.group* @getgrnam(i8* %0)
%8 = icmp eq %struct.group* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @id(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %14
11: ; preds = %6
%12 = getelementptr inbounds %struct.group, %struct.group* %7, i64 0, i32 0
%13 = load i32, i32* %12
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %10, %9 ], [ %13, %11 ]
ret i32 %15
}