#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 */
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void ipm_get_job_allocation(char *allocation, int len) {
  char *s = 0;
  if (!s)
    s = getenv("REPO");
  if (!s)
    s = getenv("GROUP");
  if (s) {
    sprintf(allocation, "%s", s);
  } else {
    strncpy(allocation, "unknown", len);
  }
}


x86 assembly (clang, -O0):
<ipm_get_job_allocation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1162 <ipm_get_job_allocation+0x32>
lea    0xea7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117d <ipm_get_job_allocation+0x4d>
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a1 <ipm_get_job_allocation+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11b4 <ipm_get_job_allocation+0x84>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe5f(%rip),%rsi
call   1040 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipm_get_job_allocation>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    115a <ipm_get_job_allocation+0x2a>
lea    0xeb5(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     116b <ipm_get_job_allocation+0x3b>
mov    %rbx,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <strcpy@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <strncpy@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"REPO\00"
@.str.1 = [6 x i8] c"GROUP\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"unknown\00"
define void @ipm_get_job_allocation(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* null, i8** %5
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %5
br label %10
10: ; preds = %8, %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %5
br label %15
15: ; preds = %13, %10
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %3
%20 = load i8*, i8** %5
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %26
22: ; preds = %15
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = call i32 @strncpy(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %18
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"REPO\00"
@.str.1 = [6 x i8] c"GROUP\00"
@.str.3 = [8 x i8] c"unknown\00"
define void @ipm_get_job_allocation(i8* %0, i32 %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %6, %5 ], [ %3, %2 ]
%10 = tail call i8* @strcpy(i8* dereferenceable(1) %0, i8* %9)
br label %13
11: ; preds = %5
%12 = tail call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %13
13: ; preds = %11, %8
ret void
}