#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 socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ client_addr;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ addr_buff;
typedef int /*<<< orphan*/ RSA;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ ERR_free_strings();
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ EVP_cleanup();
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ NID_sha1;
int /*<<< orphan*/ OpenSSL_add_all_ciphers();
int /*<<< orphan*/ *PEM_read_RSAPublicKey(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ RSA_free(int /*<<< orphan*/ *);
unsigned int RSA_size(int /*<<< orphan*/ *);
int RSA_verify(int /*<<< orphan*/, unsigned char *, unsigned int,
               unsigned char *, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwrite(char *, int, unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
char *inet_ntop(int /*<<< orphan*/, TYPE_1__ *, char *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int sockfd;
  int retval;
  struct sockaddr_in client_addr, server_addr;
  socklen_t client_addr_len, server_addr_len;
  char buff[256];
  unsigned int buff_len, message_len, sig_len;
  char addr_buff[256];
  FILE *file;
  RSA *public_key;
  if (argc != 2) {
    fprintf(stderr, "Invocation: %s <PORT>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  file = fopen("public.key", "r");
  if (file == NULL) {
    perror("fopen()");
    exit(EXIT_FAILURE);
  }
  sockfd = socket(PF_INET, SOCK_DGRAM, 0);
  if (sockfd == -1) {
    perror("socket()");
    exit(EXIT_FAILURE);
  }
  memset(&server_addr, 0, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  server_addr.sin_port = htons(atoi(argv[1]));
  server_addr_len = sizeof(server_addr);
  if (bind(sockfd, (struct sockaddr *)&server_addr, server_addr_len) == -1) {
    perror("bind()");
    exit(EXIT_FAILURE);
  }
  fprintf(stdout, "Server is waiting for UDP datagram...\n");
  client_addr_len = sizeof(client_addr);
  retval = recvfrom(sockfd, buff, sizeof(buff), 0,
                    (struct sockaddr *)&client_addr, &client_addr_len);
  if (retval == -1) {
    perror("recvfrom()");
    exit(EXIT_FAILURE);
  }
  buff_len = retval;
  fprintf(
      stdout, "UDP datagram received from %s:%d.\n",
      inet_ntop(AF_INET, &client_addr.sin_addr, addr_buff, sizeof(addr_buff)),
      ntohs(client_addr.sin_port));
  fprintf(stdout, "Signature verification...\n");
  ERR_load_crypto_strings();
  OpenSSL_add_all_ciphers();
  public_key = PEM_read_RSAPublicKey(file, NULL, NULL, NULL);
  if (!public_key) {
    ERR_print_errors_fp(stderr);
    exit(EXIT_FAILURE);
  }
  fclose(file);
  sig_len = RSA_size(public_key);
  message_len = buff_len - sig_len;
  retval = RSA_verify(NID_sha1, (unsigned char *)buff, message_len,
                      (unsigned char *)buff + message_len, sig_len, public_key);
  if (retval == 0) {
    ERR_print_errors_fp(stderr);
    exit(EXIT_FAILURE);
  } else {
    fprintf(stdout, "Signature is valid.\n");
  }
  RSA_free(public_key);
  EVP_cleanup();
  ERR_free_strings();
  fprintf(stdout, "Message: ");
  fwrite(buff, sizeof(char), message_len, stdout);
  fprintf(stdout, "\n");
  close(sockfd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     12df <main+0x4f>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    0xd31(%rip),%rdi
lea    0xd35(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x258(%rbp)
cmpq   $0x0,-0x258(%rbp)
jne    1321 <main+0x91>
lea    0xd16(%rip),%rdi
call   1150 <perror@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
mov    0x2ca7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11b0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1361 <main+0xd1>
lea    0xcde(%rip),%rdi
call   1150 <perror@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1160 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x38(%rbp)
movl   $0xc,-0x40(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   1120 <bind@plt>
cmp    $0xffffffff,%eax
jne    13de <main+0x14e>
lea    0xc6a(%rip),%rdi
call   1150 <perror@plt>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xc,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x140(%rbp),%rsi
lea    -0x28(%rbp),%r8
mov    $0x100,%edx
xor    %ecx,%ecx
lea    -0x3c(%rbp),%r9
call   10f0 <recvfrom@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1441 <main+0x1b1>
lea    0xc35(%rip),%rdi
call   1150 <perror@plt>
mov    0x2b76(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x144(%rbp)
mov    0x2b57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x26c(%rbp)
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
lea    -0x250(%rbp),%rdx
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x268(%rbp)
mov    -0x28(%rbp),%edi
call   1110 <ntohs@plt>
mov    -0x26c(%rbp),%edi
mov    -0x268(%rbp),%rdx
mov    %eax,%ecx
lea    0xbce(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2afa(%rip),%rax
mov    (%rax),%edi
lea    0xbda(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1170 <ERR_load_crypto_strings@plt>
mov    $0x0,%al
call   1130 <OpenSSL_add_all_ciphers@plt>
mov    -0x258(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1100 <PEM_read_RSAPublicKey@plt>
mov    %rax,-0x260(%rbp)
cmpq   $0x0,-0x260(%rbp)
jne    1513 <main+0x283>
mov    0x2aca(%rip),%rax
mov    (%rax),%edi
call   11a0 <ERR_print_errors_fp@plt>
mov    0x2aa4(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    -0x258(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x260(%rbp),%rdi
call   1040 <RSA_size@plt>
mov    %eax,-0x14c(%rbp)
mov    -0x144(%rbp),%eax
sub    -0x14c(%rbp),%eax
mov    %eax,-0x148(%rbp)
mov    0x2a6e(%rip),%rax
mov    (%rax),%edi
lea    -0x140(%rbp),%rsi
mov    -0x148(%rbp),%edx
lea    -0x140(%rbp),%rcx
mov    -0x148(%rbp),%eax
add    %rax,%rcx
mov    -0x14c(%rbp),%r8d
mov    -0x260(%rbp),%r9
call   10e0 <RSA_verify@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    15a5 <main+0x315>
mov    0x2a38(%rip),%rax
mov    (%rax),%edi
call   11a0 <ERR_print_errors_fp@plt>
mov    0x2a12(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    0x29fc(%rip),%rax
mov    (%rax),%edi
lea    0xaf7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x260(%rbp),%rdi
call   1070 <RSA_free@plt>
mov    $0x0,%al
call   10c0 <EVP_cleanup@plt>
mov    $0x0,%al
call   10d0 <ERR_free_strings@plt>
mov    0x29cb(%rip),%rax
mov    (%rax),%edi
lea    0xadb(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%edx
mov    0x29a7(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1190 <fwrite@plt>
mov    0x2994(%rip),%rax
mov    (%rax),%edi
lea    0xa44(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    0x296d(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    12cd <main+0x3d>
lea    0xd67(%rip),%rdi
lea    0xd6b(%rip),%rsi
call   1140 <fopen@plt>
test   %rax,%rax
jne    12ed <main+0x5d>
lea    0xd5c(%rip),%rdi
jmp    13cd <main+0x13d>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd1f(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    13d2 <main+0x142>
mov    %rax,%rbx
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11b0 <socket@plt>
cmp    $0xffffffff,%eax
jne    131a <main+0x8a>
lea    0xd17(%rip),%rdi
jmp    13cd <main+0x13d>
mov    %eax,%r15d
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2cb0(%rip),%r13
mov    0x0(%r13),%eax
mov    %eax,0x18(%rsp)
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rbp),%rdi
call   1160 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1120 <bind@plt>
cmp    $0xffffffff,%eax
jne    1384 <main+0xf4>
lea    0xcb3(%rip),%rdi
jmp    13cd <main+0x13d>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movl   $0xc,0xc(%rsp)
lea    0x30(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %r15d,%edi
mov    $0x100,%edx
xor    %ecx,%ecx
call   10f0 <recvfrom@plt>
cmp    $0xffffffff,%eax
jne    13e0 <main+0x150>
lea    0xc96(%rip),%rdi
call   1150 <perror@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>
mov    %eax,%r14d
mov    0x2bbe(%rip),%rax
mov    (%rax),%r12d
mov    0x0(%r13),%edi
lea    0x24(%rsp),%rsi
lea    0x130(%rsp),%rdx
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rbp
mov    0x20(%rsp),%edi
call   1110 <ntohs@plt>
lea    0xc53(%rip),%rsi
mov    %r12d,%edi
mov    0x2b83(%rip),%r12
mov    %rbp,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%r12),%edi
lea    0xc55(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1170 <ERR_load_crypto_strings@plt>
xor    %eax,%eax
call   1130 <OpenSSL_add_all_ciphers@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1100 <PEM_read_RSAPublicKey@plt>
test   %rax,%rax
je     14a2 <main+0x212>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
call   1040 <RSA_size@plt>
sub    %eax,%r14d
mov    0x2b37(%rip),%rcx
mov    (%rcx),%edi
lea    (%rsp,%r14,1),%rcx
add    $0x30,%rcx
lea    0x30(%rsp),%rsi
mov    %r14d,%edx
mov    %eax,%r8d
mov    %rbp,%r9
call   10e0 <RSA_verify@plt>
test   %eax,%eax
jne    14b5 <main+0x225>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
call   11a0 <ERR_print_errors_fp@plt>
jmp    13d2 <main+0x142>
mov    (%r12),%edi
lea    0xbec(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %rbp,%rdi
call   1070 <RSA_free@plt>
xor    %eax,%eax
call   10c0 <EVP_cleanup@plt>
xor    %eax,%eax
call   10d0 <ERR_free_strings@plt>
mov    (%r12),%edi
lea    0xbd9(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%r12),%ecx
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
call   1190 <fwrite@plt>
mov    (%r12),%edi
lea    0xb51(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
mov    0x2a7a(%rip),%rax
mov    (%rax),%edi
call   1180 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Invocation: %s <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"public.key\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [8 x i8] c"fopen()\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [9 x i8] c"socket()\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.5 = [7 x i8] c"bind()\00"
@stdout = global i32 0
@.str.6 = [39 x i8] c"Server is waiting for UDP datagram...\0A\00"
@.str.7 = [11 x i8] c"recvfrom()\00"
@.str.8 = [35 x i8] c"UDP datagram received from %s:%d.\0A\00"
@.str.9 = [27 x i8] c"Signature verification...\0A\00"
@NID_sha1 = global i32 0
@.str.10 = [21 x i8] c"Signature is valid.\0A\00"
@.str.11 = [10 x i8] c"Message: \00"
@.str.12 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
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 i32
%11 = alloca i32
%12 = alloca [256 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [256 x i8]
%17 = alloca i32*
%18 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %17
%31 = load i32*, i32** %17
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %29
%38 = load i32, i32* @PF_INET
%39 = load i32, i32* @SOCK_DGRAM
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %37
%44 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %37
%48 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%49 = load i32, i32* @AF_INET
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %49, i32* %50
%51 = load i32, i32* @INADDR_ANY
%52 = call i32 @htonl(i32 %51)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 0
store i32 %52, i32* %54
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 @atoi(i8* %57)
%59 = call i32 @htons(i32 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %59, i32* %60
store i32 12, i32* %11
%61 = load i32, i32* %6
%62 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%63 = load i32, i32* %11
%64 = call i32 @bind(i32 %61, %struct.sockaddr* %62, i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %70
66: ; preds = %47
%67 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %47
%71 = load i32, i32* @stdout
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
store i32 12, i32* %10
%73 = load i32, i32* %6
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%75 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%76 = call i32 @recvfrom(i32 %73, i8* %74, i32 256, i32 0, %struct.sockaddr* %75, i32* %10)
store i32 %76, i32* %7
%77 = load i32, i32* %7
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %83
79: ; preds = %70
%80 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %70
%84 = load i32, i32* %7
store i32 %84, i32* %13
%85 = load i32, i32* @stdout
%86 = load i32, i32* @AF_INET
%87 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%89 = call i8* @inet_ntop(i32 %86, %struct.TYPE_2__* %87, i8* %88, i32 256)
%90 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%91 = load i32, i32* %90
%92 = call i32 @ntohs(i32 %91)
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %89, i32 %92)
%94 = load i32, i32* @stdout
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%96 = call i32 (...) @ERR_load_crypto_strings()
%97 = call i32 (...) @OpenSSL_add_all_ciphers()
%98 = load i32*, i32** %17
%99 = call i32* @PEM_read_RSAPublicKey(i32* %98, i32* null, i32* null, i32* null)
store i32* %99, i32** %18
%100 = load i32*, i32** %18
%101 = icmp ne i32* %100, null
br i1 %101, label %107, label %102
102: ; preds = %83
%103 = load i32, i32* @stderr
%104 = call i32 @ERR_print_errors_fp(i32 %103)
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %83
%108 = load i32*, i32** %17
%109 = call i32 @fclose(i32* %108)
%110 = load i32*, i32** %18
%111 = call i32 @RSA_size(i32* %110)
store i32 %111, i32* %15
%112 = load i32, i32* %13
%113 = load i32, i32* %15
%114 = sub i32 %112, %113
store i32 %114, i32* %14
%115 = load i32, i32* @NID_sha1
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%117 = load i32, i32* %14
%118 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%119 = load i32, i32* %14
%120 = zext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = load i32, i32* %15
%123 = load i32*, i32** %18
%124 = call i32 @RSA_verify(i32 %115, i8* %116, i32 %117, i8* %121, i32 %122, i32* %123)
store i32 %124, i32* %7
%125 = load i32, i32* %7
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %132
127: ; preds = %107
%128 = load i32, i32* @stderr
%129 = call i32 @ERR_print_errors_fp(i32 %128)
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %107
%133 = load i32, i32* @stdout
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %135
135: ; preds = %132
%136 = load i32*, i32** %18
%137 = call i32 @RSA_free(i32* %136)
%138 = call i32 (...) @EVP_cleanup()
%139 = call i32 (...) @ERR_free_strings()
%140 = load i32, i32* @stdout
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%142 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%143 = load i32, i32* %14
%144 = load i32, i32* @stdout
%145 = call i32 @fwrite(i8* %142, i32 1, i32 %143, i32 %144)
%146 = load i32, i32* @stdout
%147 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%148 = load i32, i32* %6
%149 = call i32 @close(i32 %148)
%150 = load i32, i32* @EXIT_SUCCESS
%151 = call i32 @exit(i32 %150)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Invocation: %s <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"public.key\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [8 x i8] c"fopen()\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [9 x i8] c"socket()\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.5 = [7 x i8] c"bind()\00"
@stdout = global i32 0
@.str.6 = [39 x i8] c"Server is waiting for UDP datagram...\0A\00"
@.str.7 = [11 x i8] c"recvfrom()\00"
@.str.8 = [35 x i8] c"UDP datagram received from %s:%d.\0A\00"
@.str.9 = [27 x i8] c"Signature verification...\0A\00"
@NID_sha1 = global i32 0
@.str.10 = [21 x i8] c"Signature is valid.\0A\00"
@.str.11 = [10 x i8] c"Message: \00"
@.str.12 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = icmp eq i32 %0, 2
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @exit(i32 %25)
unreachable
27: ; preds = %20
%28 = load i32, i32* @PF_INET
%29 = load i32, i32* @SOCK_DGRAM
%30 = tail call i32 @socket(i32 %28, i32 %29, i32 0)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %27
%37 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %38, i32* %39
%40 = load i32, i32* @INADDR_ANY
%41 = call i32 @htonl(i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %41, i32* %42
%43 = getelementptr inbounds i8*, i8** %1, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
%46 = call i32 @htons(i32 %45)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %46, i32* %47
%48 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%49 = call i32 @bind(i32 %30, %struct.sockaddr* %48, i32 12)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %55
51: ; preds = %36
%52 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %36
%56 = load i32, i32* @stdout
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
store i32 12, i32* %5
%58 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%59 = call i32 @recvfrom(i32 %30, i8* %11, i32 256, i32 0, %struct.sockaddr* %58, i32* %5)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %55
%62 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %55
%66 = load i32, i32* @stdout
%67 = load i32, i32* @AF_INET
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%69 = call i8* @inet_ntop(i32 %67, %struct.TYPE_2__* %68, i8* %12, i32 256)
%70 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 @ntohs(i32 %71)
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %69, i32 %72)
%74 = load i32, i32* @stdout
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%76 = call i32 (...) @ERR_load_crypto_strings()
%77 = call i32 (...) @OpenSSL_add_all_ciphers()
%78 = call i32* @PEM_read_RSAPublicKey(i32* %21, i32* null, i32* null, i32* null)
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %85
80: ; preds = %65
%81 = load i32, i32* @stderr
%82 = call i32 @ERR_print_errors_fp(i32 %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %65
%86 = call i32 @fclose(i32* %21)
%87 = call i32 @RSA_size(i32* %78)
%88 = sub i32 %59, %87
%89 = load i32, i32* @NID_sha1
%90 = zext i32 %88 to i64
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %90
%92 = call i32 @RSA_verify(i32 %89, i8* %11, i32 %88, i8* %91, i32 %87, i32* %78)
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %85
%95 = load i32, i32* @stderr
%96 = call i32 @ERR_print_errors_fp(i32 %95)
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %85
%100 = load i32, i32* @stdout
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%102 = call i32 @RSA_free(i32* %78)
%103 = call i32 (...) @EVP_cleanup()
%104 = call i32 (...) @ERR_free_strings()
%105 = load i32, i32* @stdout
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%107 = load i32, i32* @stdout
%108 = call i32 @fwrite(i8* %11, i32 1, i32 %88, i32 %107)
%109 = load i32, i32* @stdout
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%111 = call i32 @close(i32 %30)
%112 = load i32, i32* @EXIT_SUCCESS
%113 = call i32 @exit(i32 %112)
unreachable
}