#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ ReverseFloat(float);
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ _error(char *);
int atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int main(int argc, char *argv[]) {
  struct sharknado {
    int a;
    char b;
    float c;
  };
  struct sharknado s = {0x0f000000, 'a', ReverseFloat(2.0f)};
  int sockfd, portno, n;
  struct sockaddr_in serv_addr;
  struct hostent *server;
  char buffer[256];
  if (argc < 3) {
    fprintf(stderr, "usage %s hostname port\n", argv[0]);
    exit(0);
  }
  portno = atoi(argv[2]);
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    _error("ERROR opening socket");
  server = gethostbyname(argv[1]);
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host\n");
    exit(0);
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr,
        server->h_length);
  serv_addr.sin_port = htons(portno);
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    _error("ERROR connecting");
  n = write(sockfd, (char *)&s, sizeof(s));
  if (n < 0)
    _error("ERROR writing to socket");
  bzero(buffer, 256);
  n = read(sockfd, buffer, 255);
  if (n < 0)
    _error("ERROR reading from socket");
  printf("%s\n", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf000000,-0x20(%rbp)
movb   $0x61,-0x1c(%rbp)
movss  0xdf4(%rip),%xmm0
call   10a0 <ReverseFloat@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1249 <main+0x69>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    128b <main+0xab>
lea    0xd96(%rip),%rdi
call   1090 <_error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12c5 <main+0xe5>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x38(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x38(%rbp),%rsi
add    $0x4,%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   10b0 <bcopy@plt>
mov    -0x28(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    132c <main+0x14c>
lea    0xd1f(%rip),%rdi
call   1090 <_error@plt>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1356 <main+0x176>
lea    0xd06(%rip),%rdi
call   1090 <_error@plt>
lea    -0x140(%rbp),%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    -0x24(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0xff,%edx
call   1060 <read@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1394 <main+0x1b4>
lea    0xce0(%rip),%rdi
call   1090 <_error@plt>
lea    -0x140(%rbp),%rsi
lea    0xce7(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
movl   $0xf000000,0x10(%rsp)
0f
movb   $0x61,0x14(%rsp)
movss  0xdf7(%rip),%xmm0
call   10a0 <ReverseFloat@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x18(%rsp)
cmp    $0x2,%ebx
jle    133b <main+0x15b>
mov    0x10(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x2db1(%rip),%r12
mov    (%r12),%edi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    125d <main+0x7d>
lea    0xdc4(%rip),%rdi
call   1090 <_error@plt>
mov    0x8(%rbp),%rdi
call   1070 <gethostbyname@plt>
test   %rax,%rax
je     135d <main+0x17d>
mov    %rax,%rbp
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbp),%rsi
lea    0x4(%rsp),%rdi
mov    0x0(%rbp),%edx
call   10b0 <memmove@plt>
mov    %r14d,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
jns    12c6 <main+0xe6>
lea    0xd85(%rip),%rdi
call   1090 <_error@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   1030 <write@plt>
test   %eax,%eax
jns    12e7 <main+0x107>
lea    0xd75(%rip),%rdi
call   1090 <_error@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
call   1060 <read@plt>
test   %eax,%eax
jns    1318 <main+0x138>
lea    0xd5c(%rip),%rdi
call   1090 <_error@plt>
lea    0xd6a(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xcb5(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xcc4(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sharknado = type { i32, i8, float }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"usage %s hostname port\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [24 x i8] c"ERROR writing to socket\00"
@.str.5 = [26 x i8] c"ERROR reading from socket\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sharknado
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %6, i32 0, i32 0
store i32 251658240, i32* %13
%14 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %6, i32 0, i32 1
store i8 97, i8* %14
%15 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %6, i32 0, i32 2
%16 = call i32 @ReverseFloat(float 2.000000e+00)
%17 = sitofp i32 %16 to float
store float %17, float* %15
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %8
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = call i32 @_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %27
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call %struct.hostent* @gethostbyname(i8* %42)
store %struct.hostent* %43, %struct.hostent** %11
%44 = load %struct.hostent*, %struct.hostent** %11
%45 = icmp eq %struct.hostent* %44, null
br i1 %45, label %46, label %50
46: ; preds = %39
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 0)
unreachable
50: ; preds = %39
%51 = bitcast %struct.sockaddr_in* %10 to i8*
%52 = call i32 @bzero(i8* %51, i32 12)
%53 = load i32, i32* @AF_INET
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %53, i32* %54
%55 = load %struct.hostent*, %struct.hostent** %11
%56 = getelementptr inbounds %struct.hostent, %struct.hostent* %55, i32 0, i32 1
%57 = load i64, i64* %56
%58 = inttoptr i64 %57 to i8*
%59 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%60 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %59, i32 0, i32 0
%61 = bitcast i32* %60 to i8*
%62 = load %struct.hostent*, %struct.hostent** %11
%63 = getelementptr inbounds %struct.hostent, %struct.hostent* %62, i32 0, i32 0
%64 = load i32, i32* %63
%65 = call i32 @bcopy(i8* %58, i8* %61, i32 %64)
%66 = load i32, i32* %8
%67 = call i32 @htons(i32 %66)
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i32 %67, i32* %68
%69 = load i32, i32* %7
%70 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%71 = call i64 @connect(i32 %69, %struct.sockaddr* %70, i32 12)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %50
%74 = call i32 @_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %75
75: ; preds = %73, %50
%76 = load i32, i32* %7
%77 = bitcast %struct.sharknado* %6 to i8*
%78 = call i32 @write(i32 %76, i8* %77, i32 12)
store i32 %78, i32* %9
%79 = load i32, i32* %9
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %75
%82 = call i32 @_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %83
83: ; preds = %81, %75
%84 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%85 = call i32 @bzero(i8* %84, i32 256)
%86 = load i32, i32* %7
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%88 = call i32 @read(i32 %86, i8* %87, i32 255)
store i32 %88, i32* %9
%89 = load i32, i32* %9
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %83
%92 = call i32 @_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %93
93: ; preds = %91, %83
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%95 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %94)
ret i32 0
}

LLVM IR (-O2):
%struct.sharknado = type { i32, i8, float }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"usage %s hostname port\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [24 x i8] c"ERROR writing to socket\00"
@.str.5 = [26 x i8] c"ERROR reading from socket\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sharknado
%4 = alloca %struct.sockaddr_in
%5 = alloca [256 x i8]
%6 = bitcast %struct.sharknado* %3 to i8*
%7 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %3, i64 0, i32 0
store i32 251658240, i32* %7
%8 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %3, i64 0, i32 1
store i8 97, i8* %8
%9 = getelementptr inbounds %struct.sharknado, %struct.sharknado* %3, i64 0, i32 2
%10 = tail call i32 @ReverseFloat(float 2.000000e+00)
%11 = sitofp i32 %10 to float
store float %11, float* %9
%12 = bitcast %struct.sockaddr_in* %4 to i8*
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%14 = icmp slt i32 %0, 3
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = tail call i32 @socket(i32 %24, i32 %25, i32 0)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = tail call i32 @_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %20
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = tail call %struct.hostent* @gethostbyname(i8* %32)
%34 = icmp eq %struct.hostent* %33, null
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%38 = tail call i32 @exit(i32 0)
unreachable
39: ; preds = %30
%40 = call i32 @bzero(i8* %12, i32 12)
%41 = load i32, i32* @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %41, i32* %42
%43 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i64 0, i32 1
%44 = load i64, i64* %43
%45 = inttoptr i64 %44 to i8*
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%47 = bitcast i32* %46 to i8*
%48 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i64 0, i32 0
%49 = load i32, i32* %48
%50 = tail call i32 @htons(i32 %23)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %50, i32* %51
%52 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%53 = call i64 @connect(i32 %26, %struct.sockaddr* %52, i32 12)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %39
%56 = call i32 @_error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %39
%58 = call i32 @write(i32 %26, i8* %6, i32 12)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 @_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
%63 = call i32 @bzero(i8* %13, i32 256)
%64 = call i32 @read(i32 %26, i8* %13, i32 255)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 @_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %62
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %13)
ret i32 0
}