#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*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ darwin_convert_sockopt_option(int *, int *);
int setsockopt(int, int, int, void const *, int /*<<< orphan*/);
int darwin_my_setsockopt(int sockfd, int level, int optname, const void *optval,
                         socklen_t optlen) {
  if (!darwin_convert_sockopt_option(&level, &optname))
    return 0;
  return setsockopt(sockfd, level, optname, optval, optlen);
}


x86 assembly (clang, -O0):
<darwin_my_setsockopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <darwin_convert_sockopt_option@plt>
cmp    $0x0,%eax
jne    115b <darwin_my_setsockopt+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1174 <darwin_my_setsockopt+0x54>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <setsockopt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<darwin_my_setsockopt>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %edi,%ebp
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <darwin_convert_sockopt_option@plt>
test   %eax,%eax
je     1162 <darwin_my_setsockopt+0x42>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %ebp,%edi
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1040 <setsockopt@plt>
jmp    1164 <darwin_my_setsockopt+0x44>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @darwin_my_setsockopt(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%12 = call i32 @darwin_convert_sockopt_option(i32* %8, i32* %9)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %5
store i32 0, i32* %6
br label %22
15: ; preds = %5
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = load i8*, i8** %10
%20 = load i32, i32* %11
%21 = call i32 @setsockopt(i32 %16, i32 %17, i32 %18, i8* %19, i32 %20)
store i32 %21, i32* %6
br label %22
22: ; preds = %15, %14
%23 = load i32, i32* %6
ret i32 %23
}

LLVM IR (-O2):
define i32 @darwin_my_setsockopt(i32 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = call i32 @darwin_convert_sockopt_option(i32* %6, i32* %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @setsockopt(i32 %0, i32 %11, i32 %12, i8* %3, i32 %4)
br label %14
14: ; preds = %5, %10
%15 = phi i32 [ %13, %10 ], [ 0, %5 ]
ret i32 %15
}