#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 */
int /*<<< orphan*/ SHUT_RD;
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SHUT_WR;
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int ss_shutdown_(int fd, int how) {
  switch (how) {
  case 0:
    return (shutdown(fd, SHUT_RD) == 0);
  case 1:
    return (shutdown(fd, SHUT_WR) == 0);
  case 2:
    return (shutdown(fd, SHUT_RDWR) == 0);
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<ss_shutdown_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1153 <ss_shutdown_+0x43>
jmp    1131 <ss_shutdown_+0x21>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1177 <ss_shutdown_+0x67>
jmp    1142 <ss_shutdown_+0x32>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     119b <ss_shutdown_+0x8b>
jmp    11bf <ss_shutdown_+0xaf>
mov    -0x8(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <ss_shutdown_+0xb6>
mov    -0x8(%rbp),%edi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <ss_shutdown_+0xb6>
mov    -0x8(%rbp),%edi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <ss_shutdown_+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ss_shutdown_>:
xor    %eax,%eax
cmp    $0x2,%esi
ja     113a <ss_shutdown_+0x2a>
push   %rax
movslq %esi,%rax
lea    0x2ce6(%rip),%rcx
mov    (%rcx,%rax,8),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    $0x8,%rsp
ret

LLVM IR (-O0):
@SHUT_RD = global i32 0
@SHUT_WR = global i32 0
@SHUT_RDWR = global i32 0
define i32 @ss_shutdown_(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %25 [
i32 0, label %7
i32 1, label %13
i32 2, label %19
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = load i32, i32* @SHUT_RD
%10 = call i32 @shutdown(i32 %8, i32 %9)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
store i32 %12, i32* %3
br label %26
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i32, i32* @SHUT_WR
%16 = call i32 @shutdown(i32 %14, i32 %15)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
store i32 %18, i32* %3
br label %26
19: ; preds = %2
%20 = load i32, i32* %4
%21 = load i32, i32* @SHUT_RDWR
%22 = call i32 @shutdown(i32 %20, i32 %21)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %26
25: ; preds = %2
store i32 0, i32* %3
br label %26
26: ; preds = %25, %19, %13, %7
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@SHUT_RD = global i32 0
@SHUT_WR = global i32 0
@SHUT_RDWR = global i32 0
@switch.table.ss_shutdown_ = [3 x i32*] [i32* @SHUT_RD, i32* @SHUT_WR, i32* @SHUT_RDWR]
define i32 @ss_shutdown_(i32 %0, i32 %1) {
%3 = icmp ult i32 %1, 3
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds [3 x i32*], [3 x i32*]* @switch.table.ss_shutdown_, i64 0, i64 %5
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
%9 = tail call i32 @shutdown(i32 %0, i32 %8)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %2, %4
%13 = phi i32 [ 0, %2 ], [ %11, %4 ]
ret i32 %13
}