#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 dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *get_ip_addr();
struct hostent *gethostbyname(char *);
scalar_t__ getline(char **, int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                  struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char **argv) {
  FILE *fp;
  char *line = NULL;
  char ip_addr[1024];
  char *my_ip_addr;
  char buf[1024];
  int port, range, rate;
  int line_length, message_size;
  int sockfd;
  double heart_rate;
  struct sockaddr_in server_addr;
  struct hostent *server;
  my_ip_addr = get_ip_addr();
  printf("My ip addr is: %s\n", my_ip_addr);
  if (argc != 2) {
    fprintf(stderr, "Error. Usage: ./set_rate <rate>. Exiting.\n");
    exit(1);
  }
  rate = atoi(argv[1]);
  if (rate < 1 || rate > 5) {
    fprintf(stderr,
            "Error. Rate must be between 0 and 5. You supplied %d. Exiting.\n",
            rate);
    exit(1);
  }
  fp = fopen("config_file", "r");
  if (fp == NULL) {
    fprintf(stderr,
            "Error opening config file with name 'config_file'. Exiting.\n");
    exit(1);
  }
  printf("Reading input file...\n");
  while (getline(&line, &line_length, fp) > 0) {
    if (strstr(line, "host_ip") != NULL) {
      sscanf(line, "host_ip: %s\n", ip_addr);
    } else if (strstr(line, "port") != NULL) {
      sscanf(line, "port: %d\n", &port);
    }
  }
  fclose(fp);
  printf("Connecting to: %s:%d\n", ip_addr, port, rate, range);
  server = gethostbyname(ip_addr);
  socklen_t len = sizeof(server_addr);
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  bzero((char *)&server_addr, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = inet_addr(ip_addr);
  server_addr.sin_port = htons(port);
  sprintf(buf, "IP: %s new_rate: %d", my_ip_addr, rate);
  printf("Sending message '%s' to server...\n", buf);
  if (sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *)&server_addr,
             len) < 0) {
    fprintf(stderr, "Failed to send.\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1080 <get_ip_addr@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
je     128f <main+0x6f>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x83c(%rbp)
cmpl   $0x1,-0x83c(%rbp)
jl     12bc <main+0x9c>
cmpl   $0x5,-0x83c(%rbp)
jle    12e3 <main+0xc3>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
mov    -0x83c(%rbp),%edx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xd94(%rip),%rdi
lea    0xd99(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1326 <main+0x106>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x840(%rbp),%rsi
call   1100 <getline@plt>
cmp    $0x0,%rax
jle    13c7 <main+0x1a7>
mov    -0x20(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
je     138a <main+0x16a>
mov    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   10c0 <sscanf@plt>
jmp    13c2 <main+0x1a2>
mov    -0x20(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1130 <strstr@plt>
cmp    $0x0,%rax
je     13bd <main+0x19d>
mov    -0x20(%rbp),%rdi
lea    0xd4b(%rip),%rsi
lea    -0x834(%rbp),%rdx
mov    $0x0,%al
call   10c0 <sscanf@plt>
jmp    13c2 <main+0x1a2>
jmp    1334 <main+0x114>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x420(%rbp),%rsi
mov    -0x834(%rbp),%edx
mov    -0x83c(%rbp),%ecx
mov    -0x838(%rbp),%r8d
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x420(%rbp),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0x868(%rbp)
movl   $0xc,-0x86c(%rbp)
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x848(%rbp)
lea    -0x860(%rbp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x2b9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x858(%rbp)
lea    -0x420(%rbp),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x85c(%rbp)
mov    -0x834(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x860(%rbp)
lea    -0x830(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    -0x83c(%rbp),%ecx
lea    0xc88(%rip),%rsi
call   1110 <sprintf@plt>
lea    -0x830(%rbp),%rsi
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x848(%rbp),%eax
mov    %eax,-0x87c(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0x878(%rbp)
lea    -0x830(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x87c(%rbp),%edi
mov    -0x878(%rbp),%rsi
mov    %eax,%edx
lea    -0x860(%rbp),%r8
mov    -0x86c(%rbp),%r9d
xor    %ecx,%ecx
call   1070 <sendto@plt>
cmp    $0x0,%rax
jge    1521 <main+0x301>
mov    0x2ac9(%rip),%rax
mov    (%rax),%edi
lea    0xc41(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
xor    %eax,%eax
add    $0x880,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1090 <get_ip_addr@plt>
mov    %rax,%r14
lea    0xda0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x2,%ebp
jne    1446 <main+0x216>
mov    0x8(%rbx),%rdi
call   1100 <atoi@plt>
mov    %eax,%edx
add    $0xfffffffa,%eax
cmp    $0xfffffffa,%eax
jbe    1458 <main+0x228>
mov    %edx,0x10(%rsp)
lea    0xde9(%rip),%rdi
lea    0xdee(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1479 <main+0x249>
mov    %rax,%rbx
mov    %r14,0x28(%rsp)
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
mov    %rbx,%rdx
call   1110 <getline@plt>
test   %rax,%rax
jle    1361 <main+0x131>
lea    0xde9(%rip),%rbp
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r13
lea    0x30(%rsp),%r12
jmp    1327 <main+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xdc7(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <sscanf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1110 <getline@plt>
test   %rax,%rax
jle    1361 <main+0x131>
mov    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
call   1140 <strstr@plt>
test   %rax,%rax
jne    1300 <main+0xd0>
mov    %r14,%rdi
lea    0xd98(%rip),%rsi
call   1140 <strstr@plt>
test   %rax,%rax
je     1314 <main+0xe4>
mov    %r14,%rdi
lea    0xd89(%rip),%rsi
lea    0x4(%rsp),%rdx
jmp    130d <main+0xdd>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%edx
lea    0xd79(%rip),%rdi
lea    0x30(%rsp),%r12
mov    %r12,%rsi
mov    0x10(%rsp),%ebp
mov    %ebp,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
call   10b0 <gethostbyname@plt>
mov    0x2c50(%rip),%rbx
mov    (%rbx),%edi
mov    0x2c3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r15d
lea    0x18(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    (%rbx),%eax
mov    %eax,0x20(%rsp)
mov    %r12,%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x1c(%rsp)
mov    0x4(%rsp),%edi
call   1060 <htons@plt>
mov    %eax,0x18(%rsp)
lea    0xd1e(%rip),%rsi
lea    0x430(%rsp),%rbx
mov    %rbx,%rdi
mov    0x28(%rsp),%rdx
mov    %ebp,%ecx
call   1120 <sprintf@plt>
lea    0xd14(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0xc,%r9d
call   1080 <sendto@plt>
test   %rax,%rax
js     148b <main+0x25b>
xor    %eax,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
lea    0xbbd(%rip),%rsi
jmp    149b <main+0x26b>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
lea    0xbd6(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
jmp    149b <main+0x26b>
mov    0x2b3e(%rip),%rax
mov    (%rax),%edi
lea    0xc9f(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"My ip addr is: %s\0A\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Error. Usage: ./set_rate <rate>. Exiting.\0A\00"
@.str.2 = [64 x i8] c"Error. Rate must be between 0 and 5. You supplied %d. Exiting.\0A\00"
@.str.3 = [12 x i8] c"config_file\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [61 x i8] c"Error opening config file with name 'config_file'. Exiting.\0A\00"
@.str.6 = [23 x i8] c"Reading input file...\0A\00"
@.str.7 = [8 x i8] c"host_ip\00"
@.str.8 = [13 x i8] c"host_ip: %s\0A\00"
@.str.9 = [5 x i8] c"port\00"
@.str.10 = [10 x i8] c"port: %d\0A\00"
@.str.11 = [22 x i8] c"Connecting to: %s:%d\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.12 = [20 x i8] c"IP: %s new_rate: %d\00"
@.str.13 = [35 x i8] c"Sending message '%s' to server...\0A\00"
@.str.14 = [17 x i8] c"Failed to send.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca %struct.sockaddr_in
%19 = alloca %struct.hostent*
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%21 = call i8* (...) @get_ip_addr()
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 2
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %13
%35 = load i32, i32* %13
%36 = icmp slt i32 %35, 1
br i1 %36, label %40, label %37
37: ; preds = %30
%38 = load i32, i32* %13
%39 = icmp sgt i32 %38, 5
br i1 %39, label %40, label %45
40: ; preds = %37, %30
%41 = load i32, i32* @stderr
%42 = load i32, i32* %13
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
%46 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %46, i32** %6
%47 = load i32*, i32** %6
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %45
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %75, %53
%56 = load i32*, i32** %6
%57 = call i64 @getline(i8** %7, i32* %14, i32* %56)
%58 = icmp sgt i64 %57, 0
br i1 %58, label %59, label %76
59: ; preds = %55
%60 = load i8*, i8** %7
%61 = call i32* @strstr(i8* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp ne i32* %61, null
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i8*, i8** %7
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%66 = call i32 (i8*, i8*, ...) @sscanf(i8* %64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %65)
br label %75
67: ; preds = %59
%68 = load i8*, i8** %7
%69 = call i32* @strstr(i8* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%70 = icmp ne i32* %69, null
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load i8*, i8** %7
%73 = call i32 (i8*, i8*, ...) @sscanf(i8* %72, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32* %11)
br label %74
74: ; preds = %71, %67
br label %75
75: ; preds = %74, %63
br label %55
76: ; preds = %55
%77 = load i32*, i32** %6
%78 = call i32 @fclose(i32* %77)
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%80 = load i32, i32* %11
%81 = load i32, i32* %13
%82 = load i32, i32* %12
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %79, i32 %80, i32 %81, i32 %82)
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%85 = call %struct.hostent* @gethostbyname(i8* %84)
store %struct.hostent* %85, %struct.hostent** %19
store i32 12, i32* %20
%86 = load i32, i32* @AF_INET
%87 = load i32, i32* @SOCK_DGRAM
%88 = call i32 @socket(i32 %86, i32 %87, i32 0)
store i32 %88, i32* %16
%89 = bitcast %struct.sockaddr_in* %18 to i8*
%90 = call i32 @bzero(i8* %89, i32 12)
%91 = load i32, i32* @AF_INET
%92 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 2
store i32 %91, i32* %92
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%94 = call i32 @inet_addr(i8* %93)
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 1
%96 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %95, i32 0, i32 0
store i32 %94, i32* %96
%97 = load i32, i32* %11
%98 = call i32 @htons(i32 %97)
%99 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
store i32 %98, i32* %99
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%101 = load i8*, i8** %9
%102 = load i32, i32* %13
%103 = call i32 @sprintf(i8* %100, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %101, i32 %102)
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i8* %104)
%106 = load i32, i32* %16
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%109 = call i32 @strlen(i8* %108)
%110 = bitcast %struct.sockaddr_in* %18 to %struct.sockaddr*
%111 = load i32, i32* %20
%112 = call i64 @sendto(i32 %106, i8* %107, i32 %109, i32 0, %struct.sockaddr* %110, i32 %111)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %76
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %76
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"My ip addr is: %s\0A\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Error. Usage: ./set_rate <rate>. Exiting.\0A\00"
@.str.2 = [64 x i8] c"Error. Rate must be between 0 and 5. You supplied %d. Exiting.\0A\00"
@.str.3 = [12 x i8] c"config_file\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [61 x i8] c"Error opening config file with name 'config_file'. Exiting.\0A\00"
@.str.7 = [8 x i8] c"host_ip\00"
@.str.8 = [13 x i8] c"host_ip: %s\0A\00"
@.str.9 = [5 x i8] c"port\00"
@.str.10 = [10 x i8] c"port: %d\0A\00"
@.str.11 = [22 x i8] c"Connecting to: %s:%d\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.12 = [20 x i8] c"IP: %s new_rate: %d\00"
@.str.13 = [35 x i8] c"Sending message '%s' to server...\0A\00"
@.str.14 = [17 x i8] c"Failed to send.\0A\00"
@str = [22 x i8] c"Reading input file...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast %struct.sockaddr_in* %8 to i8*
%15 = tail call i8* (...) @get_ip_addr()
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp eq i32 %0, 2
br i1 %17, label %22, label %18
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = add i32 %25, -6
%27 = icmp ult i32 %26, -5
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %22
%33 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %32
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%41 = call i64 @getline(i8** %3, i32* %7, i32* %33)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %43, label %57
43: ; preds = %39, %54
%44 = load i8*, i8** %3
%45 = call i32* @strstr(i8* dereferenceable(1) %44, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %54
49: ; preds = %43
%50 = call i32* @strstr(i8* dereferenceable(1) %44, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %54, label %52
52: ; preds = %49
%53 = call i32 (i8*, i8*, ...) @sscanf(i8* %44, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32* %6)
br label %54
54: ; preds = %49, %52, %47
%55 = call i64 @getline(i8** %3, i32* %7, i32* %33)
%56 = icmp sgt i64 %55, 0
br i1 %56, label %43, label %57
57: ; preds = %54, %39
%58 = call i32 @fclose(i32* %33)
%59 = load i32, i32* %6
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %10, i32 %59, i32 %25, i32 undef)
%61 = call %struct.hostent* @gethostbyname(i8* %10)
%62 = load i32, i32* @AF_INET
%63 = load i32, i32* @SOCK_DGRAM
%64 = call i32 @socket(i32 %62, i32 %63, i32 0)
%65 = call i32 @bzero(i8* %14, i32 12)
%66 = load i32, i32* @AF_INET
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 2
store i32 %66, i32* %67
%68 = call i32 @inet_addr(i8* %10)
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 1, i32 0
store i32 %68, i32* %69
%70 = load i32, i32* %6
%71 = call i32 @htons(i32 %70)
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 0
store i32 %71, i32* %72
%73 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %15, i32 %25)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i8* %11)
%75 = call i32 @strlen(i8* %11)
%76 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%77 = call i64 @sendto(i32 %64, i8* %11, i32 %75, i32 0, %struct.sockaddr* %76, i32 12)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %57
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %57
ret i32 0
}