#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 /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EADDRINUSE;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int X_TCP_PORT;
int abs(int /*<<< orphan*/);
int /*<<< orphan*/ atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
char *strerror(scalar_t__);
int /*<<< orphan*/ usage(char *);
main(int argc, char **argv) {
  int ret = 1;
  int sockfd;
  struct sockaddr_in addr;
  int xpval = -1;
  int xpmin = 0;
  int xplim = 100;
  char *exe = argv[0];
  int go = 1;
  int i;
  if (argc == 1)
    xpval = xpmin;
  else
    for (i = 1, go = 1; (i < argc) && (go); i++) {
      if (!strcmp(argv[i], "-h")) {
        usage(exe);
        ret = 2;
        go = 0;
      } else if (xpval == -1) {
        xpval = abs(atoi(argv[i]));
        if ((xpval == 0) && (strcmp(argv[i], "0"))) {
          usage(exe);
          ret = 1;
          go = 0;
        }
      } else {
        usage(exe);
        ret = 1;
        go = 0;
      }
    }
  if (!go)
    return ret;
  if ((xpval > xplim) || (xpval < xpmin)) {
    fprintf(stderr, "%s: ERROR: Server number out of range (%d -> %d): %d.\n",
            exe, xpmin, xplim, xpval);
    return ret;
  }
  xpval += X_TCP_PORT;
  xplim += X_TCP_PORT;
  xpmin += X_TCP_PORT;
  if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
    fprintf(stderr, "%s: ERROR: Cannot create socket: %s\n", exe,
            strerror(errno));
  else {
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    for (go = 1; go; xpval++) {
      addr.sin_port = htons(xpval);
      if (bind(sockfd, (struct sockaddr *)(&addr), sizeof(addr)) == 0)
        break;
      if (xpval > xplim) {
        fprintf(stderr, "%s: ERROR: All ports in use.\n", exe);
        go = 0;
      } else if (errno != EADDRINUSE) {
        fprintf(stderr, "%s: ERROR: Cannot bind: %s.\n", exe, strerror(errno));
        go = 0;
      }
    }
    (void)close(sockfd);
    if (go) {
      fprintf(stdout, "%d\n", xpval - X_TCP_PORT);
      ret = 0;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x64,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1209 <main+0x59>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1321 <main+0x171>
movl   $0x1,-0x40(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x40(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x41(%rbp)
jge    1232 <main+0x82>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1242 <main+0x92>
jmp    131c <main+0x16c>
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdab(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1280 <main+0xd0>
mov    -0x38(%rbp),%rdi
call   1090 <usage@plt>
movl   $0x2,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1309 <main+0x159>
cmpl   $0xffffffff,-0x24(%rbp)
jne    12ed <main+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1030 <abs@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    12e8 <main+0x138>
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd41(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12e8 <main+0x138>
mov    -0x38(%rbp),%rdi
call   1090 <usage@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1304 <main+0x154>
mov    -0x38(%rbp),%rdi
call   1090 <usage@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    1309 <main+0x159>
jmp    130e <main+0x15e>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1217 <main+0x67>
jmp    1321 <main+0x171>
cmpl   $0x0,-0x3c(%rbp)
jne    1336 <main+0x186>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1557 <main+0x3a7>
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     134e <main+0x19e>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    137f <main+0x1cf>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xc98(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1557 <main+0x3a7>
mov    0x2c2a(%rip),%rax
mov    (%rax),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2c1b(%rip),%rax
mov    (%rax),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
mov    0x2c14(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1411 <main+0x261>
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2bd4(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xc37(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1551 <main+0x3a1>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    0x2bc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1510 <main+0x360>
mov    -0x24(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <bind@plt>
cmp    $0x0,%rax
jne    1469 <main+0x2b9>
jmp    1510 <main+0x360>
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    149c <main+0x2ec>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xbd8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
jmp    14fd <main+0x34d>
mov    0x2b1d(%rip),%rax
mov    (%rax),%rax
mov    0x2b1b(%rip),%rcx
cmp    (%rcx),%rax
je     14f8 <main+0x348>
mov    0x2b1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2aef(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rdx
mov    %rax,%rcx
lea    0xb95(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
jmp    14fd <main+0x34d>
jmp    1502 <main+0x352>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1434 <main+0x284>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x3c(%rbp)
je     154c <main+0x39c>
mov    0x2a7f(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    0x2a7b(%rip),%rax
sub    (%rax),%edx
lea    0xb5e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
jmp    1551 <main+0x3a1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    (%rsi),%r14
xor    %ebp,%ebp
cmp    $0x1,%edi
jne    12b7 <main+0x117>
mov    0x2ded(%rip),%rax
mov    (%rax),%r13d
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1358 <main+0x1b8>
mov    %eax,%ebx
add    %r13d,%ebp
lea    0x10(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x8,%edx
call   1090 <bind@plt>
test   %rax,%rax
je     1287 <main+0xe7>
mov    %r14,0x8(%rsp)
add    $0x64,%r13d
mov    0x2d83(%rip),%r14
mov    0x2d84(%rip),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax)
cmp    %r13d,%ebp
jg     1390 <main+0x1f0>
mov    (%r14),%rdi
cmp    (%r15),%rdi
jne    13ae <main+0x20e>
add    $0x1,%ebp
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x8,%edx
call   1090 <bind@plt>
test   %rax,%rax
jne    1250 <main+0xb0>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
mov    0x2d12(%rip),%rax
sub    (%rax),%ebp
lea    0xdf5(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
jmp    142b <main+0x28b>
mov    $0xffffffff,%ebp
jle    13f0 <main+0x250>
mov    %rsi,%r13
mov    %r14,0x8(%rsp)
mov    %edi,%r12d
mov    $0xffffffff,%ebp
mov    $0x1,%r14d
lea    0xd21(%rip),%r15
jmp    12fd <main+0x15d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r12,%r14
jae    13e2 <main+0x242>
mov    0x0(%r13,%r14,8),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     141c <main+0x27c>
cmp    $0xffffffff,%ebp
jne    1344 <main+0x1a4>
mov    0x0(%r13,%r14,8),%rbx
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
neg    %ebp
cmovs  %eax,%ebp
jb     12f0 <main+0x150>
mov    %rbx,%rdi
lea    0xccb(%rip),%rsi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12f0 <main+0x150>
mov    0x8(%rsp),%rdi
call   1080 <usage@plt>
mov    $0x1,%eax
jmp    142b <main+0x28b>
mov    0x2c79(%rip),%rax
mov    (%rax),%ebx
mov    0x2c58(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
lea    0xcc5(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    142b <main+0x28b>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
lea    0xcc1(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13d4 <main+0x234>
mov    0x2c23(%rip),%rax
mov    (%rax),%ebp
call   10b0 <strerror@plt>
lea    0xcbc(%rip),%rsi
mov    %ebp,%edi
mov    0x8(%rsp),%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    $0x1,%eax
jmp    142b <main+0x28b>
cmp    $0x65,%ebp
mov    0x8(%rsp),%r14
jb     11bc <main+0x1c>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xc05(%rip),%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    $0x64,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    142b <main+0x28b>
mov    0x8(%rsp),%rdi
call   1080 <usage@plt>
mov    $0x2,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"%s: ERROR: Server number out of range (%d -> %d): %d.\0A\00"
@X_TCP_PORT = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [37 x i8] c"%s: ERROR: Cannot create socket: %s\0A\00"
@errno = global i64 0
@AF_INET = global i32 0
@.str.4 = [30 x i8] c"%s: ERROR: All ports in use.\0A\00"
@EADDRINUSE = global i64 0
@.str.5 = [29 x i8] c"%s: ERROR: Cannot bind: %s.\0A\00"
@stdout = global i32 0
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 -1, i32* %9
store i32 0, i32* %10
store i32 100, i32* %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
store i8* %17, i8** %12
store i32 1, i32* %13
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = load i32, i32* %10
store i32 %21, i32* %9
br label %77
22: ; preds = %2
store i32 1, i32* %14
store i32 1, i32* %13
br label %23
23: ; preds = %73, %22
%24 = load i32, i32* %14
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %13
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %27, %23
%31 = phi i1 [ false, %23 ], [ %29, %27 ]
br i1 %31, label %32, label %76
32: ; preds = %30
%33 = load i8**, i8*** %5
%34 = load i32, i32* %14
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %32
%41 = load i8*, i8** %12
%42 = call i32 @usage(i8* %41)
store i32 2, i32* %6
store i32 0, i32* %13
br label %72
43: ; preds = %32
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %68
46: ; preds = %43
%47 = load i8**, i8*** %5
%48 = load i32, i32* %14
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
%53 = call i32 @abs(i32 %52)
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %46
%57 = load i8**, i8*** %5
%58 = load i32, i32* %14
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %56
%65 = load i8*, i8** %12
%66 = call i32 @usage(i8* %65)
store i32 1, i32* %6
store i32 0, i32* %13
br label %67
67: ; preds = %64, %56, %46
br label %71
68: ; preds = %43
%69 = load i8*, i8** %12
%70 = call i32 @usage(i8* %69)
store i32 1, i32* %6
store i32 0, i32* %13
br label %71
71: ; preds = %68, %67
br label %72
72: ; preds = %71, %40
br label %73
73: ; preds = %72
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
br label %23
76: ; preds = %30
br label %77
77: ; preds = %76, %20
%78 = load i32, i32* %13
%79 = icmp ne i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %77
%81 = load i32, i32* %6
store i32 %81, i32* %3
br label %171
82: ; preds = %77
%83 = load i32, i32* %9
%84 = load i32, i32* %11
%85 = icmp sgt i32 %83, %84
br i1 %85, label %90, label %86
86: ; preds = %82
%87 = load i32, i32* %9
%88 = load i32, i32* %10
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %98
90: ; preds = %86, %82
%91 = load i32, i32* @stderr
%92 = load i8*, i8** %12
%93 = load i32, i32* %10
%94 = load i32, i32* %11
%95 = load i32, i32* %9
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %92, i32 %93, i32 %94, i32 %95)
%97 = load i32, i32* %6
store i32 %97, i32* %3
br label %171
98: ; preds = %86
%99 = load i32, i32* @X_TCP_PORT
%100 = load i32, i32* %9
%101 = add nsw i32 %100, %99
store i32 %101, i32* %9
%102 = load i32, i32* @X_TCP_PORT
%103 = load i32, i32* %11
%104 = add nsw i32 %103, %102
store i32 %104, i32* %11
%105 = load i32, i32* @X_TCP_PORT
%106 = load i32, i32* %10
%107 = add nsw i32 %106, %105
store i32 %107, i32* %10
%108 = load i32, i32* @PF_INET
%109 = load i32, i32* @SOCK_STREAM
%110 = call i32 @socket(i32 %108, i32 %109, i32 0)
store i32 %110, i32* %7
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %118
112: ; preds = %98
%113 = load i32, i32* @stderr
%114 = load i8*, i8** %12
%115 = load i64, i64* @errno
%116 = call i8* @strerror(i64 %115)
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %114, i8* %116)
br label %169
118: ; preds = %98
%119 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 8)
%120 = load i32, i32* @AF_INET
%121 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %120, i32* %121
store i32 1, i32* %13
br label %122
122: ; preds = %154, %118
%123 = load i32, i32* %13
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %157
125: ; preds = %122
%126 = load i32, i32* %9
%127 = call i32 @htons(i32 %126)
%128 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %127, i32* %128
%129 = load i32, i32* %7
%130 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%131 = call i64 @bind(i32 %129, %struct.sockaddr* %130, i32 8)
%132 = icmp eq i64 %131, 0
br i1 %132, label %133, label %134
133: ; preds = %125
br label %157
134: ; preds = %125
%135 = load i32, i32* %9
%136 = load i32, i32* %11
%137 = icmp sgt i32 %135, %136
br i1 %137, label %138, label %142
138: ; preds = %134
%139 = load i32, i32* @stderr
%140 = load i8*, i8** %12
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %140)
store i32 0, i32* %13
br label %153
142: ; preds = %134
%143 = load i64, i64* @errno
%144 = load i64, i64* @EADDRINUSE
%145 = icmp ne i64 %143, %144
br i1 %145, label %146, label %152
146: ; preds = %142
%147 = load i32, i32* @stderr
%148 = load i8*, i8** %12
%149 = load i64, i64* @errno
%150 = call i8* @strerror(i64 %149)
%151 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %148, i8* %150)
store i32 0, i32* %13
br label %152
152: ; preds = %146, %142
br label %153
153: ; preds = %152, %138
br label %154
154: ; preds = %153
%155 = load i32, i32* %9
%156 = add nsw i32 %155, 1
store i32 %156, i32* %9
br label %122
157: ; preds = %133, %122
%158 = load i32, i32* %7
%159 = call i32 @close(i32 %158)
%160 = load i32, i32* %13
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %168
162: ; preds = %157
%163 = load i32, i32* @stdout
%164 = load i32, i32* %9
%165 = load i32, i32* @X_TCP_PORT
%166 = sub nsw i32 %164, %165
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %166)
store i32 0, i32* %6
br label %168
168: ; preds = %162, %157
br label %169
169: ; preds = %168, %112
%170 = load i32, i32* %6
store i32 %170, i32* %3
br label %171
171: ; preds = %169, %90, %80
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"%s: ERROR: Server number out of range (%d -> %d): %d.\0A\00"
@X_TCP_PORT = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [37 x i8] c"%s: ERROR: Cannot create socket: %s\0A\00"
@errno = global i64 0
@AF_INET = global i32 0
@.str.4 = [30 x i8] c"%s: ERROR: All ports in use.\0A\00"
@EADDRINUSE = global i64 0
@.str.5 = [29 x i8] c"%s: ERROR: Cannot bind: %s.\0A\00"
@stdout = global i32 0
@.str.6 = [4 x i8] c"%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 i8*, i8** %1
%6 = icmp eq i32 %0, 1
br i1 %6, label %44, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %40
9: ; preds = %7
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %34
%12 = phi i64 [ 1, %9 ], [ %36, %34 ]
%13 = phi i32 [ -1, %9 ], [ %35, %34 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @usage(i8* %5)
br label %95
20: ; preds = %11
%21 = icmp eq i32 %13, -1
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = load i8*, i8** %14
%24 = tail call i32 @atoi(i8* %23)
%25 = tail call i32 @llvm.abs.i32(i32 %24, i1 true)
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = tail call i32 @usage(i8* %5)
br label %95
32: ; preds = %20
%33 = tail call i32 @usage(i8* %5)
br label %95
34: ; preds = %22, %27
%35 = phi i32 [ 0, %27 ], [ %25, %22 ]
%36 = add nuw nsw i64 %12, 1
%37 = icmp ult i64 %36, %10
br i1 %37, label %11, label %38
38: ; preds = %34
%39 = icmp ugt i32 %35, 100
br i1 %39, label %40, label %44
40: ; preds = %7, %38
%41 = phi i32 [ %35, %38 ], [ -1, %7 ]
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 0, i32 100, i32 %41)
br label %95
44: ; preds = %2, %38
%45 = phi i32 [ %35, %38 ], [ 0, %2 ]
%46 = load i32, i32* @X_TCP_PORT
%47 = add nsw i32 %46, 100
%48 = load i32, i32* @PF_INET
%49 = load i32, i32* @SOCK_STREAM
%50 = tail call i32 @socket(i32 %48, i32 %49, i32 0)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %57
52: ; preds = %44
%53 = load i32, i32* @stderr
%54 = load i64, i64* @errno
%55 = tail call i8* @strerror(i64 %54)
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %55)
br label %95
57: ; preds = %44
%58 = add nsw i32 %46, %45
%59 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 8)
%60 = load i32, i32* @AF_INET
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %60, i32* %61
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%63 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%64 = call i32 @htons(i32 %58)
store i32 %64, i32* %62
%65 = call i64 @bind(i32 %50, %struct.sockaddr* %63, i32 8)
%66 = icmp eq i64 %65, 0
br i1 %66, label %86, label %67
67: ; preds = %57, %81
%68 = phi i32 [ %82, %81 ], [ %58, %57 ]
%69 = icmp sgt i32 %68, %47
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %93
73: ; preds = %67
%74 = load i64, i64* @errno
%75 = load i64, i64* @EADDRINUSE
%76 = icmp eq i64 %74, %75
br i1 %76, label %81, label %77
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i8* @strerror(i64 %74)
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %79)
br label %93
81: ; preds = %73
%82 = add nsw i32 %68, 1
%83 = call i32 @htons(i32 %82)
store i32 %83, i32* %62
%84 = call i64 @bind(i32 %50, %struct.sockaddr* %63, i32 8)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %67
86: ; preds = %81, %57
%87 = phi i32 [ %58, %57 ], [ %82, %81 ]
%88 = call i32 @close(i32 %50)
%89 = load i32, i32* @stdout
%90 = load i32, i32* @X_TCP_PORT
%91 = sub nsw i32 %87, %90
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %91)
br label %95
93: ; preds = %70, %77
%94 = call i32 @close(i32 %50)
br label %95
95: ; preds = %18, %32, %30, %52, %86, %93, %40
%96 = phi i32 [ 1, %40 ], [ 1, %52 ], [ 0, %86 ], [ 1, %93 ], [ 2, %18 ], [ 1, %32 ], [ 1, %30 ]
ret i32 %96
}