#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 stat {
  int st_mode;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int S_IFDIR;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt_long(int, char **, char *, struct option const *, int *);
int /*<<< orphan*/ help();
int /*<<< orphan*/ no_argument;
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ required_argument;
int service_socket_loop(char *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ version();
int main(int argc, char *argv[]) {
  char root_dir[255];
  int port = 80;
  int optindex, optchar, error = 0;
  struct stat root_dir_stat;
  const struct option long_options[] = {
      {"help", no_argument, NULL, 'h'},
      {"version", no_argument, NULL, 'v'},
      {"rootdir", required_argument, NULL, 'r'},
      {"port", required_argument, NULL, 'p'},
      {NULL}};
  signal(SIGPIPE, SIG_IGN);
  strcpy(root_dir, "./");
  while ((optchar = getopt_long(argc, argv, "hvr:p:", long_options,
                                &optindex)) != -1) {
    switch (optchar) {
    case 'h':
      help();
      error = -1;
      break;
    case 'v':
      version();
      error = -1;
      break;
    case 'p':
      port = atoi(optarg);
      if (port < 1 || port > 65535) {
        fprintf(stderr, "wrong port specified error!\n");
        return (-1);
      }
      break;
    case 'r':
      strncpy(root_dir, optarg, 255);
      root_dir[255 - 1] = '\0';
      error = stat(root_dir, &root_dir_stat);
      if (!error) {
        if (!(root_dir_stat.st_mode & S_IFDIR)) {
          error = -1;
        }
      }
      if (error)
        fprintf(stderr,
                "html document root directory %s does not exist or cannot be "
                "accessed error!\n",
                root_dir);
      break;
    default:
      fprintf(stderr, "input argument error!\n");
      return -1;
    }
  }
  if (!error) {
    printf("Starting Webserver at port %d and root directory %s ...\n\n", port,
           root_dir);
    error = service_socket_loop(root_dir, port);
  }
  return error;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x114(%rbp)
movl   $0x0,-0x120(%rbp)
lea    -0x1d0(%rbp),%rdi
lea    0xe41(%rip),%rax
mov    %rax,-0x1d0(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x1c8(%rbp)
movq   $0x0,-0x1c0(%rbp)
movl   $0x68,-0x1b8(%rbp)
add    $0x20,%rdi
lea    0xe10(%rip),%rax
mov    %rax,-0x1b0(%rbp)
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x1a8(%rbp)
movq   $0x0,-0x1a0(%rbp)
movl   $0x76,-0x198(%rbp)
add    $0x20,%rdi
lea    0xde2(%rip),%rax
mov    %rax,-0x190(%rbp)
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x188(%rbp)
movq   $0x0,-0x180(%rbp)
movl   $0x72,-0x178(%rbp)
add    $0x20,%rdi
lea    0xdb4(%rip),%rax
mov    %rax,-0x170(%rbp)
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x168(%rbp)
movq   $0x0,-0x160(%rbp)
movl   $0x70,-0x158(%rbp)
add    $0x20,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
call   1090 <signal@plt>
lea    -0x110(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1d0(%rbp),%rcx
lea    0xd42(%rip),%rdx
lea    -0x118(%rbp),%r8
call   1050 <getopt_long@plt>
mov    %eax,-0x11c(%rbp)
cmp    $0xffffffff,%eax
je     14ac <main+0x2ec>
mov    -0x11c(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x1d8(%rbp)
sub    $0xe,%eax
ja     1484 <main+0x2c4>
mov    -0x1d8(%rbp),%rax
lea    0xca5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10d0 <help@plt>
movl   $0xffffffff,-0x120(%rbp)
ff ff ff
jmp    14a7 <main+0x2e7>
mov    $0x0,%al
call   10c0 <version@plt>
movl   $0xffffffff,-0x120(%rbp)
ff ff ff
jmp    14a7 <main+0x2e7>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
call   10e0 <atoi@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x1,-0x114(%rbp)
jl     13c1 <main+0x201>
cmpl   $0xffff,-0x114(%rbp)
jle    13e4 <main+0x224>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f3 <main+0x333>
jmp    14a7 <main+0x2e7>
lea    -0x110(%rbp),%rdi
mov    0x2c01(%rip),%rax
mov    (%rax),%esi
mov    $0xff,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x12(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x128(%rbp),%rsi
call   10b0 <stat@plt>
mov    %eax,-0x120(%rbp)
cmpl   $0x0,-0x120(%rbp)
jne    1454 <main+0x294>
mov    -0x128(%rbp),%eax
mov    0x2b6e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    144f <main+0x28f>
movl   $0xffffffff,-0x120(%rbp)
ff ff ff
jmp    1454 <main+0x294>
cmpl   $0x0,-0x120(%rbp)
je     147f <main+0x2bf>
mov    0x2b60(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xc05(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    14a7 <main+0x2e7>
mov    0x2b3d(%rip),%rax
mov    (%rax),%edi
lea    0xc36(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14f3 <main+0x333>
jmp    1302 <main+0x142>
cmpl   $0x0,-0x120(%rbp)
jne    14ea <main+0x32a>
mov    -0x114(%rbp),%esi
lea    -0x110(%rbp),%rdx
lea    0xc14(%rip),%rdi
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   1080 <service_socket_loop@plt>
mov    %eax,-0x120(%rbp)
mov    -0x120(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe53(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%al
mov    %al,0x18(%rsp)
movq   $0x0,0x20(%rsp)
movl   $0x68,0x28(%rsp)
lea    0xe2e(%rip),%rcx
mov    %rcx,0x30(%rsp)
mov    %al,0x38(%rsp)
movq   $0x0,0x40(%rsp)
movl   $0x76,0x48(%rsp)
lea    0xe15(%rip),%rax
mov    %rax,0x50(%rsp)
mov    0x2db4(%rip),%rax
mov    (%rax),%al
mov    %al,0x58(%rsp)
movq   $0x0,0x60(%rsp)
movl   $0x72,0x68(%rsp)
lea    0xdf3(%rip),%rcx
mov    %rcx,0x70(%rsp)
mov    %al,0x78(%rsp)
movq   $0x0,0x80(%rsp)
movl   $0x70,0x88(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
call   1080 <signal@plt>
lea    0xda7(%rip),%rsi
lea    0xb0(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xd96(%rip),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <getopt_long@plt>
mov    $0x50,%ebx
cmp    $0xffffffff,%eax
je     13f7 <main+0x247>
lea    0xd30(%rip),%r12
lea    0xb0(%rsp),%r13
xor    %r15d,%r15d
jmp    1319 <main+0x169>
nopl   (%rax)
xor    %eax,%eax
call   10c0 <help@plt>
mov    $0xffffffff,%r15d
mov    %ebp,%edi
mov    %r14,%rsi
lea    0xd44(%rip),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <getopt_long@plt>
cmp    $0xffffffff,%eax
lea    0xb0(%rsp),%r13
je     13f2 <main+0x242>
add    $0xffffff98,%eax
ror    %eax
cmp    $0x7,%eax
ja     141f <main+0x26f>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
call   10d0 <atoi@plt>
mov    %eax,%ebx
add    $0xffff0000,%eax
cmp    $0xffff0000,%eax
ja     12ed <main+0x13d>
jmp    1431 <main+0x281>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2c91(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
mov    $0xff,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x1ae(%rsp)
mov    %r13,%rdi
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
mov    %eax,%r15d
test   %eax,%eax
je     13cc <main+0x21c>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
lea    0xcbf(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    12ed <main+0x13d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <version@plt>
jmp    12e7 <main+0x137>
mov    0x2bd5(%rip),%rax
mov    (%rax),%eax
xor    %r15d,%r15d
test   %eax,0x8(%rsp)
jne    12ed <main+0x13d>
mov    $0xffffffff,%r15d
lea    0xb0(%rsp),%r13
jmp    1392 <main+0x1e2>
test   %r15d,%r15d
jne    144e <main+0x29e>
lea    0xcc7(%rip),%rdi
lea    0xb0(%rsp),%rbp
mov    %ebx,%esi
mov    %rbp,%rdx
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1070 <service_socket_loop@plt>
mov    %eax,%r15d
jmp    144e <main+0x29e>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
lea    0xc7f(%rip),%rsi
jmp    1441 <main+0x291>
mov    0x2b90(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [8 x i8] c"rootdir\00"
@required_argument = global i32 0
@.str.3 = [5 x i8] c"port\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str.4 = [3 x i8] c"./\00"
@.str.5 = [7 x i8] c"hvr:p:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.6 = [29 x i8] c"wrong port specified error!\0A\00"
@S_IFDIR = global i32 0
@.str.7 = [77 x i8] c"html document root directory %s does not exist or cannot be accessed error!\0A\00"
@.str.8 = [23 x i8] c"input argument error!\0A\00"
@.str.9 = [58 x i8] c"Starting Webserver at port %d and root directory %s ...\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.stat
%12 = alloca [5 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 80, i32* %7
store i32 0, i32* %10
%13 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %12, i64 0, i64 0
%14 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 1
%16 = load i32, i32* @no_argument
%17 = trunc i32 %16 to i8
store i8 %17, i8* %15
%18 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 2
store i32* null, i32** %18
%19 = getelementptr inbounds %struct.option, %struct.option* %13, i32 0, i32 3
store i32 104, i32* %19
%20 = getelementptr inbounds %struct.option, %struct.option* %13, i64 1
%21 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 1
%23 = load i32, i32* @no_argument
%24 = trunc i32 %23 to i8
store i8 %24, i8* %22
%25 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 2
store i32* null, i32** %25
%26 = getelementptr inbounds %struct.option, %struct.option* %20, i32 0, i32 3
store i32 118, i32* %26
%27 = getelementptr inbounds %struct.option, %struct.option* %20, i64 1
%28 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 1
%30 = load i32, i32* @required_argument
%31 = trunc i32 %30 to i8
store i8 %31, i8* %29
%32 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 2
store i32* null, i32** %32
%33 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 3
store i32 114, i32* %33
%34 = getelementptr inbounds %struct.option, %struct.option* %27, i64 1
%35 = getelementptr inbounds %struct.option, %struct.option* %34, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %35
%36 = getelementptr inbounds %struct.option, %struct.option* %34, i32 0, i32 1
%37 = load i32, i32* @required_argument
%38 = trunc i32 %37 to i8
store i8 %38, i8* %36
%39 = getelementptr inbounds %struct.option, %struct.option* %34, i32 0, i32 2
store i32* null, i32** %39
%40 = getelementptr inbounds %struct.option, %struct.option* %34, i32 0, i32 3
store i32 112, i32* %40
%41 = getelementptr inbounds %struct.option, %struct.option* %34, i64 1
%42 = bitcast %struct.option* %41 to i8*
%43 = load i32, i32* @SIGPIPE
%44 = load i32, i32* @SIG_IGN
%45 = call i32 @signal(i32 %43, i32 %44)
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %100, %2
%49 = load i32, i32* %4
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %12, i64 0, i64 0
%52 = call i32 @getopt_long(i32 %49, i8** %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.option* %51, i32* %8)
store i32 %52, i32* %9
%53 = icmp ne i32 %52, -1
br i1 %53, label %54, label %101
54: ; preds = %48
%55 = load i32, i32* %9
switch i32 %55, label %97 [
i32 104, label %56
i32 118, label %58
i32 112, label %60
i32 114, label %72
]
56: ; preds = %54
%57 = call i32 (...) @help()
store i32 -1, i32* %10
br label %100
58: ; preds = %54
%59 = call i32 (...) @version()
store i32 -1, i32* %10
br label %100
60: ; preds = %54
%61 = load i32, i32* @optarg
%62 = call i32 @atoi(i32 %61)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = icmp slt i32 %63, 1
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = load i32, i32* %7
%67 = icmp sgt i32 %66, 65535
br i1 %67, label %68, label %71
68: ; preds = %65, %60
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %113
71: ; preds = %65
br label %100
72: ; preds = %54
%73 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%74 = load i32, i32* @optarg
%75 = call i32 @strncpy(i8* %73, i32 %74, i32 255)
%76 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 254
store i8 0, i8* %76
%77 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%78 = call i32 @stat(i8* %77, %struct.stat* %11)
store i32 %78, i32* %10
%79 = load i32, i32* %10
%80 = icmp ne i32 %79, 0
br i1 %80, label %89, label %81
81: ; preds = %72
%82 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%83 = load i32, i32* %82
%84 = load i32, i32* @S_IFDIR
%85 = and i32 %83, %84
%86 = icmp ne i32 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %81
store i32 -1, i32* %10
br label %88
88: ; preds = %87, %81
br label %89
89: ; preds = %88, %72
%90 = load i32, i32* %10
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = load i32, i32* @stderr
%94 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.7, i64 0, i64 0), i8* %94)
br label %96
96: ; preds = %92, %89
br label %100
97: ; preds = %54
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %113
100: ; preds = %96, %71, %58, %56
br label %48
101: ; preds = %48
%102 = load i32, i32* %10
%103 = icmp ne i32 %102, 0
br i1 %103, label %111, label %104
104: ; preds = %101
%105 = load i32, i32* %7
%106 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%107 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i32 %105, i8* %106)
%108 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%109 = load i32, i32* %7
%110 = call i32 @service_socket_loop(i8* %108, i32 %109)
store i32 %110, i32* %10
br label %111
111: ; preds = %104, %101
%112 = load i32, i32* %10
store i32 %112, i32* %3
br label %113
113: ; preds = %111, %97, %68
%114 = load i32, i32* %3
ret i32 %114
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [8 x i8] c"rootdir\00"
@required_argument = global i32 0
@.str.3 = [5 x i8] c"port\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str.4 = [3 x i8] c"./\00"
@.str.5 = [7 x i8] c"hvr:p:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.6 = [29 x i8] c"wrong port specified error!\0A\00"
@S_IFDIR = global i32 0
@.str.7 = [77 x i8] c"html document root directory %s does not exist or cannot be accessed error!\0A\00"
@.str.8 = [23 x i8] c"input argument error!\0A\00"
@.str.9 = [58 x i8] c"Starting Webserver at port %d and root directory %s ...\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [255 x i8]
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca [5 x %struct.option]
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
%9 = bitcast %struct.stat* %5 to i8*
%10 = bitcast [5 x %struct.option]* %6 to i8*
%11 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0
%12 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0, i32 1
%14 = load i32, i32* @no_argument
%15 = trunc i32 %14 to i8
store i8 %15, i8* %13
%16 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0, i32 2
store i32* null, i32** %16
%17 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 0, i32 3
store i32 104, i32* %17
%18 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 1, i32 1
store i8 %15, i8* %19
%20 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 1, i32 2
store i32* null, i32** %20
%21 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 1, i32 3
store i32 118, i32* %21
%22 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 2, i32 1
%24 = load i32, i32* @required_argument
%25 = trunc i32 %24 to i8
store i8 %25, i8* %23
%26 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 2, i32 2
store i32* null, i32** %26
%27 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 2, i32 3
store i32 114, i32* %27
%28 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 3, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 3, i32 1
store i8 %25, i8* %29
%30 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 3, i32 2
store i32* null, i32** %30
%31 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 3, i32 3
store i32 112, i32* %31
%32 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %6, i64 0, i64 4
%33 = bitcast %struct.option* %32 to i8*
%34 = load i32, i32* @SIGPIPE
%35 = load i32, i32* @SIG_IGN
%36 = tail call i32 @signal(i32 %34, i32 %35)
%37 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.option* %11, i32* %4)
%39 = icmp eq i32 %38, -1
br i1 %39, label %85, label %40
40: ; preds = %2
%41 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 254
%42 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %43
43: ; preds = %40, %78
%44 = phi i32 [ %38, %40 ], [ %81, %78 ]
%45 = phi i32 [ 0, %40 ], [ %80, %78 ]
%46 = phi i32 [ 80, %40 ], [ %79, %78 ]
%47 = add i32 %44, -104
%48 = call i32 @llvm.fshl.i32(i32 %47, i32 %47, i32 31)
switch i32 %48, label %75 [
i32 0, label %49
i32 7, label %51
i32 4, label %53
i32 5, label %61
]
49: ; preds = %43
%50 = call i32 (...) @help()
br label %78
51: ; preds = %43
%52 = call i32 (...) @version()
br label %78
53: ; preds = %43
%54 = load i32, i32* @optarg
%55 = call i32 @atoi(i32 %54)
%56 = add i32 %55, -65536
%57 = icmp ult i32 %56, -65535
br i1 %57, label %58, label %78
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %89
61: ; preds = %43
%62 = load i32, i32* @optarg
%63 = call i32 @strncpy(i8* %7, i32 %62, i32 255)
store i8 0, i8* %41
%64 = call i32 @stat(i8* %7, %struct.stat* %5)
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %61
%67 = load i32, i32* %42
%68 = load i32, i32* @S_IFDIR
%69 = and i32 %68, %67
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %66, %61
%72 = phi i32 [ %64, %61 ], [ -1, %66 ]
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.7, i64 0, i64 0), i8* %7)
br label %78
75: ; preds = %43
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %89
78: ; preds = %66, %71, %53, %51, %49
%79 = phi i32 [ %46, %71 ], [ %55, %53 ], [ %46, %51 ], [ %46, %49 ], [ %46, %66 ]
%80 = phi i32 [ %72, %71 ], [ %45, %53 ], [ -1, %51 ], [ -1, %49 ], [ 0, %66 ]
%81 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.option* %11, i32* %4)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %43
83: ; preds = %78
%84 = icmp eq i32 %80, 0
br i1 %84, label %85, label %89
85: ; preds = %2, %83
%86 = phi i32 [ %79, %83 ], [ 80, %2 ]
%87 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0), i32 %86, i8* %7)
%88 = call i32 @service_socket_loop(i8* %7, i32 %86)
br label %89
89: ; preds = %83, %85, %75, %58
%90 = phi i32 [ -1, %75 ], [ -1, %58 ], [ %80, %83 ], [ %88, %85 ]
ret i32 %90
}