#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*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ itc_net_setsockopt_n_invalid_opt_name(int);
int /*<<< orphan*/ itc_net_setsockopt_p_ip_ttl(int);
int /*<<< orphan*/ itc_net_setsockopt_p_multicast_ttl_loop(int);
int /*<<< orphan*/ itc_net_setsockopt_p_multicast_ttl_loop_own(int);
int /*<<< orphan*/ itc_net_setsockopt_p_no_check(int);
int /*<<< orphan*/ itc_net_setsockopt_p_rcvbuf(int);
int /*<<< orphan*/ itc_net_setsockopt_p_rcvtimo(int);
int /*<<< orphan*/ itc_net_setsockopt_p_reuseaddr(int);
int /*<<< orphan*/ itc_net_setsockopt_p_sndtimo(int);
int /*<<< orphan*/ printf(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int itc_net_setsockopt_main(void) {
  int fd = -1;
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd < 0) {
    printf("socket creation failed\n");
    return 0;
  }
  itc_net_setsockopt_n_invalid_opt_name(fd);
  itc_net_setsockopt_p_rcvbuf(fd);
  itc_net_setsockopt_p_reuseaddr(fd);
  itc_net_setsockopt_p_rcvtimo(fd);
  itc_net_setsockopt_p_sndtimo(fd);
  itc_net_setsockopt_p_ip_ttl(fd);
  close(fd);
  fd = -1;
  fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (fd < 0) {
    printf("socket creation failed\n");
    return 0;
  }
  itc_net_setsockopt_p_no_check(fd);
  itc_net_setsockopt_p_multicast_ttl_loop(fd);
  itc_net_setsockopt_p_multicast_ttl_loop_own(fd);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<itc_net_setsockopt_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x8(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    120d <itc_net_setsockopt_main+0x4d>
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b1 <itc_net_setsockopt_main+0xf1>
mov    -0x8(%rbp),%edi
call   1090 <itc_net_setsockopt_n_invalid_opt_name@plt>
mov    -0x8(%rbp),%edi
call   1030 <itc_net_setsockopt_p_rcvbuf@plt>
mov    -0x8(%rbp),%edi
call   1060 <itc_net_setsockopt_p_reuseaddr@plt>
mov    -0x8(%rbp),%edi
call   10a0 <itc_net_setsockopt_p_rcvtimo@plt>
mov    -0x8(%rbp),%edi
call   10b0 <itc_net_setsockopt_p_sndtimo@plt>
mov    -0x8(%rbp),%edi
call   1040 <itc_net_setsockopt_p_ip_ttl@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    128a <itc_net_setsockopt_main+0xca>
lea    0xd87(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b1 <itc_net_setsockopt_main+0xf1>
mov    -0x8(%rbp),%edi
call   1080 <itc_net_setsockopt_p_no_check@plt>
mov    -0x8(%rbp),%edi
call   10c0 <itc_net_setsockopt_p_multicast_ttl_loop@plt>
mov    -0x8(%rbp),%edi
call   10d0 <itc_net_setsockopt_p_multicast_ttl_loop_own@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itc_net_setsockopt_main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e1d(%rip),%r14
mov    (%r14),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     124c <itc_net_setsockopt_main+0x8c>
mov    %eax,%ebx
mov    %eax,%edi
call   1090 <itc_net_setsockopt_n_invalid_opt_name@plt>
mov    %ebx,%edi
call   1030 <itc_net_setsockopt_p_rcvbuf@plt>
mov    %ebx,%edi
call   1060 <itc_net_setsockopt_p_reuseaddr@plt>
mov    %ebx,%edi
call   10a0 <itc_net_setsockopt_p_rcvtimo@plt>
mov    %ebx,%edi
call   10b0 <itc_net_setsockopt_p_sndtimo@plt>
mov    %ebx,%edi
call   1040 <itc_net_setsockopt_p_ip_ttl@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    (%r14),%edi
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     124c <itc_net_setsockopt_main+0x8c>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <itc_net_setsockopt_p_no_check@plt>
mov    %ebx,%edi
call   10c0 <itc_net_setsockopt_p_multicast_ttl_loop@plt>
mov    %ebx,%edi
call   10d0 <itc_net_setsockopt_p_multicast_ttl_loop_own@plt>
mov    %ebx,%edi
call   1070 <close@plt>
jmp    1258 <itc_net_setsockopt_main+0x98>
lea    0xdad(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [24 x i8] c"socket creation failed\0A\00"
@SOCK_DGRAM = global i32 0
define i32 @itc_net_setsockopt_main() {
%1 = alloca i32
%2 = alloca i32
store i32 -1, i32* %2
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %41
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 @itc_net_setsockopt_n_invalid_opt_name(i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @itc_net_setsockopt_p_rcvbuf(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @itc_net_setsockopt_p_reuseaddr(i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @itc_net_setsockopt_p_rcvtimo(i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @itc_net_setsockopt_p_sndtimo(i32 %19)
%21 = load i32, i32* %2
%22 = call i32 @itc_net_setsockopt_p_ip_ttl(i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @close(i32 %23)
store i32 -1, i32* %2
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %10
%31 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %41
32: ; preds = %10
%33 = load i32, i32* %2
%34 = call i32 @itc_net_setsockopt_p_no_check(i32 %33)
%35 = load i32, i32* %2
%36 = call i32 @itc_net_setsockopt_p_multicast_ttl_loop(i32 %35)
%37 = load i32, i32* %2
%38 = call i32 @itc_net_setsockopt_p_multicast_ttl_loop_own(i32 %37)
%39 = load i32, i32* %2
%40 = call i32 @close(i32 %39)
store i32 0, i32* %1
br label %41
41: ; preds = %32, %30, %8
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@str.1 = [23 x i8] c"socket creation failed\00"
define i32 @itc_net_setsockopt_main() {
%1 = load i32, i32* @AF_INET
%2 = load i32, i32* @SOCK_STREAM
%3 = tail call i32 @socket(i32 %1, i32 %2, i32 0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.1, i64 0, i64 0))
br label %26
7: ; preds = %0
%8 = tail call i32 @itc_net_setsockopt_n_invalid_opt_name(i32 %3)
%9 = tail call i32 @itc_net_setsockopt_p_rcvbuf(i32 %3)
%10 = tail call i32 @itc_net_setsockopt_p_reuseaddr(i32 %3)
%11 = tail call i32 @itc_net_setsockopt_p_rcvtimo(i32 %3)
%12 = tail call i32 @itc_net_setsockopt_p_sndtimo(i32 %3)
%13 = tail call i32 @itc_net_setsockopt_p_ip_ttl(i32 %3)
%14 = tail call i32 @close(i32 %3)
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_DGRAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.1, i64 0, i64 0))
br label %26
21: ; preds = %7
%22 = tail call i32 @itc_net_setsockopt_p_no_check(i32 %17)
%23 = tail call i32 @itc_net_setsockopt_p_multicast_ttl_loop(i32 %17)
%24 = tail call i32 @itc_net_setsockopt_p_multicast_ttl_loop_own(i32 %17)
%25 = tail call i32 @close(i32 %17)
br label %26
26: ; preds = %21, %19, %5
ret i32 0
}