#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*/ prg_cache_clear();
char *prg_cache_get(int);
int /*<<< orphan*/ prg_cache_load();
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char **argv) {
  int i;
  char *cmdline;
  prg_cache_load();
  for (i = 1; i < 65535; i++) {
    cmdline = prg_cache_get(i);
    if (*cmdline != '-')
      printf("port:[%d], cmdline:[%s]\n", i, cmdline);
  }
  printf("over======PORT_MAX:%d=\n", 65535);
  prg_cache_clear();
  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)
mov    $0x0,%al
call   1060 <prg_cache_load@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xffff,-0x14(%rbp)
jge    11b5 <main+0x75>
mov    -0x14(%rbp),%edi
call   1030 <prg_cache_get@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11a2 <main+0x62>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11a7 <main+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x24>
lea    0xe5d(%rip),%rdi
mov    $0xffff,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <prg_cache_clear@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <prg_cache_load@plt>
mov    $0x1,%ebx
lea    0xea9(%rip),%r14
jmp    116b <main+0x2b>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0xffff,%ebx
je     1188 <main+0x48>
mov    %ebx,%edi
call   1030 <prg_cache_get@plt>
cmpb   $0x2d,(%rax)
je     1160 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1160 <main+0x20>
lea    0xe8a(%rip),%rdi
mov    $0xffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <prg_cache_clear@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"port:[%d], cmdline:[%s]\0A\00"
@.str.1 = [24 x i8] c"over======PORT_MAX:%d=\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @prg_cache_load()
store i32 1, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 65535
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load i32, i32* %6
%14 = call i8* @prg_cache_get(i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 45
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i32, i32* %6
%21 = load i8*, i8** %7
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %21)
br label %23
23: ; preds = %19, %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 65535)
%29 = call i32 (...) @prg_cache_clear()
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"port:[%d], cmdline:[%s]\0A\00"
@.str.1 = [24 x i8] c"over======PORT_MAX:%d=\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @prg_cache_load()
br label %4
4: ; preds = %2, %11
%5 = phi i32 [ 1, %2 ], [ %12, %11 ]
%6 = tail call i8* @prg_cache_get(i32 %5)
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %6)
br label %11
11: ; preds = %4, %9
%12 = add nuw nsw i32 %5, 1
%13 = icmp eq i32 %12, 65535
br i1 %13, label %14, label %4
14: ; preds = %11
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 65535)
%16 = tail call i32 (...) @prg_cache_clear()
ret i32 0
}