#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
unsigned char *makegroupsid(const unsigned char *sid) {
  static unsigned char groupsid[80];
  int size;
  size = 8 + 4 * sid[1];
  memcpy(groupsid, sid, size);
  groupsid[size - 4] = 1;
  groupsid[size - 3] = 2;
  groupsid[size - 2] = 0;
  groupsid[size - 1] = 0;
  return (groupsid);
}


x86 assembly (clang, -O0):
<makegroupsid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x2,%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0x2f05(%rip),%rdi
call   1030 <memcpy@plt>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
movslq %eax,%rcx
lea    0x2ef0(%rip),%rax
movb   $0x1,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
movslq %eax,%rcx
lea    0x2edc(%rip),%rax
movb   $0x2,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
movslq %eax,%rcx
lea    0x2ec8(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2eb4(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2ea9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makegroupsid>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
movzbl 0x1(%rdi),%ebx
lea    0x0(,%rbx,4),%rdx
add    $0x8,%edx
lea    0x2f13(%rip),%r14
mov    %r14,%rdi
call   1030 <memcpy@plt>
movl   $0x201,0x4(%r14,%rbx,4)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@makegroupsid.groupsid = internal global [80 x i8] zeroinitializer
define i8* @makegroupsid(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = mul nsw i32 4, %7
%9 = add nsw i32 8, %8
store i32 %9, i32* %3
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = call i32 @memcpy(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 0), i8* %10, i32 %11)
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %15
store i8 1, i8* %16
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %19
store i8 2, i8* %20
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %23
store i8 0, i8* %24
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %27
store i8 0, i8* %28
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 0)
}

LLVM IR (-O2):
@makegroupsid.groupsid = internal global [80 x i8] zeroinitializer
define i8* @makegroupsid(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = shl nuw nsw i32 %4, 2
%6 = add nuw nsw i32 %5, 8
%7 = tail call i32 @memcpy(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 0), i8* %0, i32 %6)
%8 = add nuw nsw i32 %5, 4
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %9
store i8 1, i8* %10
%11 = add nuw nsw i32 %5, 5
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %12
store i8 2, i8* %13
%14 = add nuw nsw i32 %5, 6
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %15
store i8 0, i8* %16
%17 = add nuw nsw i32 %5, 7
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 %18
store i8 0, i8* %19
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @makegroupsid.groupsid, i64 0, i64 0)
}