#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
FILE *stream_dflt_stdio_fp(void *fileno) {
  if (fileno == ((void *)0))
    return stdin;
  else if (fileno == ((void *)1))
    return stdout;
  else if (fileno == ((void *)2))
    return stderr;
  return NULL;
}


x86 assembly (clang, -O0):
<stream_dflt_stdio_fp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1126 <stream_dflt_stdio_fp+0x26>
mov    0x2ece(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <stream_dflt_stdio_fp+0x7c>
mov    $0x1,%eax
cmp    %rax,-0x10(%rbp)
jne    1148 <stream_dflt_stdio_fp+0x48>
mov    0x2e94(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <stream_dflt_stdio_fp+0x7c>
mov    $0x2,%eax
cmp    %rax,-0x10(%rbp)
jne    116a <stream_dflt_stdio_fp+0x6a>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <stream_dflt_stdio_fp+0x7c>
jmp    116f <stream_dflt_stdio_fp+0x6f>
jmp    1174 <stream_dflt_stdio_fp+0x74>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stream_dflt_stdio_fp>:
cmp    $0x2,%rdi
je     111c <stream_dflt_stdio_fp+0x1c>
cmp    $0x1,%rdi
je     1127 <stream_dflt_stdio_fp+0x27>
test   %rdi,%rdi
jne    1132 <stream_dflt_stdio_fp+0x32>
mov    0x2ed0(%rip),%rax
mov    (%rax),%rax
ret
mov    0x2eb5(%rip),%rax
mov    (%rax),%rax
ret
mov    0x2ea2(%rip),%rax
mov    (%rax),%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32* null
define i32* @stream_dflt_stdio_fp(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32*, i32** @stdin
store i32* %7, i32** %2
br label %21
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, inttoptr (i64 1 to i8*)
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32*, i32** @stdout
store i32* %12, i32** %2
br label %21
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = icmp eq i8* %14, inttoptr (i64 2 to i8*)
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i32*, i32** @stderr
store i32* %17, i32** %2
br label %21
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
store i32* null, i32** %2
br label %21
21: ; preds = %20, %16, %11, %6
%22 = load i32*, i32** %2
ret i32* %22
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32* null
define i32* @stream_dflt_stdio_fp(i8* %0) {
%2 = ptrtoint i8* %0 to i64
switch i64 %2, label %9 [
i64 0, label %3
i64 1, label %5
i64 2, label %7
]
3: ; preds = %1
%4 = load i32*, i32** @stdin
br label %9
5: ; preds = %1
%6 = load i32*, i32** @stdout
br label %9
7: ; preds = %1
%8 = load i32*, i32** @stderr
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i32* [ %4, %3 ], [ %6, %5 ], [ %8, %7 ], [ null, %1 ]
ret i32* %10
}