#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 */
#define SHUT_RD 130
#define SHUT_RDWR 129
#define SHUT_WR 128
int /*<<< orphan*/ _arakoon_log_debug(char *, int, char *, int,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int shutdown(int, int);
int _arakoon_networking_shutdown_wrapper(int sockfd, int how) {
  int rc = 0;
  char *s = NULL;
  switch (how) {
  case SHUT_RD:
    s = "SHUT_RD";
    break;
  case SHUT_WR:
    s = "SHUT_WR";
    break;
  case SHUT_RDWR:
    s = "SHUT_RDWR";
    break;
  default:
    s = "(invalid)";
    break;
  }
  rc = shutdown(sockfd, how);
  _arakoon_log_debug("arakoon-networking: shutdown(%d, %s) = %d, errno = %d",
                     sockfd, s, rc, errno);
  return rc;
}


x86 assembly (clang, -O0):
<_arakoon_networking_shutdown_wrapper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     1189 <_arakoon_networking_shutdown_wrapper+0x69>
jmp    1153 <_arakoon_networking_shutdown_wrapper+0x33>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
je     1199 <_arakoon_networking_shutdown_wrapper+0x79>
jmp    1166 <_arakoon_networking_shutdown_wrapper+0x46>
mov    -0x1c(%rbp),%eax
sub    $0x82,%eax
jne    11a9 <_arakoon_networking_shutdown_wrapper+0x89>
jmp    1179 <_arakoon_networking_shutdown_wrapper+0x59>
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b4 <_arakoon_networking_shutdown_wrapper+0x94>
lea    0xe78(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b4 <_arakoon_networking_shutdown_wrapper+0x94>
lea    0xe70(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b4 <_arakoon_networking_shutdown_wrapper+0x94>
lea    0xe6a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <shutdown@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    0x2e0d(%rip),%rax
mov    (%rax),%r8d
lea    0xe47(%rip),%rdi
call   1030 <_arakoon_log_debug@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_arakoon_networking_shutdown_wrapper>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
lea    -0x80(%rsi),%eax
cmp    $0x2,%eax
ja     1141 <_arakoon_networking_shutdown_wrapper+0x21>
cltq
lea    0xf24(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1148 <_arakoon_networking_shutdown_wrapper+0x28>
lea    0xed2(%rip),%rbx
mov    %r14d,%edi
call   1040 <shutdown@plt>
mov    %eax,%ebp
mov    0x2e87(%rip),%rax
mov    (%rax),%r8d
lea    0xec1(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1030 <_arakoon_log_debug@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"SHUT_RD\00"
@.str.1 = [8 x i8] c"SHUT_WR\00"
@.str.2 = [10 x i8] c"SHUT_RDWR\00"
@.str.3 = [10 x i8] c"(invalid)\00"
@.str.4 = [54 x i8] c"arakoon-networking: shutdown(%d, %s) = %d, errno = %d\00"
@errno = global i32 0
define i32 @_arakoon_networking_shutdown_wrapper(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i8* null, i8** %6
%7 = load i32, i32* %4
switch i32 %7, label %11 [
i32 130, label %8
i32 128, label %9
i32 129, label %10
]
8: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %6
br label %12
9: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %12
10: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %12
11: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %12
12: ; preds = %11, %10, %9, %8
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @shutdown(i32 %13, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = load i8*, i8** %6
%18 = load i32, i32* %5
%19 = load i32, i32* @errno
%20 = call i32 @_arakoon_log_debug(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %16, i8* %17, i32 %18, i32 %19)
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@.str = [8 x i8] c"SHUT_RD\00"
@.str.1 = [8 x i8] c"SHUT_WR\00"
@.str.2 = [10 x i8] c"SHUT_RDWR\00"
@.str.3 = [10 x i8] c"(invalid)\00"
@.str.4 = [54 x i8] c"arakoon-networking: shutdown(%d, %s) = %d, errno = %d\00"
@errno = global i32 0
@reltable._arakoon_networking_shutdown_wrapper = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable._arakoon_networking_shutdown_wrapper to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable._arakoon_networking_shutdown_wrapper to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable._arakoon_networking_shutdown_wrapper to i64)) to i32)]
define i32 @_arakoon_networking_shutdown_wrapper(i32 %0, i32 %1) {
%3 = add i32 %1, -128
%4 = icmp ult i32 %3, 3
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable._arakoon_networking_shutdown_wrapper to i8*), i64 %7)
br label %9
9: ; preds = %2, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %2 ]
%11 = tail call i32 @shutdown(i32 %0, i32 %1)
%12 = load i32, i32* @errno
%13 = tail call i32 @_arakoon_log_debug(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %0, i8* %10, i32 %11, i32 %12)
ret i32 %11
}