#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;
};
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ sendline;
typedef int /*<<< orphan*/ host;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ printf(char *, ...);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int strtol(char *, char **, int);
int main(int argc, char **argv) {
  int sockfd, n;
  struct sockaddr_in servaddr, cliaddr;
  char sendline[1000];
  char recvline[1000];
  char host[200];
  char *p, *arg, *errptr;
  int port;
  if (argc < 3) {
    printf("UNOMP pool block notify\n usage: <host:port> <coin> <block>\n");
    exit(1);
  }
  strncpy(host, argv[1], (sizeof(host) - 1));
  p = host;
  if ((arg = strchr(p, ':'))) {
    *arg = '\0';
    errno = 0;
    port = strtol(++arg, &errptr, 10);
    if ((errno != 0) || (errptr == arg)) {
      fprintf(stderr, "port number fail [%s]\n", errptr);
    }
  }
  snprintf(sendline, sizeof(sendline) - 1,
           "{\"command\":\"blocknotify\",\"params\":[\"%s\",\"%s\"]}\n",
           argv[2], argv[3]);
  sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = inet_addr(host);
  servaddr.sin_port = htons(port);
  connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
  int result = send(sockfd, sendline, strlen(sendline), 0);
  close(sockfd);
  if (result == -1) {
    printf("Error sending: %i\n", errno);
    exit(-1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x910,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    122b <main+0x3b>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x8e0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0xc7,%edx
call   1030 <strncpy@plt>
lea    -0x8e0(%rbp),%rax
mov    %rax,-0x8e8(%rbp)
mov    -0x8e8(%rbp),%rdi
mov    $0x3a,%esi
call   1070 <strchr@plt>
mov    %rax,-0x8f0(%rbp)
cmp    $0x0,%rax
je     12fb <main+0x10b>
mov    -0x8f0(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2d3b(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8f0(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x8f0(%rbp)
lea    -0x8f8(%rbp),%rsi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %eax,-0x8fc(%rbp)
mov    0x2d04(%rip),%rax
cmpq   $0x0,(%rax)
jne    12da <main+0xea>
mov    -0x8f8(%rbp),%rax
cmp    -0x8f0(%rbp),%rax
jne    12f6 <main+0x106>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
mov    -0x8f8(%rbp),%rdx
lea    0xd4b(%rip),%rsi
call   10c0 <fprintf@plt>
jmp    12fb <main+0x10b>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%r8
mov    $0x3e7,%esi
lea    0xd35(%rip),%rdx
call   1090 <snprintf@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    -0x8e0(%rbp),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8fc(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x90c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x908(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x90c(%rbp),%edi
mov    -0x908(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x900(%rbp)
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
cmpl   $0xffffffff,-0x900(%rbp)
jne    1404 <main+0x214>
mov    0x2bd7(%rip),%rax
mov    (%rax),%rsi
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4e0,%rsp
cmp    $0x2,%edi
jg     122a <main+0x2a>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xc7,%edx
call   1030 <strncpy@plt>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     12a7 <main+0xa7>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    0x2d5e(%rip),%r15
movq   $0x0,(%r15)
add    $0x1,%rbp
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   10e0 <strtol@plt>
mov    %eax,%r14d
cmpq   $0x0,(%r15)
mov    0x18(%rsp),%rdx
jne    1292 <main+0x92>
cmp    %rbp,%rdx
jne    12a7 <main+0xa7>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xd5e(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x10(%rbx),%rcx
mov    0x18(%rbx),%r8
lea    0xd61(%rip),%rdx
lea    0xf0(%rsp),%r15
mov    %r15,%rdi
mov    $0x3e7,%esi
call   10a0 <snprintf@plt>
mov    0x2d16(%rip),%rbx
mov    (%rbx),%edi
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    0x2cfc(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%r12
mov    %r12,%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
lea    0x20(%rsp),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   10b0 <close@plt>
cmp    $0xffffffff,%ebx
jne    1374 <main+0x174>
mov    0x2c67(%rip),%rax
mov    (%rax),%rsi
lea    0xce4(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [60 x i8] c"UNOMP pool block notify\0A usage: <host:port> <coin> <block>\0A\00"
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"port number fail [%s]\0A\00"
@.str.2 = [48 x i8] c"{\22command\22:\22blocknotify\22,\22params\22:[\22%s\22,\22%s\22]}\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [19 x i8] c"Error sending: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca [1000 x i8]
%11 = alloca [1000 x i8]
%12 = alloca [200 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %12, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strncpy(i8* %24, i8* %27, i32 199)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %12, i64 0, i64 0
store i8* %29, i8** %13
%30 = load i8*, i8** %13
%31 = call i8* @strchr(i8* %30, i8 signext 58)
store i8* %31, i8** %14
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %49
33: ; preds = %23
%34 = load i8*, i8** %14
store i8 0, i8* %34
store i64 0, i64* @errno
%35 = load i8*, i8** %14
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %14
%37 = call i32 @strtol(i8* %36, i8** %15, i32 10)
store i32 %37, i32* %16
%38 = load i64, i64* @errno
%39 = icmp ne i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %33
%41 = load i8*, i8** %15
%42 = load i8*, i8** %14
%43 = icmp eq i8* %41, %42
br i1 %43, label %44, label %48
44: ; preds = %40, %33
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %15
%47 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %44, %40
br label %49
49: ; preds = %48, %23
%50 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call i32 @snprintf(i8* %50, i32 999, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* %56)
%58 = load i32, i32* @AF_INET
%59 = load i32, i32* @SOCK_STREAM
%60 = load i32, i32* @IPPROTO_TCP
%61 = call i32 @socket(i32 %58, i32 %59, i32 %60)
store i32 %61, i32* %6
%62 = call i32 @bzero(%struct.sockaddr_in* %8, i32 12)
%63 = load i32, i32* @AF_INET
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %63, i32* %64
%65 = getelementptr inbounds [200 x i8], [200 x i8]* %12, i64 0, i64 0
%66 = call i32 @inet_addr(i8* %65)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%68 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %67, i32 0, i32 0
store i32 %66, i32* %68
%69 = load i32, i32* %16
%70 = call i32 @htons(i32 %69)
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %70, i32* %71
%72 = load i32, i32* %6
%73 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%74 = call i32 @connect(i32 %72, %struct.sockaddr* %73, i32 12)
%75 = load i32, i32* %6
%76 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%77 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%78 = call i32 @strlen(i8* %77)
%79 = call i32 @send(i32 %75, i8* %76, i32 %78, i32 0)
store i32 %79, i32* %17
%80 = load i32, i32* %6
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %17
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %88
84: ; preds = %49
%85 = load i64, i64* @errno
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %85)
%87 = call i32 @exit(i32 -1)
unreachable
88: ; preds = %49
%89 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@errno = global i64 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"port number fail [%s]\0A\00"
@.str.2 = [48 x i8] c"{\22command\22:\22blocknotify\22,\22params\22:[\22%s\22,\22%s\22]}\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [19 x i8] c"Error sending: %i\0A\00"
@str = [59 x i8] c"UNOMP pool block notify\0A usage: <host:port> <coin> <block>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [1000 x i8]
%5 = alloca [200 x i8]
%6 = alloca i8*
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%10 = bitcast i8** %6 to i8*
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strncpy(i8* %9, i8* %17, i32 199)
%19 = call i8* @strchr(i8* %9, i8 signext 58)
%20 = icmp eq i8* %19, null
br i1 %20, label %32, label %21
21: ; preds = %15
store i8 0, i8* %19
store i64 0, i64* @errno
%22 = getelementptr inbounds i8, i8* %19, i64 1
%23 = call i32 @strtol(i8* %22, i8** %6, i32 10)
%24 = load i64, i64* @errno
%25 = icmp ne i64 %24, 0
%26 = load i8*, i8** %6
%27 = icmp eq i8* %26, %22
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %32
32: ; preds = %21, %29, %15
%33 = phi i32 [ %23, %29 ], [ undef, %15 ], [ %23, %21 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8*, i8** %1, i64 3
%37 = load i8*, i8** %36
%38 = call i32 @snprintf(i8* %8, i32 999, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %37)
%39 = load i32, i32* @AF_INET
%40 = load i32, i32* @SOCK_STREAM
%41 = load i32, i32* @IPPROTO_TCP
%42 = call i32 @socket(i32 %39, i32 %40, i32 %41)
%43 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%44 = load i32, i32* @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %44, i32* %45
%46 = call i32 @inet_addr(i8* %9)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %46, i32* %47
%48 = call i32 @htons(i32 %33)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %48, i32* %49
%50 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%51 = call i32 @connect(i32 %42, %struct.sockaddr* %50, i32 12)
%52 = call i32 @strlen(i8* %8)
%53 = call i32 @send(i32 %42, i8* %8, i32 %52, i32 0)
%54 = call i32 @close(i32 %42)
%55 = icmp eq i32 %53, -1
br i1 %55, label %56, label %60
56: ; preds = %32
%57 = load i64, i64* @errno
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %57)
%59 = call i32 @exit(i32 -1)
unreachable
60: ; preds = %32
%61 = call i32 @exit(i32 0)
unreachable
}