#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;
};

/* Variables and functions */
struct group *getgrnam(unsigned char const *);
scalar_t__ is_empty_string(unsigned char const *);
int file_perms_parse_group(const unsigned char *group) {
  struct group *g = 0;
  if (!group)
    return -1;
  if (is_empty_string(group))
    return -1;
  if (!(g = getgrnam(group)))
    return -1;
  return g->gr_gid;
}


x86 assembly (clang, -O0):
<file_perms_parse_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114b <file_perms_parse_group+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <file_perms_parse_group+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <is_empty_string@plt>
cmp    $0x0,%rax
je     116a <file_perms_parse_group+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <file_perms_parse_group+0x76>
mov    -0x10(%rbp),%rdi
call   1040 <getgrnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    118d <file_perms_parse_group+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <file_perms_parse_group+0x76>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_perms_parse_group>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1149 <file_perms_parse_group+0x29>
mov    %rdi,%rbx
call   1030 <is_empty_string@plt>
test   %rax,%rax
jne    1149 <file_perms_parse_group+0x29>
mov    %rbx,%rdi
call   1040 <getgrnam@plt>
test   %rax,%rax
je     1149 <file_perms_parse_group+0x29>
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.group = type { i32 }
define i32 @file_perms_parse_group(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.group*
store i8* %0, i8** %3
store %struct.group* null, %struct.group** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 -1, i32* %2
br label %22
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @is_empty_string(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 -1, i32* %2
br label %22
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call %struct.group* @getgrnam(i8* %14)
store %struct.group* %15, %struct.group** %4
%16 = icmp ne %struct.group* %15, null
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 -1, i32* %2
br label %22
18: ; preds = %13
%19 = load %struct.group*, %struct.group** %4
%20 = getelementptr inbounds %struct.group, %struct.group* %19, i32 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %2
br label %22
22: ; preds = %18, %17, %12, %7
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
%struct.group = type { i32 }
define i32 @file_perms_parse_group(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i64 @is_empty_string(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call %struct.group* @getgrnam(i8* %0)
%8 = icmp eq %struct.group* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = getelementptr inbounds %struct.group, %struct.group* %7, i64 0, i32 0
%11 = load i32, i32* %10
br label %12
12: ; preds = %6, %3, %1, %9
%13 = phi i32 [ %11, %9 ], [ -1, %1 ], [ -1, %3 ], [ -1, %6 ]
ret i32 %13
}