#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 errno;
int gettid();
int /*<<< orphan*/ printf(char *, int, ...);
int shutdown(int, int);
char *strerror(int);
int _shutdown(int fd, int how) {
  int ret;
  printf("%d: shutdown(%d)\n", gettid(), fd);
  ret = shutdown(fd, how);
  printf("%d: shutdown(%d) = %d\n", gettid(), fd, ret);
  if (ret < 0)
    printf("\terr %d (%s)\n", errno, strerror(errno));
  return ret;
}


x86 assembly (clang, -O0):
<_shutdown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <gettid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <shutdown@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <gettid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    11cb <_shutdown+0x8b>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rdx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_shutdown>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <gettid@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <shutdown@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <gettid@plt>
lea    0xe99(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jns    11ad <_shutdown+0x6d>
mov    0x2e4f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1060 <strerror@plt>
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%d: shutdown(%d)\0A\00"
@.str.1 = [23 x i8] c"%d: shutdown(%d) = %d\0A\00"
@.str.2 = [14 x i8] c"\09err %d (%s)\0A\00"
@errno = global i32 0
define i32 @_shutdown(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 (...) @gettid()
%7 = load i32, i32* %3
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @shutdown(i32 %9, i32 %10)
store i32 %11, i32* %5
%12 = call i32 (...) @gettid()
%13 = load i32, i32* %3
%14 = load i32, i32* %5
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @errno
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* %21)
br label %23
23: ; preds = %18, %2
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@.str = [18 x i8] c"%d: shutdown(%d)\0A\00"
@.str.1 = [23 x i8] c"%d: shutdown(%d) = %d\0A\00"
@.str.2 = [14 x i8] c"\09err %d (%s)\0A\00"
@errno = global i32 0
define i32 @_shutdown(i32 %0, i32 %1) {
%3 = tail call i32 (...) @gettid()
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %0)
%5 = tail call i32 @shutdown(i32 %0, i32 %1)
%6 = tail call i32 (...) @gettid()
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %0, i32 %5)
%8 = icmp slt i32 %5, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @errno
%11 = tail call i8* @strerror(i32 %10)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %10, i8* %11)
br label %13
13: ; preds = %9, %2
ret i32 %5
}