#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 UdpSocket {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_rtp_frame(struct UdpSocket *);
int udp_read(struct UdpSocket *, unsigned char *, int);
struct UdpSocket *udp_socket(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  printf("Starting video test program!\n");
  struct UdpSocket *sock;
  sock = udp_socket("192.168.209.34", 5000, 5001, 0);
  long cnt = 0;
  while (1) {
    printf("Aquiring image %ld...\n", cnt);
    cnt++;
    test_rtp_frame(sock);
    unsigned char buff[128];
    int len = udp_read(sock, buff, 128);
    if (len > 0)
      printf("read %d\n", len);
    usleep(20000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x1388,%esi
mov    $0x1389,%edx
xor    %ecx,%ecx
call   1060 <udp_socket@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <test_rtp_frame@plt>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1050 <udp_read@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jle    11fe <main+0xae>
mov    -0xa4(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x4e20,%edi
call   1070 <usleep@plt>
jmp    119b <main+0x4b>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7d(%rip),%rdi
mov    $0x1388,%esi
mov    $0x1389,%edx
xor    %ecx,%ecx
call   1070 <udp_socket@plt>
mov    %rax,%r13
lea    0xe71(%rip),%r14
mov    %rsp,%r15
lea    0xe7e(%rip),%r12
xor    %ebx,%ebx
jmp    11be <main+0x5e>
nopl   0x0(%rax)
mov    $0x4e20,%edi
call   1080 <usleep@plt>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <test_rtp_frame@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x80,%edx
call   1060 <udp_read@plt>
test   %eax,%eax
jle    11b0 <main+0x50>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x50>

LLVM IR (-O0):
%struct.UdpSocket = type { i32 }
@.str = [30 x i8] c"Starting video test program!\0A\00"
@.str.1 = [15 x i8] c"192.168.209.34\00"
@.str.2 = [23 x i8] c"Aquiring image %ld...\0A\00"
@.str.3 = [9 x i8] c"read %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.UdpSocket*
%7 = alloca i64
%8 = alloca [128 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%11 = call %struct.UdpSocket* @udp_socket(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 5000, i32 5001, i32 0)
store %struct.UdpSocket* %11, %struct.UdpSocket** %6
store i64 0, i64* %7
br label %12
12: ; preds = %2, %27
%13 = load i64, i64* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 %13)
%15 = load i64, i64* %7
%16 = add nsw i64 %15, 1
store i64 %16, i64* %7
%17 = load %struct.UdpSocket*, %struct.UdpSocket** %6
%18 = call i32 @test_rtp_frame(%struct.UdpSocket* %17)
%19 = load %struct.UdpSocket*, %struct.UdpSocket** %6
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%21 = call i32 @udp_read(%struct.UdpSocket* %19, i8* %20, i32 128)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = load i32, i32* %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %12
%28 = call i32 @usleep(i32 20000)
br label %12
}

LLVM IR (-O2):
%struct.UdpSocket = type { i32 }
@.str.1 = [15 x i8] c"192.168.209.34\00"
@.str.2 = [23 x i8] c"Aquiring image %ld...\0A\00"
@.str.3 = [9 x i8] c"read %d\0A\00"
@str = [29 x i8] c"Starting video test program!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%5 = tail call %struct.UdpSocket* @udp_socket(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 5000, i32 5001, i32 0)
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %16, %2
%8 = phi i64 [ 0, %2 ], [ %10, %16 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 %8)
%10 = add nuw nsw i64 %8, 1
%11 = call i32 @test_rtp_frame(%struct.UdpSocket* %5)
%12 = call i32 @udp_read(%struct.UdpSocket* %5, i8* %6, i32 128)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %12)
br label %16
16: ; preds = %14, %7
%17 = call i32 @usleep(i32 20000)
br label %7
}