#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 */
void *fdopen(int, char *);
void *stderr;
void *stdin;
void *stdout;
void dalibc_helix_initialize() {
  stdin = fdopen(0, "r");
  stdout = fdopen(1, "w");
  stderr = fdopen(2, "w");
  if (!stdin || !stdout || !stderr)
    *((int *)0xa0000000) = 1;
}


x86 assembly (clang, -O0):
<dalibc_helix_initialize>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
lea    0xee3(%rip),%rsi
call   1030 <fdopen@plt>
mov    %rax,%rcx
mov    0x2ebc(%rip),%rax
mov    %rcx,(%rax)
mov    $0x1,%edi
lea    0xec7(%rip),%rsi
call   1030 <fdopen@plt>
mov    %rax,%rcx
mov    0x2e86(%rip),%rax
mov    %rcx,(%rax)
mov    $0x2,%edi
lea    0xea9(%rip),%rsi
call   1030 <fdopen@plt>
mov    %rax,%rcx
mov    0x2e70(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e76(%rip),%rax
cmpq   $0x0,(%rax)
je     119e <dalibc_helix_initialize+0x8e>
mov    0x2e4d(%rip),%rax
cmpq   $0x0,(%rax)
je     119e <dalibc_helix_initialize+0x8e>
mov    0x2e44(%rip),%rax
cmpq   $0x0,(%rax)
jne    11a9 <dalibc_helix_initialize+0x99>
mov    $0xa0000000,%eax
movl   $0x1,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<dalibc_helix_initialize>:
push   %r15
push   %r14
push   %rbx
lea    0xee4(%rip),%rsi
xor    %edi,%edi
call   1030 <fdopen@plt>
mov    0x2ebe(%rip),%r14
mov    %rax,(%r14)
lea    0xece(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <fdopen@plt>
mov    0x2e88(%rip),%r15
mov    %rax,(%r15)
mov    $0x2,%edi
mov    %rbx,%rsi
call   1030 <fdopen@plt>
mov    0x2e79(%rip),%rcx
mov    %rax,(%rcx)
test   %rax,%rax
je     1173 <dalibc_helix_initialize+0x63>
cmpq   $0x0,(%r14)
je     1173 <dalibc_helix_initialize+0x63>
cmpq   $0x0,(%r15)
jne    117e <dalibc_helix_initialize+0x6e>
mov    $0xa0000000,%eax
movl   $0x1,(%rax)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdin = global i8* null
@.str.1 = [2 x i8] c"w\00"
@stdout = global i8* null
@stderr = global i8* null
define void @dalibc_helix_initialize() {
%1 = call i8* @fdopen(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %1, i8** @stdin
%2 = call i8* @fdopen(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %2, i8** @stdout
%3 = call i8* @fdopen(i32 2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %3, i8** @stderr
%4 = load i8*, i8** @stdin
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i8*, i8** @stdout
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i8*, i8** @stderr
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %9, %6, %0
store i32 1, i32* inttoptr (i64 2684354560 to i32*)
br label %13
13: ; preds = %12, %9
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdin = global i8* null
@.str.1 = [2 x i8] c"w\00"
@stdout = global i8* null
@stderr = global i8* null
define void @dalibc_helix_initialize() {
%1 = tail call i8* @fdopen(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %1, i8** @stdin
%2 = tail call i8* @fdopen(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %2, i8** @stdout
%3 = tail call i8* @fdopen(i32 2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %3, i8** @stderr
%4 = load i8*, i8** @stdin
%5 = icmp ne i8* %4, null
%6 = load i8*, i8** @stdout
%7 = icmp ne i8* %6, null
%8 = select i1 %5, i1 %7, i1 false
%9 = icmp ne i8* %3, null
%10 = and i1 %9, %8
br i1 %10, label %12, label %11
11: ; preds = %0
store i32 1, i32* inttoptr (i64 2684354560 to i32*)
br label %12
12: ; preds = %0, %11
ret void
}