#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*/ abort();
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
const char *stream_name(FILE *s) {
  if (s == stdin)
    return "stdin";
  if (s == stdout)
    return "stdout";
  if (s == stderr)
    return "stderr";
  abort();
}


x86 assembly (clang, -O0):
<stream_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ec1(%rip),%rcx
cmp    (%rcx),%rax
jne    1140 <stream_name+0x30>
lea    0xec9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <stream_name+0x7f>
mov    -0x10(%rbp),%rax
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
jne    1164 <stream_name+0x54>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <stream_name+0x7f>
mov    -0x10(%rbp),%rax
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%rax
jne    1188 <stream_name+0x78>
lea    0xe8e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <stream_name+0x7f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stream_name>:
push   %rax
mov    0x2ed0(%rip),%rax
cmp    %rdi,(%rax)
je     113e <stream_name+0x2e>
mov    0x2eac(%rip),%rax
cmp    %rdi,(%rax)
je     1147 <stream_name+0x37>
mov    0x2ea8(%rip),%rax
cmp    %rdi,(%rax)
jne    1150 <stream_name+0x40>
lea    0xed1(%rip),%rax
pop    %rcx
ret
lea    0xebb(%rip),%rax
pop    %rcx
ret
lea    0xeb8(%rip),%rax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [6 x i8] c"stdin\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"stdout\00"
@stderr = global i32* null
@.str.2 = [7 x i8] c"stderr\00"
define i8* @stream_name(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = load i32*, i32** @stdin
%6 = icmp eq i32* %4, %5
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %20
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = load i32*, i32** @stdout
%11 = icmp eq i32* %9, %10
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %20
13: ; preds = %8
%14 = load i32*, i32** %3
%15 = load i32*, i32** @stderr
%16 = icmp eq i32* %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
18: ; preds = %13
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %17, %12, %7
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [6 x i8] c"stdin\00"
@stdout = global i32* null
@.str.1 = [7 x i8] c"stdout\00"
@stderr = global i32* null
@.str.2 = [7 x i8] c"stderr\00"
define i8* @stream_name(i32* nocapture readnone %0) {
%2 = load i32*, i32** @stdin
%3 = icmp eq i32* %2, %0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = load i32*, i32** @stdout
%6 = icmp eq i32* %5, %0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = load i32*, i32** @stderr
%9 = icmp eq i32* %8, %0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %7, %4, %1
%13 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %7 ]
ret i8* %13
}