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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int LOG_CONS;
int LOG_PERROR;
int LOG_PID;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closelog();
int create_listenfd(char const **);
int /*<<< orphan*/ do_proxy(int, char const **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, const char **argv) {
  int srv_listenfd = -1;
  if (4 != argc) {
    fprintf(
        stderr,
        "USAGE:%s <proxy-port> <server IP> <service-port | service-name>\r\n",
        argv[0]);
    exit(EXIT_FAILURE);
  }
  openlog("proxyd", LOG_CONS | LOG_PERROR | LOG_PID, 0);
  srv_listenfd = create_listenfd(argv);
  do_proxy(srv_listenfd, argv);
  close(srv_listenfd);
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     11c5 <main+0x55>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4e(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
mov    0x2e13(%rip),%rax
or     (%rax),%esi
mov    0x2dfa(%rip),%rax
or     (%rax),%esi
lea    0xe5b(%rip),%rdi
xor    %edx,%edx
call   1070 <openlog@plt>
mov    -0x10(%rbp),%rdi
call   1040 <create_listenfd@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <do_proxy@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    11cf <main+0x5f>
mov    0x2e46(%rip),%rax
mov    0x2e5f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e44(%rip),%rax
or     (%rax),%esi
lea    0xea5(%rip),%rdi
xor    %edx,%edx
call   1070 <openlog@plt>
mov    %rbx,%rdi
call   1040 <create_listenfd@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
call   1090 <do_proxy@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe1e(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [66 x i8] c"USAGE:%s <proxy-port> <server IP> <service-port | service-name>\0D\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"proxyd\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_PID = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%7 = load i32, i32* %4
%8 = icmp ne i32 4, %7
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* @LOG_CONS
%19 = load i32, i32* @LOG_PERROR
%20 = or i32 %18, %19
%21 = load i32, i32* @LOG_PID
%22 = or i32 %20, %21
%23 = call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 0)
%24 = load i8**, i8*** %5
%25 = call i32 @create_listenfd(i8** %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i8**, i8*** %5
%28 = call i32 @do_proxy(i32 %26, i8** %27)
%29 = load i32, i32* %6
%30 = call i32 @close(i32 %29)
%31 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [66 x i8] c"USAGE:%s <proxy-port> <server IP> <service-port | service-name>\0D\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"proxyd\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_PID = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = load i32, i32* @LOG_CONS
%12 = load i32, i32* @LOG_PERROR
%13 = or i32 %12, %11
%14 = load i32, i32* @LOG_PID
%15 = or i32 %13, %14
%16 = tail call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 0)
%17 = tail call i32 @create_listenfd(i8** %1)
%18 = tail call i32 @do_proxy(i32 %17, i8** %1)
%19 = tail call i32 @close(i32 %17)
%20 = tail call i32 (...) @closelog()
ret i32 0
}