#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 */

/* Type definitions */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int read_int(char *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char *argv[]) {
  int sock;
  socklen_t tolen;
  struct sockaddr_in to;
  struct hostent *hp;
  char pktbuf[1500];
  int rval;
  int i;
  int pn;
  int idle;
  int result;
  char addr_regname[256];
  char banka_regname[256];
  char bankb_regname[256];
  char chansel_regname[256];
  char mcntr_regname[256];
  FILE *bramfile;
  int addr;
  char bank;
  int last_addr;
  char last_bank;
  unsigned int chansel;
  unsigned int mcntr;
  int chan;
  int streamid;
  if (argc < 2) {
    return -1;
  }
  sprintf(addr_regname, "/proc/%s/hw/ioreg/ppout0_addr", argv[1]);
  sprintf(banka_regname, "/proc/%s/hw/ioreg/ppout0_a", argv[1]);
  sprintf(bankb_regname, "/proc/%s/hw/ioreg/ppout0_b", argv[1]);
  sprintf(chansel_regname, "/proc/%s/hw/ioreg/ppout0_chan", argv[1]);
  sprintf(mcntr_regname, "/proc/%s/hw/ioreg/mcntr", argv[1]);
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock < 0)
    error("ERROR opening socket");
  to.sin_family = AF_INET;
  hp = gethostbyname("192.168.1.1");
  if (hp == 0)
    error("Unknown host");
  bcopy((char *)hp->h_addr, (char *)&to.sin_addr, hp->h_length);
  to.sin_port = htons(atoi("12345"));
  tolen = sizeof(struct sockaddr_in);
  addr = 0x1FFF & read_int(addr_regname);
  last_bank = addr > 4096;
  bank = last_bank;
  while (1) {
    idle = 0;
    while (bank == last_bank) {
      addr = 0x1FFF & read_int(addr_regname);
      bank = addr > 4096;
      idle += 1;
    }
    last_bank = bank;
    chansel = read_int(chansel_regname);
    chan = chansel & 0xFFFF;
    streamid = (chansel >> 16);
    if (streamid) {
      mcntr = read_int(mcntr_regname);
      if (bank) {
        bramfile = fopen(banka_regname, "r");
      } else {
        bramfile = fopen(bankb_regname, "r");
      }
      for (pn = 0; pn < 16; pn++) {
        ((unsigned int *)pktbuf)[0] = (idle << 16) + pn;
        ((unsigned int *)pktbuf)[1] = chansel;
        ((unsigned int *)pktbuf)[2] = mcntr;
        fread(pktbuf + 4 * 3, 1024, 1, bramfile);
        rval = sendto(sock, pktbuf, 1024 + 4 * 3, 0, (struct sockaddr *)&to,
                      tolen);
        if (rval < 0)
          error("ERROR sending");
      }
      fclose(bramfile);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f1 <main+0x31>
mov    $0xffffffff,%eax
add    $0xb60,%rsp
pop    %rbp
ret
lea    -0x730(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdf9(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x830(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfc(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x930(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfc(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0xa30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfc(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0xb30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdff(%rip),%rsi
call   10d0 <sprintf@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12aa <main+0xea>
lea    0xde5(%rip),%rdi
call   10a0 <error@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xde2(%rip),%rdi
call   1070 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12dd <main+0x11d>
lea    0xdd3(%rip),%rdi
call   10a0 <error@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   1090 <bcopy@plt>
lea    0xdb9(%rip),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0xc,-0x18(%rbp)
lea    -0x730(%rbp),%rdi
call   1080 <read_int@plt>
and    $0x1fff,%eax
mov    %eax,-0xb3c(%rbp)
cmpl   $0x1000,-0xb3c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0xb45(%rbp)
mov    -0xb45(%rbp),%al
mov    %al,-0xb3d(%rbp)
movl   $0x0,-0x620(%rbp)
movsbl -0xb3d(%rbp),%eax
movsbl -0xb45(%rbp),%ecx
cmp    %ecx,%eax
jne    13b3 <main+0x1f3>
lea    -0x730(%rbp),%rdi
call   1080 <read_int@plt>
and    $0x1fff,%eax
mov    %eax,-0xb3c(%rbp)
cmpl   $0x1000,-0xb3c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0xb3d(%rbp)
mov    -0x620(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x620(%rbp)
jmp    135a <main+0x19a>
mov    -0xb3d(%rbp),%al
mov    %al,-0xb45(%rbp)
lea    -0xa30(%rbp),%rdi
call   1080 <read_int@plt>
mov    %eax,-0xb4c(%rbp)
mov    -0xb4c(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0xb54(%rbp)
mov    -0xb4c(%rbp),%eax
shr    $0x10,%eax
mov    %eax,-0xb58(%rbp)
cmpl   $0x0,-0xb58(%rbp)
je     151d <main+0x35d>
lea    -0xb30(%rbp),%rdi
call   1080 <read_int@plt>
mov    %eax,-0xb50(%rbp)
cmpb   $0x0,-0xb3d(%rbp)
je     143c <main+0x27c>
lea    -0x830(%rbp),%rdi
lea    0xbf1(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xb38(%rbp)
jmp    1456 <main+0x296>
lea    -0x930(%rbp),%rdi
lea    0xbd2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xb38(%rbp)
movl   $0x0,-0x61c(%rbp)
cmpl   $0x10,-0x61c(%rbp)
jge    1511 <main+0x351>
mov    -0x620(%rbp),%eax
shl    $0x10,%eax
add    -0x61c(%rbp),%eax
mov    %eax,-0x610(%rbp)
mov    -0xb4c(%rbp),%eax
mov    %eax,-0x60c(%rbp)
mov    -0xb50(%rbp),%eax
mov    %eax,-0x608(%rbp)
lea    -0x610(%rbp),%rdi
add    $0xc,%rdi
mov    -0xb38(%rbp),%rcx
mov    $0x400,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x14(%rbp),%edi
lea    -0x610(%rbp),%rsi
lea    -0x28(%rbp),%r8
mov    -0x18(%rbp),%r9d
mov    $0x40c,%edx
xor    %ecx,%ecx
call   1060 <sendto@plt>
mov    %eax,-0x614(%rbp)
cmpl   $0x0,-0x614(%rbp)
jge    14f8 <main+0x338>
lea    0xbcb(%rip),%rdi
call   10a0 <error@plt>
jmp    14fd <main+0x33d>
mov    -0x61c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61c(%rbp)
jmp    1460 <main+0x2a0>
mov    -0xb38(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1350 <main+0x190>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb08,%rsp
cmp    $0x1,%edi
jg     11dd <main+0x2d>
mov    $0xffffffff,%eax
add    $0xb08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    0x8(%rsi),%rdx
lea    0xe15(%rip),%rsi
lea    0x20(%rsp),%rdi
call   10c0 <sprintf@plt>
mov    0x8(%rbx),%rdx
lea    0xe1e(%rip),%rsi
lea    0x420(%rsp),%rdi
call   10c0 <sprintf@plt>
mov    0x8(%rbx),%rdx
lea    0xe21(%rip),%rsi
lea    0x320(%rsp),%rdi
call   10c0 <sprintf@plt>
mov    0x8(%rbx),%rdx
lea    0xe24(%rip),%rsi
lea    0x220(%rsp),%rdi
call   10c0 <sprintf@plt>
mov    0x8(%rbx),%rdx
lea    0xe2a(%rip),%rsi
lea    0x120(%rsp),%rdi
call   10c0 <sprintf@plt>
mov    0x2d8c(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jns    1282 <main+0xd2>
lea    0xe0d(%rip),%rdi
call   10a0 <error@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
lea    0xe10(%rip),%rdi
call   1070 <gethostbyname@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    12a8 <main+0xf8>
lea    0xe08(%rip),%rdi
call   10a0 <error@plt>
mov    0x8(%rbx),%rsi
lea    0x14(%rsp),%rdi
mov    (%rbx),%edx
call   1090 <memmove@plt>
mov    $0x3039,%edi
call   1050 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x20(%rsp),%r12
mov    %r12,%rdi
call   1080 <read_int@plt>
and    $0x1fff,%eax
cmp    $0x1001,%eax
setae  %r14b
jmp    1300 <main+0x150>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebx,%r14d
lea    0x20(%rsp),%r12
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1080 <read_int@plt>
mov    %eax,%ebp
and    $0x1fff,%ebp
cmp    $0x1001,%ebp
setae  %bl
add    $0x10000,%r15d
cmp    %bl,%r14b
je     1310 <main+0x160>
lea    0x220(%rsp),%rdi
call   1080 <read_int@plt>
mov    %ebx,%r14d
cmp    $0x10000,%eax
jb     1300 <main+0x150>
mov    %eax,%r13d
lea    0x120(%rsp),%rdi
call   1080 <read_int@plt>
mov    %eax,%r12d
cmp    $0x1001,%ebp
lea    0x320(%rsp),%rdi
lea    0x420(%rsp),%rax
cmovae %rax,%rdi
lea    0xc9c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
xor    %ebp,%ebp
jmp    139c <main+0x1ec>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x10,%ebp
je     12f0 <main+0x140>
lea    (%r15,%rbp,1),%eax
mov    %eax,0x520(%rsp)
mov    %r13d,0x524(%rsp)
mov    %r12d,0x528(%rsp)
lea    0x52c(%rsp),%rdi
mov    $0x400,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    0xc(%rsp),%edi
lea    0x520(%rsp),%rsi
mov    $0x40c,%edx
xor    %ecx,%ecx
lea    0x10(%rsp),%r8
mov    $0xc,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
jns    1390 <main+0x1e0>
lea    0xcb9(%rip),%rdi
call   10a0 <error@plt>
jmp    1390 <main+0x1e0>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [30 x i8] c"/proc/%s/hw/ioreg/ppout0_addr\00"
@.str.1 = [27 x i8] c"/proc/%s/hw/ioreg/ppout0_a\00"
@.str.2 = [27 x i8] c"/proc/%s/hw/ioreg/ppout0_b\00"
@.str.3 = [30 x i8] c"/proc/%s/hw/ioreg/ppout0_chan\00"
@.str.4 = [24 x i8] c"/proc/%s/hw/ioreg/mcntr\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.5 = [21 x i8] c"ERROR opening socket\00"
@.str.6 = [12 x i8] c"192.168.1.1\00"
@.str.7 = [13 x i8] c"Unknown host\00"
@.str.8 = [6 x i8] c"12345\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [14 x i8] c"ERROR sending\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.hostent*
%10 = alloca [1500 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [256 x i8]
%17 = alloca [256 x i8]
%18 = alloca [256 x i8]
%19 = alloca [256 x i8]
%20 = alloca [256 x i8]
%21 = alloca i32*
%22 = alloca i32
%23 = alloca i8
%24 = alloca i32
%25 = alloca i8
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 2
br i1 %31, label %32, label %33
32: ; preds = %2
ret i32 -1
33: ; preds = %2
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %57)
%59 = load i32, i32* @AF_INET
%60 = load i32, i32* @SOCK_DGRAM
%61 = call i32 @socket(i32 %59, i32 %60, i32 0)
store i32 %61, i32* %6
%62 = load i32, i32* %6
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %33
%65 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %33
%67 = load i32, i32* @AF_INET
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %67, i32* %68
%69 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store %struct.hostent* %69, %struct.hostent** %9
%70 = load %struct.hostent*, %struct.hostent** %9
%71 = icmp eq %struct.hostent* %70, null
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = load %struct.hostent*, %struct.hostent** %9
%76 = getelementptr inbounds %struct.hostent, %struct.hostent* %75, i32 0, i32 1
%77 = load i64, i64* %76
%78 = inttoptr i64 %77 to i8*
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%80 = bitcast i32* %79 to i8*
%81 = load %struct.hostent*, %struct.hostent** %9
%82 = getelementptr inbounds %struct.hostent, %struct.hostent* %81, i32 0, i32 0
%83 = load i32, i32* %82
%84 = call i32 @bcopy(i8* %78, i8* %80, i32 %83)
%85 = call i32 @atoi(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%86 = call i32 @htons(i32 %85)
%87 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %86, i32* %87
store i32 12, i32* %7
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%89 = call i32 @read_int(i8* %88)
%90 = and i32 8191, %89
store i32 %90, i32* %22
%91 = load i32, i32* %22
%92 = icmp sgt i32 %91, 4096
%93 = zext i1 %92 to i32
%94 = trunc i32 %93 to i8
store i8 %94, i8* %25
%95 = load i8, i8* %25
store i8 %95, i8* %23
br label %96
96: ; preds = %74, %174
store i32 0, i32* %14
br label %97
97: ; preds = %103, %96
%98 = load i8, i8* %23
%99 = sext i8 %98 to i32
%100 = load i8, i8* %25
%101 = sext i8 %100 to i32
%102 = icmp eq i32 %99, %101
br i1 %102, label %103, label %113
103: ; preds = %97
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%105 = call i32 @read_int(i8* %104)
%106 = and i32 8191, %105
store i32 %106, i32* %22
%107 = load i32, i32* %22
%108 = icmp sgt i32 %107, 4096
%109 = zext i1 %108 to i32
%110 = trunc i32 %109 to i8
store i8 %110, i8* %23
%111 = load i32, i32* %14
%112 = add nsw i32 %111, 1
store i32 %112, i32* %14
br label %97
113: ; preds = %97
%114 = load i8, i8* %23
store i8 %114, i8* %25
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %19, i64 0, i64 0
%116 = call i32 @read_int(i8* %115)
store i32 %116, i32* %26
%117 = load i32, i32* %26
%118 = and i32 %117, 65535
store i32 %118, i32* %28
%119 = load i32, i32* %26
%120 = lshr i32 %119, 16
store i32 %120, i32* %29
%121 = load i32, i32* %29
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %174
123: ; preds = %113
%124 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%125 = call i32 @read_int(i8* %124)
store i32 %125, i32* %27
%126 = load i8, i8* %23
%127 = icmp ne i8 %126, 0
br i1 %127, label %128, label %131
128: ; preds = %123
%129 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%130 = call i32* @fopen(i8* %129, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %130, i32** %21
br label %134
131: ; preds = %123
%132 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%133 = call i32* @fopen(i8* %132, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %133, i32** %21
br label %134
134: ; preds = %131, %128
store i32 0, i32* %13
br label %135
135: ; preds = %168, %134
%136 = load i32, i32* %13
%137 = icmp slt i32 %136, 16
br i1 %137, label %138, label %171
138: ; preds = %135
%139 = load i32, i32* %14
%140 = shl i32 %139, 16
%141 = load i32, i32* %13
%142 = add nsw i32 %140, %141
%143 = getelementptr inbounds [1500 x i8], [1500 x i8]* %10, i64 0, i64 0
%144 = bitcast i8* %143 to i32*
%145 = getelementptr inbounds i32, i32* %144, i64 0
store i32 %142, i32* %145
%146 = load i32, i32* %26
%147 = getelementptr inbounds [1500 x i8], [1500 x i8]* %10, i64 0, i64 0
%148 = bitcast i8* %147 to i32*
%149 = getelementptr inbounds i32, i32* %148, i64 1
store i32 %146, i32* %149
%150 = load i32, i32* %27
%151 = getelementptr inbounds [1500 x i8], [1500 x i8]* %10, i64 0, i64 0
%152 = bitcast i8* %151 to i32*
%153 = getelementptr inbounds i32, i32* %152, i64 2
store i32 %150, i32* %153
%154 = getelementptr inbounds [1500 x i8], [1500 x i8]* %10, i64 0, i64 0
%155 = getelementptr inbounds i8, i8* %154, i64 12
%156 = load i32*, i32** %21
%157 = call i32 @fread(i8* %155, i32 1024, i32 1, i32* %156)
%158 = load i32, i32* %6
%159 = getelementptr inbounds [1500 x i8], [1500 x i8]* %10, i64 0, i64 0
%160 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%161 = load i32, i32* %7
%162 = call i32 @sendto(i32 %158, i8* %159, i32 1036, i32 0, %struct.sockaddr* %160, i32 %161)
store i32 %162, i32* %11
%163 = load i32, i32* %11
%164 = icmp slt i32 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %138
%166 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %167
167: ; preds = %165, %138
br label %168
168: ; preds = %167
%169 = load i32, i32* %13
%170 = add nsw i32 %169, 1
store i32 %170, i32* %13
br label %135
171: ; preds = %135
%172 = load i32*, i32** %21
%173 = call i32 @fclose(i32* %172)
br label %174
174: ; preds = %171, %113
br label %96
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [30 x i8] c"/proc/%s/hw/ioreg/ppout0_addr\00"
@.str.1 = [27 x i8] c"/proc/%s/hw/ioreg/ppout0_a\00"
@.str.2 = [27 x i8] c"/proc/%s/hw/ioreg/ppout0_b\00"
@.str.3 = [30 x i8] c"/proc/%s/hw/ioreg/ppout0_chan\00"
@.str.4 = [24 x i8] c"/proc/%s/hw/ioreg/mcntr\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.5 = [21 x i8] c"ERROR opening socket\00"
@.str.6 = [12 x i8] c"192.168.1.1\00"
@.str.7 = [13 x i8] c"Unknown host\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [14 x i8] c"ERROR sending\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [1500 x i8]
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = getelementptr inbounds [1500 x i8], [1500 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%17 = icmp slt i32 %0, 2
br i1 %17, label %18, label %19
18: ; preds = %2
ret i32 -1
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %20
%24 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %20
%26 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %20
%28 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %20
%30 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_DGRAM
%33 = tail call i32 @socket(i32 %31, i32 %32, i32 0)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %19
%36 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %19
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %38, i32* %39
%40 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp eq %struct.hostent* %40, null
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = tail call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %40, i64 0, i32 1
%46 = load i64, i64* %45
%47 = inttoptr i64 %46 to i8*
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%49 = bitcast i32* %48 to i8*
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %40, i64 0, i32 0
%51 = load i32, i32* %50
%52 = tail call i32 @htons(i32 12345)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %52, i32* %53
%54 = call i32 @read_int(i8* %12)
%55 = and i32 %54, 8191
%56 = icmp ugt i32 %55, 4096
%57 = zext i1 %56 to i8
%58 = bitcast [1500 x i8]* %4 to i32*
%59 = getelementptr inbounds [1500 x i8], [1500 x i8]* %4, i64 0, i64 4
%60 = bitcast i8* %59 to i32*
%61 = getelementptr inbounds [1500 x i8], [1500 x i8]* %4, i64 0, i64 8
%62 = bitcast i8* %61 to i32*
%63 = getelementptr inbounds [1500 x i8], [1500 x i8]* %4, i64 0, i64 12
%64 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
br label %65
65: ; preds = %96, %44
%66 = phi i8 [ %57, %44 ], [ %72, %96 ]
br label %67
67: ; preds = %65, %67
%68 = phi i32 [ 0, %65 ], [ %73, %67 ]
%69 = call i32 @read_int(i8* %12)
%70 = and i32 %69, 8191
%71 = icmp ugt i32 %70, 4096
%72 = zext i1 %71 to i8
%73 = add nuw nsw i32 %68, 1
%74 = icmp eq i8 %66, %72
br i1 %74, label %67, label %75
75: ; preds = %67
%76 = call i32 @read_int(i8* %15)
%77 = icmp ult i32 %76, 65536
br i1 %77, label %96, label %78
78: ; preds = %75
%79 = call i32 @read_int(i8* %16)
%80 = select i1 %71, i8* %13, i8* %14
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%82 = shl i32 %73, 16
br label %83
83: ; preds = %78, %91
%84 = phi i32 [ 0, %78 ], [ %92, %91 ]
%85 = add nuw nsw i32 %84, %82
store i32 %85, i32* %58
store i32 %76, i32* %60
store i32 %79, i32* %62
%86 = call i32 @fread(i8* %63, i32 1024, i32 1, i32* %81)
%87 = call i32 @sendto(i32 %33, i8* %11, i32 1036, i32 0, %struct.sockaddr* %64, i32 12)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %91
91: ; preds = %83, %89
%92 = add nuw nsw i32 %84, 1
%93 = icmp eq i32 %92, 16
br i1 %93, label %94, label %83
94: ; preds = %91
%95 = call i32 @fclose(i32* %81)
br label %96
96: ; preds = %94, %75
br label %65
}