#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*/ parse_config(char *, char *);
int read_config_env(void) {
  char *c;
  int ret = 0;
  c = getenv("QUARQD_PORT");
  if (c) {
    parse_config("QUARQD_PORT", c);
    ret = 1;
  };
  c = getenv("ANT_TTY");
  if (c) {
    parse_config("ANT_TTY", c);
    ret = 1;
  };
  c = getenv("ANT_BAUDRATE");
  if (c) {
    parse_config("ANT_BAUDRATE", c);
    ret = 1;
  };
  c = getenv("QUARQD_DEBUG");
  if (c) {
    parse_config("QUARQD_DEBUG", c);
    ret = 1;
  };
  return ret;
}


x86 assembly (clang, -O0):
<read_config_env>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1161 <read_config_env+0x41>
mov    -0x8(%rbp),%rsi
lea    0xeab(%rip),%rdi
call   1040 <parse_config@plt>
movl   $0x1,-0xc(%rbp)
lea    0xea4(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1193 <read_config_env+0x73>
mov    -0x8(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1040 <parse_config@plt>
movl   $0x1,-0xc(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c5 <read_config_env+0xa5>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1040 <parse_config@plt>
movl   $0x1,-0xc(%rbp)
lea    0xe55(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f7 <read_config_env+0xd7>
mov    -0x8(%rbp),%rsi
lea    0xe36(%rip),%rdi
call   1040 <parse_config@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config_env>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1148 <read_config_env+0x28>
lea    0xec7(%rip),%rdi
mov    %rax,%rsi
call   1040 <parse_config@plt>
mov    $0x1,%ebx
jmp    114a <read_config_env+0x2a>
xor    %ebx,%ebx
lea    0xebb(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     116f <read_config_env+0x4f>
lea    0xeaa(%rip),%rdi
mov    %rax,%rsi
call   1040 <parse_config@plt>
mov    $0x1,%ebx
lea    0xe9e(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1194 <read_config_env+0x74>
lea    0xe8d(%rip),%rdi
mov    %rax,%rsi
call   1040 <parse_config@plt>
mov    $0x1,%ebx
lea    0xe86(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b9 <read_config_env+0x99>
lea    0xe75(%rip),%rdi
mov    %rax,%rsi
call   1040 <parse_config@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"QUARQD_PORT\00"
@.str.1 = [8 x i8] c"ANT_TTY\00"
@.str.2 = [13 x i8] c"ANT_BAUDRATE\00"
@.str.3 = [13 x i8] c"QUARQD_DEBUG\00"
define i32 @read_config_env() {
%1 = alloca i8*
%2 = alloca i32
store i32 0, i32* %2
%3 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i8*, i8** %1
%8 = call i32 @parse_config(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 1, i32* %2
br label %9
9: ; preds = %6, %0
%10 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %1
%15 = call i32 @parse_config(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 1, i32* %2
br label %16
16: ; preds = %13, %9
%17 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i8* %17, i8** %1
%18 = load i8*, i8** %1
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8*, i8** %1
%22 = call i32 @parse_config(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %21)
store i32 1, i32* %2
br label %23
23: ; preds = %20, %16
%24 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i8* %24, i8** %1
%25 = load i8*, i8** %1
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %1
%29 = call i32 @parse_config(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %28)
store i32 1, i32* %2
br label %30
30: ; preds = %27, %23
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [12 x i8] c"QUARQD_PORT\00"
@.str.1 = [8 x i8] c"ANT_TTY\00"
@.str.2 = [13 x i8] c"ANT_BAUDRATE\00"
@.str.3 = [13 x i8] c"QUARQD_DEBUG\00"
define i32 @read_config_env() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @parse_config(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %5
5: ; preds = %3, %0
%6 = phi i32 [ 1, %3 ], [ 0, %0 ]
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @parse_config(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %11
11: ; preds = %9, %5
%12 = phi i32 [ 1, %9 ], [ %6, %5 ]
%13 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @parse_config(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %17
17: ; preds = %15, %11
%18 = phi i32 [ 1, %15 ], [ %12, %11 ]
%19 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 @parse_config(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %23
23: ; preds = %21, %17
%24 = phi i32 [ 1, %21 ], [ %18, %17 ]
ret i32 %24
}