#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*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char *, int);
void checkEnvironmentAndFill(char *string_to_fill, char *key, int key_length,
                             char *property_key, char *env_var) {
  char has_property_key[255];
  char get_property_key[255];
  char *env_value = getenv(env_var);
  sprintf(has_property_key, "Use%sProxy", property_key);
  sprintf(get_property_key, "%sProxyHost", property_key);
  if (strncmp(has_property_key, key, key_length) == 0) {
    strcpy(string_to_fill, env_value ? "1" : "0");
  } else if (strncmp(get_property_key, key, key_length) == 0) {
    strcpy(string_to_fill, env_value ? env_value : "\0");
  }
}


x86 assembly (clang, -O0):
<checkEnvironmentAndFill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x238(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x230(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11e4 <checkEnvironmentAndFill+0xa4>
mov    -0x8(%rbp),%rdi
mov    -0x238(%rbp),%rcx
lea    0xe4e(%rip),%rsi
lea    0xe45(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
call   1050 <strcpy@plt>
jmp    1258 <checkEnvironmentAndFill+0x118>
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1253 <checkEnvironmentAndFill+0x113>
mov    -0x8(%rbp),%rax
mov    %rax,-0x240(%rbp)
cmpq   $0x0,-0x238(%rbp)
je     122d <checkEnvironmentAndFill+0xed>
mov    -0x238(%rbp),%rax
mov    %rax,-0x248(%rbp)
jmp    1240 <checkEnvironmentAndFill+0x100>
lea    0xde7(%rip),%rax
mov    %rax,-0x248(%rbp)
jmp    1240 <checkEnvironmentAndFill+0x100>
mov    -0x240(%rbp),%rdi
mov    -0x248(%rbp),%rsi
call   1050 <strcpy@plt>
jmp    1258 <checkEnvironmentAndFill+0x118>
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkEnvironmentAndFill>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rcx,%rbp
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %r8,%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
lea    0xe91(%rip),%rsi
lea    0x100(%rsp),%r13
mov    %r13,%rdi
mov    %rbp,%rdx
call   1060 <sprintf@plt>
lea    0xe82(%rip),%rsi
mov    %rsp,%rdi
mov    %rbp,%rdx
call   1060 <sprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11ca <checkEnvironmentAndFill+0x8a>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    11e7 <checkEnvironmentAndFill+0xa7>
test   %r15,%r15
lea    0xe57(%rip),%rsi
cmovne %r15,%rsi
jmp    11df <checkEnvironmentAndFill+0x9f>
test   %r15,%r15
lea    0xe45(%rip),%rax
lea    0xe3c(%rip),%rsi
cmove  %rax,%rsi
mov    %r14,%rdi
call   1050 <strcpy@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Use%sProxy\00"
@.str.1 = [12 x i8] c"%sProxyHost\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [2 x i8] zeroinitializer
define void @checkEnvironmentAndFill(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [255 x i8]
%12 = alloca [255 x i8]
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%14 = load i8*, i8** %10
%15 = call i8* @getenv(i8* %14)
store i8* %15, i8** %13
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%17 = load i8*, i8** %9
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%20 = load i8*, i8** %9
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %11, i64 0, i64 0
%23 = load i8*, i8** %7
%24 = load i32, i32* %8
%25 = call i64 @strncmp(i8* %22, i8* %23, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %5
%28 = load i8*, i8** %6
%29 = load i8*, i8** %13
%30 = icmp ne i8* %29, null
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%33 = call i32 @strcpy(i8* %28, i8* %32)
br label %51
34: ; preds = %5
%35 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%36 = load i8*, i8** %7
%37 = load i32, i32* %8
%38 = call i64 @strncmp(i8* %35, i8* %36, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %34
%41 = load i8*, i8** %6
%42 = load i8*, i8** %13
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i8*, i8** %13
br label %47
46: ; preds = %40
br label %47
47: ; preds = %46, %44
%48 = phi i8* [ %45, %44 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %46 ]
%49 = call i32 @strcpy(i8* %41, i8* %48)
br label %50
50: ; preds = %47, %34
br label %51
51: ; preds = %50, %27
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Use%sProxy\00"
@.str.1 = [12 x i8] c"%sProxyHost\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [2 x i8] zeroinitializer
define void @checkEnvironmentAndFill(i8* %0, i8* %1, i32 %2, i8* %3, i8* nocapture %4) {
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%10 = tail call i8* @getenv(i8* %4)
%11 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%13 = call i64 @strncmp(i8* %8, i8* %1, i32 %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = icmp eq i8* %10, null
%17 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
br label %24
18: ; preds = %5
%19 = call i64 @strncmp(i8* %9, i8* %1, i32 %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = icmp eq i8* %10, null
%23 = select i1 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %10
br label %24
24: ; preds = %15, %21
%25 = phi i8* [ %23, %21 ], [ %17, %15 ]
%26 = call i32 @strcpy(i8* %0, i8* %25)
br label %27
27: ; preds = %24, %18
ret void
}