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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dumprtp(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int makeclientsocket(char *, int, int, struct sockaddr_in *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct sockaddr_in si;
  int socketIn;
  char *ip;
  int port;
  fprintf(stderr, "Rtp dump\n");
  if (argc == 1) {
    ip = "224.0.1.2";
    port = 5004;
  } else if (argc == 3) {
    ip = argv[1];
    port = atoi(argv[2]);
  } else {
    fprintf(stderr, "Usage %s ip port\n", argv[0]);
    exit(1);
  }
  fprintf(stderr, "Using %s:%d\n", ip, port);
  socketIn = makeclientsocket(ip, port, 2, &si);
  dumprtp(socketIn);
  close(socketIn);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11ae <main+0x4e>
lea    0xe6c(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x138c,-0x2c(%rbp)
jmp    1206 <main+0xa6>
cmpl   $0x3,-0x8(%rbp)
jne    11d9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1201 <main+0xa1>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1206 <main+0xa6>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    $0x2,%edx
lea    -0x18(%rbp),%rcx
call   1050 <makeclientsocket@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <dumprtp@plt>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x2e6c(%rip),%r14
mov    (%r14),%edi
lea    0xe82(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x1,%ebx
je     11a0 <main+0x40>
cmp    $0x3,%ebx
jne    11f1 <main+0x91>
mov    0x8(%rbp),%rbx
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
jmp    11ac <main+0x4c>
mov    $0x138c,%ebp
lea    0xe5e(%rip),%rbx
mov    (%r14),%edi
lea    0xe70(%rip),%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1050 <makeclientsocket@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <dumprtp@plt>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%r14),%edi
mov    0x0(%rbp),%rdx
lea    0xe15(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"Rtp dump\0A\00"
@.str.1 = [10 x i8] c"224.0.1.2\00"
@.str.2 = [18 x i8] c"Usage %s ip port\0A\00"
@.str.3 = [13 x i8] c"Using %s:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i32 5004, i32* %9
br label %34
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %9
br label %33
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %18
br label %34
34: ; preds = %33, %14
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %8
%37 = load i32, i32* %9
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %36, i32 %37)
%39 = load i8*, i8** %8
%40 = load i32, i32* %9
%41 = call i32 @makeclientsocket(i8* %39, i32 %40, i32 2, %struct.sockaddr_in* %6)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = call i32 @dumprtp(i32 %42)
%44 = load i32, i32* %7
%45 = call i32 @close(i32 %44)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"Rtp dump\0A\00"
@.str.1 = [10 x i8] c"224.0.1.2\00"
@.str.2 = [18 x i8] c"Usage %s ip port\0A\00"
@.str.3 = [13 x i8] c"Using %s:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %13 [
i32 1, label %18
i32 3, label %7
]
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2, %7
%19 = phi i8* [ %9, %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ]
%20 = phi i32 [ %12, %7 ], [ 5004, %2 ]
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %20)
%23 = call i32 @makeclientsocket(i8* %19, i32 %20, i32 2, %struct.sockaddr_in* %3)
%24 = call i32 @dumprtp(i32 %23)
%25 = call i32 @close(i32 %23)
ret i32 0
}