#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*/ close(int);
int /*<<< orphan*/ mydown_donothing();
void mydown_free_sock(char *ssl_sd, char *ctx_sd, int *sock) {
  if (sock && *sock) {
    if (ssl_sd) {
      mydown_donothing();
      mydown_donothing();
    }
    if (ctx_sd)
      mydown_donothing();
    close(*sock);
    *sock = 0;
  }
}


x86 assembly (clang, -O0):
<mydown_free_sock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118c <mydown_free_sock+0x6c>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     118c <mydown_free_sock+0x6c>
cmpq   $0x0,-0x8(%rbp)
je     1165 <mydown_free_sock+0x45>
mov    $0x0,%al
call   1040 <mydown_donothing@plt>
mov    $0x0,%al
call   1040 <mydown_donothing@plt>
cmpq   $0x0,-0x10(%rbp)
je     1177 <mydown_free_sock+0x57>
mov    $0x0,%al
call   1040 <mydown_donothing@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <close@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mydown_free_sock>:
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
je     1160 <mydown_free_sock+0x40>
mov    %rdx,%rbx
cmpl   $0x0,(%rdx)
je     1160 <mydown_free_sock+0x40>
mov    %rsi,%r14
test   %rdi,%rdi
je     1147 <mydown_free_sock+0x27>
xor    %eax,%eax
call   1040 <mydown_donothing@plt>
xor    %eax,%eax
call   1040 <mydown_donothing@plt>
test   %r14,%r14
je     1153 <mydown_free_sock+0x33>
xor    %eax,%eax
call   1040 <mydown_donothing@plt>
mov    (%rbx),%edi
call   1030 <close@plt>
movl   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mydown_free_sock(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %6
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %29
9: ; preds = %3
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 (...) @mydown_donothing()
%18 = call i32 (...) @mydown_donothing()
br label %19
19: ; preds = %16, %13
%20 = load i8*, i8** %5
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @mydown_donothing()
br label %24
24: ; preds = %22, %19
%25 = load i32*, i32** %6
%26 = load i32, i32* %25
%27 = call i32 @close(i32 %26)
%28 = load i32*, i32** %6
store i32 0, i32* %28
br label %29
29: ; preds = %24, %9, %3
ret void
}

LLVM IR (-O2):
define void @mydown_free_sock(i8* readnone %0, i8* readnone %1, i32* %2) {
%4 = icmp eq i32* %2, null
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5
%9 = icmp eq i8* %0, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 (...) @mydown_donothing()
%12 = tail call i32 (...) @mydown_donothing()
br label %13
13: ; preds = %10, %8
%14 = icmp eq i8* %1, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 (...) @mydown_donothing()
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %2
%19 = tail call i32 @close(i32 %18)
store i32 0, i32* %2
br label %20
20: ; preds = %17, %5, %3
ret void
}