#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_passwd;
  int /*<<< orphan*/ *gr_name;
};

/* Variables and functions */
void *malloc(int);
int strlen(char *);
int exfiles_alloc_group_from_gr_entry(struct group *grbuf, char **gr_entry) {
  grbuf->gr_name = malloc(sizeof(char) * (strlen(gr_entry[0]) + 1));
  grbuf->gr_passwd = malloc(sizeof(char) * (strlen(gr_entry[1]) + 1));
  if (grbuf->gr_name == NULL || grbuf->gr_passwd == NULL)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<exfiles_alloc_group_from_gr_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     119b <exfiles_alloc_group_from_gr_entry+0x7b>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a7 <exfiles_alloc_group_from_gr_entry+0x87>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <exfiles_alloc_group_from_gr_entry+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exfiles_alloc_group_from_gr_entry>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    0x8(%r14),%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
cmpq   $0x0,0x8(%rbx)
sete   %cl
test   %rax,%rax
sete   %al
or     %cl,%al
movzbl %al,%eax
neg    %eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.group = type { i32*, i32* }
define i32 @exfiles_alloc_group_from_gr_entry(%struct.group* %0, i8** %1) {
%3 = alloca i32
%4 = alloca %struct.group*
%5 = alloca i8**
store %struct.group* %0, %struct.group** %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @malloc(i32 %13)
%15 = bitcast i8* %14 to i32*
%16 = load %struct.group*, %struct.group** %4
%17 = getelementptr inbounds %struct.group, %struct.group* %16, i32 0, i32 1
store i32* %15, i32** %17
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = mul i64 1, %23
%25 = trunc i64 %24 to i32
%26 = call i8* @malloc(i32 %25)
%27 = bitcast i8* %26 to i32*
%28 = load %struct.group*, %struct.group** %4
%29 = getelementptr inbounds %struct.group, %struct.group* %28, i32 0, i32 0
store i32* %27, i32** %29
%30 = load %struct.group*, %struct.group** %4
%31 = getelementptr inbounds %struct.group, %struct.group* %30, i32 0, i32 1
%32 = load i32*, i32** %31
%33 = icmp eq i32* %32, null
br i1 %33, label %39, label %34
34: ; preds = %2
%35 = load %struct.group*, %struct.group** %4
%36 = getelementptr inbounds %struct.group, %struct.group* %35, i32 0, i32 0
%37 = load i32*, i32** %36
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %40
39: ; preds = %34, %2
store i32 -1, i32* %3
br label %41
40: ; preds = %34
store i32 0, i32* %3
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.group = type { i32*, i32* }
define i32 @exfiles_alloc_group_from_gr_entry(%struct.group* nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @strlen(i8* %3)
%5 = add nsw i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = getelementptr inbounds %struct.group, %struct.group* %0, i64 0, i32 1
%8 = bitcast i32** %7 to i8**
store i8* %6, i8** %8
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = tail call i8* @malloc(i32 %12)
%14 = bitcast %struct.group* %0 to i8**
store i8* %13, i8** %14
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
%17 = icmp eq i8* %13, null
%18 = or i1 %17, %16
%19 = sext i1 %18 to i32
ret i32 %19
}