#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 kore_server_bind(char *, char const *, char *);
int /*<<< orphan*/ kore_split_string(char *, char *, char **, int);
int /*<<< orphan*/ printf(char *, char const *);
int configure_bind(char *options) {
  char *argv[4];
  kore_split_string(options, " ", argv, 4);
  if (argv[0] == NULL || argv[1] == NULL)
    return (0);
  const char *port = getenv("PORT");
  printf("PORT :%s\n", (port != NULL) ? port : "getenv() returned NULL");
  return (kore_server_bind(argv[0], (port != NULL) ? port : argv[1], argv[2]));
}


x86 assembly (clang, -O0):
<configure_bind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xea5(%rip),%rsi
mov    $0x4,%ecx
call   1050 <kore_split_string@plt>
cmpq   $0x0,-0x30(%rbp)
je     117b <configure_bind+0x3b>
cmpq   $0x0,-0x28(%rbp)
jne    1187 <configure_bind+0x47>
movl   $0x0,-0x4(%rbp)
jmp    120b <configure_bind+0xcb>
lea    0xe74(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11af <configure_bind+0x6f>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    11bf <configure_bind+0x7f>
lea    0xe5b(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11bf <configure_bind+0x7f>
mov    -0x40(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11ef <configure_bind+0xaf>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    11f7 <configure_bind+0xb7>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <kore_server_bind@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configure_bind>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rsi
mov    %rsp,%rdx
mov    $0x4,%ecx
call   1050 <kore_split_string@plt>
xor    %eax,%eax
cmpq   $0x0,(%rsp)
je     11ae <configure_bind+0x6e>
cmpq   $0x0,0x8(%rsp)
je     11ae <configure_bind+0x6e>
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
test   %rax,%rax
lea    0xe8e(%rip),%rsi
cmovne %rax,%rsi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
test   %rbx,%rbx
jne    119d <configure_bind+0x5d>
mov    0x8(%rsp),%rbx
mov    (%rsp),%rdi
mov    0x10(%rsp),%rdx
mov    %rbx,%rsi
call   1060 <kore_server_bind@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"PORT\00"
@.str.2 = [10 x i8] c"PORT :%s\0A\00"
@.str.3 = [23 x i8] c"getenv() returned NULL\00"
define i32 @configure_bind(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4 x i8*]
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
%8 = call i32 @kore_split_string(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7, i32 4)
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %12, %1
store i32 0, i32* %2
br label %41
17: ; preds = %12
%18 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8*, i8** %5
br label %24
23: ; preds = %17
br label %24
24: ; preds = %23, %21
%25 = phi i8* [ %22, %21 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %23 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
%28 = load i8*, i8** %27
%29 = load i8*, i8** %5
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load i8*, i8** %5
br label %36
33: ; preds = %24
%34 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
%35 = load i8*, i8** %34
br label %36
36: ; preds = %33, %31
%37 = phi i8* [ %32, %31 ], [ %35, %33 ]
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @kore_server_bind(i8* %28, i8* %37, i8* %39)
store i32 %40, i32* %2
br label %41
41: ; preds = %36, %16
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [5 x i8] c"PORT\00"
@.str.2 = [10 x i8] c"PORT :%s\0A\00"
@.str.3 = [23 x i8] c"getenv() returned NULL\00"
define i32 @configure_bind(i8* %0) {
%2 = alloca [4 x i8*]
%3 = bitcast [4 x i8*]* %2 to i8*
%4 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%5 = call i32 @kore_split_string(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4, i32 4)
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
%11 = select i1 %7, i1 true, i1 %10
br i1 %11, label %23, label %12
12: ; preds = %1
%13 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
%15 = select i1 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %13
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %4
%18 = load i8*, i8** %8
%19 = select i1 %14, i8* %18, i8* %13
%20 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @kore_server_bind(i8* %17, i8* %19, i8* %21)
br label %23
23: ; preds = %1, %12
%24 = phi i32 [ %22, %12 ], [ 0, %1 ]
ret i32 %24
}