#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 ifreq {
  int /*<<< orphan*/ ifr_flags;
  int /*<<< orphan*/ ifr_name;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ IFF_PROMISC;
int /*<<< orphan*/ IFNAMSIZ;
int /*<<< orphan*/ PF_PACKET;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char **, int, int, int /*<<< orphan*/ *);
int ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int socket_receive(int num_packets) {
  int sock, n;
  char buffer[2048], rx_pack[1038];
  unsigned char *iphead, *ethhead;
  struct ifreq ethreq;
  if ((sock = socket(PF_PACKET, SOCK_RAW, 0x0400)) < 0) {
    perror("socket");
    exit(1);
  }
  strncpy(ethreq.ifr_name, "eth0", IFNAMSIZ);
  if (ioctl(sock, SIOCGIFFLAGS, &ethreq) == -1) {
    perror("ioctl");
    close(sock);
    exit(1);
  }
  ethreq.ifr_flags |= IFF_PROMISC;
  if (ioctl(sock, SIOCSIFFLAGS, &ethreq) == -1) {
    perror("ioctl");
    close(sock);
    exit(1);
  }
  FILE *erp = NULL;
  erp = fopen("eth_rx_packets.txt", "w+");
  fclose(erp);
  int packs = 0;
  while (packs < num_packets) {
    n = recvfrom(sock, buffer, 2048, 0, NULL, NULL);
    ethhead = buffer;
    packs++;
    erp = fopen("eth_rx_packets.txt", "a+");
    fwrite(&buffer, 1, n, erp);
    fclose(erp);
    printf(" %d\n", packs);
    printf("Source MAC address: "
           "%02x:%02x:%02x:%02x:%02x:%02x\n",
           ethhead[0], ethhead[1], ethhead[2], ethhead[3], ethhead[4],
           ethhead[5]);
    printf("Destination MAC address: "
           "%02x:%02x:%02x:%02x:%02x:%02x\n",
           ethhead[6], ethhead[7], ethhead[8], ethhead[9], ethhead[10],
           ethhead[11]);
  }
  printf("Packs received %d ", packs);
}


x86 assembly (clang, -O0):
<socket_receive>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc50,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    $0x400,%edx
call   10d0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11fc <socket_receive+0x4c>
lea    0xe13(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0xc34(%rbp),%edi
mov    0x2db7(%rip),%rax
mov    (%rax),%edx
lea    0xdf5(%rip),%rsi
call   1030 <strncpy@plt>
mov    -0xc(%rbp),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
lea    -0xc38(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1256 <socket_receive+0xa6>
lea    0xdcd(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
or     -0xc38(%rbp),%eax
mov    %eax,-0xc38(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
lea    -0xc38(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12aa <socket_receive+0xfa>
lea    0xd79(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
movq   $0x0,-0xc40(%rbp)
lea    0xd56(%rip),%rdi
lea    0xd62(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xc40(%rbp)
mov    -0xc40(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0xc44(%rbp)
mov    -0xc44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1435 <socket_receive+0x285>
mov    -0xc(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   1080 <recvfrom@plt>
mov    %eax,-0x10(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0xc30(%rbp)
mov    -0xc44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc44(%rbp)
lea    0xcd9(%rip),%rdi
lea    0xce8(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xc40(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0xc40(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    -0xc40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc44(%rbp),%esi
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc30(%rbp),%rax
movzbl (%rax),%esi
mov    -0xc30(%rbp),%rax
movzbl 0x1(%rax),%edx
mov    -0xc30(%rbp),%rax
movzbl 0x2(%rax),%ecx
mov    -0xc30(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    -0xc30(%rbp),%rax
movzbl 0x4(%rax),%r9d
mov    -0xc30(%rbp),%rax
movzbl 0x5(%rax),%eax
lea    0xc5f(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc30(%rbp),%rax
movzbl 0x6(%rax),%esi
mov    -0xc30(%rbp),%rax
movzbl 0x7(%rax),%edx
mov    -0xc30(%rbp),%rax
movzbl 0x8(%rax),%ecx
mov    -0xc30(%rbp),%rax
movzbl 0x9(%rax),%r8d
mov    -0xc30(%rbp),%rax
movzbl 0xa(%rax),%r9d
mov    -0xc30(%rbp),%rax
movzbl 0xb(%rax),%eax
lea    0xc3d(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12e5 <socket_receive+0x135>
mov    -0xc44(%rbp),%esi
lea    0xc59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xc50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_receive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %edi,%ebx
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
mov    $0x400,%edx
call   10d0 <socket@plt>
test   %eax,%eax
js     13ab <socket_receive+0x1fb>
mov    %eax,%r15d
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
lea    0xe0d(%rip),%rsi
call   1030 <strncpy@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %r15d,%edi
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     138d <socket_receive+0x1dd>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
or     %eax,0x18(%rsp)
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %r15d,%edi
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     138d <socket_receive+0x1dd>
lea    0xdc1(%rip),%rdi
lea    0xdcd(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
test   %ebx,%ebx
jle    136b <socket_receive+0x1bb>
mov    %ebx,0x14(%rsp)
mov    %ebx,%r13d
neg    %r13d
mov    $0x1,%ebx
lea    0x20(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x800,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1080 <recvfrom@plt>
mov    %eax,%r14d
lea    0xd60(%rip),%rdi
lea    0xd6f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xd48(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x20(%rsp),%esi
movzbl 0x21(%rsp),%edx
movzbl 0x22(%rsp),%ecx
movzbl 0x23(%rsp),%r8d
movzbl 0x24(%rsp),%r9d
movzbl 0x25(%rsp),%eax
mov    %eax,(%rsp)
lea    0xd1a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x26(%rsp),%esi
movzbl 0x27(%rsp),%edx
movzbl 0x28(%rsp),%ecx
movzbl 0x29(%rsp),%r8d
movzbl 0x2a(%rsp),%r9d
movzbl 0x2b(%rsp),%eax
mov    %eax,(%rsp)
lea    0xd1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1290 <socket_receive+0xe0>
mov    0x14(%rsp),%esi
jmp    136d <socket_receive+0x1bd>
xor    %esi,%esi
lea    0xd27(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc78(%rip),%rdi
call   10a0 <perror@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xc4e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"eth0\00"
@IFNAMSIZ = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@IFF_PROMISC = global i32 0
@SIOCSIFFLAGS = global i32 0
@.str.3 = [19 x i8] c"eth_rx_packets.txt\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [3 x i8] c"a+\00"
@.str.6 = [5 x i8] c" %d\0A\00"
@.str.7 = [51 x i8] c"Source MAC address: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@.str.8 = [56 x i8] c"Destination MAC address: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@.str.9 = [19 x i8] c"Packs received %d \00"
define i32 @socket_receive(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2048 x i8]
%7 = alloca [1038 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.ifreq
%11 = alloca i32*
%12 = alloca i32
store i32 %0, i32* %3
%13 = load i32, i32* @PF_PACKET
%14 = load i32, i32* @SOCK_RAW
%15 = call i32 @socket(i32 %13, i32 %14, i32 1024)
store i32 %15, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %1
%21 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load i32, i32* @IFNAMSIZ
%24 = call i32 @strncpy(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* @SIOCGIFFLAGS
%27 = call i32 @ioctl(i32 %25, i32 %26, %struct.ifreq* %10)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %20
%30 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* %4
%32 = call i32 @close(i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %20
%35 = load i32, i32* @IFF_PROMISC
%36 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 0
%37 = load i32, i32* %36
%38 = or i32 %37, %35
store i32 %38, i32* %36
%39 = load i32, i32* %4
%40 = load i32, i32* @SIOCSIFFLAGS
%41 = call i32 @ioctl(i32 %39, i32 %40, %struct.ifreq* %10)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %34
%44 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* %4
%46 = call i32 @close(i32 %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %34
store i32* null, i32** %11
%49 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %49, i32** %11
%50 = load i32*, i32** %11
%51 = call i32 @fclose(i32* %50)
store i32 0, i32* %12
br label %52
52: ; preds = %56, %48
%53 = load i32, i32* %12
%54 = load i32, i32* %3
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %122
56: ; preds = %52
%57 = load i32, i32* %4
%58 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%59 = call i32 @recvfrom(i32 %57, i8* %58, i32 2048, i32 0, i32* null, i32* null)
store i32 %59, i32* %5
%60 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
store i8* %60, i8** %9
%61 = load i32, i32* %12
%62 = add nsw i32 %61, 1
store i32 %62, i32* %12
%63 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %63, i32** %11
%64 = bitcast [2048 x i8]* %6 to i8**
%65 = load i32, i32* %5
%66 = load i32*, i32** %11
%67 = call i32 @fwrite(i8** %64, i32 1, i32 %65, i32* %66)
%68 = load i32*, i32** %11
%69 = call i32 @fclose(i32* %68)
%70 = load i32, i32* %12
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %70)
%72 = load i8*, i8** %9
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = load i8*, i8** %9
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = load i8*, i8** %9
%81 = getelementptr inbounds i8, i8* %80, i64 2
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = load i8*, i8** %9
%85 = getelementptr inbounds i8, i8* %84, i64 3
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = load i8*, i8** %9
%89 = getelementptr inbounds i8, i8* %88, i64 4
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = load i8*, i8** %9
%93 = getelementptr inbounds i8, i8* %92, i64 5
%94 = load i8, i8* %93
%95 = zext i8 %94 to i32
%96 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %75, i32 %79, i32 %83, i32 %87, i32 %91, i32 %95)
%97 = load i8*, i8** %9
%98 = getelementptr inbounds i8, i8* %97, i64 6
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = load i8*, i8** %9
%102 = getelementptr inbounds i8, i8* %101, i64 7
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = load i8*, i8** %9
%106 = getelementptr inbounds i8, i8* %105, i64 8
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = load i8*, i8** %9
%110 = getelementptr inbounds i8, i8* %109, i64 9
%111 = load i8, i8* %110
%112 = zext i8 %111 to i32
%113 = load i8*, i8** %9
%114 = getelementptr inbounds i8, i8* %113, i64 10
%115 = load i8, i8* %114
%116 = zext i8 %115 to i32
%117 = load i8*, i8** %9
%118 = getelementptr inbounds i8, i8* %117, i64 11
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %100, i32 %104, i32 %108, i32 %112, i32 %116, i32 %120)
br label %52
122: ; preds = %52
%123 = load i32, i32* %12
%124 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %123)
%125 = load i32, i32* %2
ret i32 %125
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"eth0\00"
@IFNAMSIZ = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@IFF_PROMISC = global i32 0
@SIOCSIFFLAGS = global i32 0
@.str.3 = [19 x i8] c"eth_rx_packets.txt\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [3 x i8] c"a+\00"
@.str.6 = [5 x i8] c" %d\0A\00"
@.str.7 = [51 x i8] c"Source MAC address: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@.str.8 = [56 x i8] c"Destination MAC address: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@.str.9 = [19 x i8] c"Packs received %d \00"
define i32 @socket_receive(i32 %0) {
%2 = alloca [2048 x i8]
%3 = alloca %struct.ifreq
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%5 = bitcast %struct.ifreq* %3 to i8*
%6 = load i32, i32* @PF_PACKET
%7 = load i32, i32* @SOCK_RAW
%8 = tail call i32 @socket(i32 %6, i32 %7, i32 1024)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i32, i32* @IFNAMSIZ
%15 = tail call i32 @strncpy(i32 undef, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @SIOCGIFFLAGS
%17 = call i32 @ioctl(i32 %8, i32 %16, %struct.ifreq* %3)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @close(i32 %8)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13
%24 = load i32, i32* @IFF_PROMISC
%25 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 0
%26 = load i32, i32* %25
%27 = or i32 %26, %24
store i32 %27, i32* %25
%28 = load i32, i32* @SIOCSIFFLAGS
%29 = call i32 @ioctl(i32 %8, i32 %28, %struct.ifreq* %3)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %35
31: ; preds = %23
%32 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @close(i32 %8)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %23
%36 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 @fclose(i32* %36)
%38 = icmp sgt i32 %0, 0
br i1 %38, label %39, label %87
39: ; preds = %35
%40 = bitcast [2048 x i8]* %2 to i8**
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 1
%42 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 2
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 3
%44 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 4
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 5
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 6
%47 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 7
%48 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 8
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 9
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 10
%51 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 11
br label %52
52: ; preds = %39, %52
%53 = phi i32 [ 0, %39 ], [ %55, %52 ]
%54 = call i32 @recvfrom(i32 %8, i8* %4, i32 2048, i32 0, i32* null, i32* null)
%55 = add nuw nsw i32 %53, 1
%56 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%57 = call i32 @fwrite(i8** %40, i32 1, i32 %54, i32* %56)
%58 = call i32 @fclose(i32* %56)
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %55)
%60 = load i8, i8* %4
%61 = zext i8 %60 to i32
%62 = load i8, i8* %41
%63 = zext i8 %62 to i32
%64 = load i8, i8* %42
%65 = zext i8 %64 to i32
%66 = load i8, i8* %43
%67 = zext i8 %66 to i32
%68 = load i8, i8* %44
%69 = zext i8 %68 to i32
%70 = load i8, i8* %45
%71 = zext i8 %70 to i32
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %61, i32 %63, i32 %65, i32 %67, i32 %69, i32 %71)
%73 = load i8, i8* %46
%74 = zext i8 %73 to i32
%75 = load i8, i8* %47
%76 = zext i8 %75 to i32
%77 = load i8, i8* %48
%78 = zext i8 %77 to i32
%79 = load i8, i8* %49
%80 = zext i8 %79 to i32
%81 = load i8, i8* %50
%82 = zext i8 %81 to i32
%83 = load i8, i8* %51
%84 = zext i8 %83 to i32
%85 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %74, i32 %76, i32 %78, i32 %80, i32 %82, i32 %84)
%86 = icmp eq i32 %55, %0
br i1 %86, label %87, label %52
87: ; preds = %52, %35
%88 = phi i32 [ 0, %35 ], [ %0, %52 ]
%89 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %88)
ret i32 undef
}