#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 */
typedef int uid_t;

/* Variables and functions */
int TcpCheckProccesses(unsigned long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, int *, char *, int *, char *, int *, int *,
           unsigned long *, unsigned long *, int *, unsigned long *,
           unsigned long *, int *, int *, unsigned long *, char *);
int /*<<< orphan*/ stderr;
int TcpCheckTcpLine(int nbLines, char *line, int localPort, uid_t *uid) {
  unsigned long rxq, txq, time_len, retr, inode;
  int num, local_port, rem_port, d, state, tuid, timer_run, timeout;
  char rem_addr[128], local_addr[128], more[512];
  if (nbLines == 0)
    return 0;
  num =
      sscanf(line,
             "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d "
             "%d %ld %512s\n",
             &d, local_addr, &local_port, rem_addr, &rem_port, &state, &txq,
             &rxq, &timer_run, &time_len, &retr, &tuid, &timeout, &inode, more);
  if (num < 11)
    fprintf(stderr, "warning, got bogus tcp line.\n");
  else if (local_port == localPort) {
    printf("-> %s\n", line);
    *uid = tuid;
    return TcpCheckProccesses(inode);
  }
  return 0;
}


x86 assembly (clang, -O0):
<TcpCheckTcpLine>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3d8,%rsp
mov    %edi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %edx,-0x3c(%rbp)
mov    %rcx,-0x48(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    1178 <TcpCheckTcpLine+0x38>
movl   $0x0,-0x2c(%rbp)
jmp    12a5 <TcpCheckTcpLine+0x165>
mov    -0x38(%rbp),%rdi
lea    -0x190(%rbp),%rcx
lea    -0x110(%rbp),%r9
lea    -0x390(%rbp),%rax
mov    %rax,-0x398(%rbp)
lea    0xe61(%rip),%rsi
lea    -0x80(%rbp),%rdx
lea    -0x78(%rbp),%r8
lea    -0x7c(%rbp),%rax
lea    -0x84(%rbp),%r10
mov    %r10,-0x3a8(%rbp)
lea    -0x58(%rbp),%r10
mov    %r10,-0x3a0(%rbp)
lea    -0x50(%rbp),%r13
lea    -0x8c(%rbp),%r12
lea    -0x60(%rbp),%r15
lea    -0x68(%rbp),%r14
lea    -0x88(%rbp),%rbx
lea    -0x90(%rbp),%r11
lea    -0x70(%rbp),%r10
mov    %rax,(%rsp)
mov    -0x3a8(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0x3a0(%rbp),%rax
mov    %rax,0x10(%rsp)
mov    -0x398(%rbp),%rax
mov    %r13,0x18(%rsp)
mov    %r12,0x20(%rsp)
mov    %r15,0x28(%rsp)
mov    %r14,0x30(%rsp)
mov    %rbx,0x38(%rsp)
mov    %r11,0x40(%rsp)
mov    %r10,0x48(%rsp)
mov    %rax,0x50(%rsp)
call   1050 <sscanf@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0xb,-0x74(%rbp)
jge    1260 <TcpCheckTcpLine+0x120>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1040 <fprintf@plt>
jmp    129e <TcpCheckTcpLine+0x15e>
mov    -0x78(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    1299 <TcpCheckTcpLine+0x159>
mov    -0x38(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x88(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rdi
call   1060 <TcpCheckProccesses@plt>
mov    %eax,-0x2c(%rbp)
jmp    12a5 <TcpCheckTcpLine+0x165>
jmp    129e <TcpCheckTcpLine+0x15e>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x3d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<TcpCheckTcpLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x358,%rsp
xor    %ebx,%ebx
test   %edi,%edi
je     122d <TcpCheckTcpLine+0xed>
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rcx,0x8(%rsp)
sub    $0x8,%rsp
lea    0x158(%rsp),%rax
lea    0x18(%rsp),%r12
lea    0x24(%rsp),%r13
lea    0x8(%rsp),%r10
lea    0x38(%rsp),%r11
lea    0x40(%rsp),%r14
lea    0xe6f(%rip),%rsi
lea    0x30(%rsp),%rdx
lea    0x58(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0xd8(%rsp),%r9
mov    %r15,%rdi
push   %rax
push   %r12
push   %r13
push   %r10
push   %r11
push   %r14
lea    0x58(%rsp),%rax
push   %rax
lea    0x88(%rsp),%rax
push   %rax
lea    0x88(%rsp),%rax
push   %rax
lea    0x74(%rsp),%rax
push   %rax
lea    0x84(%rsp),%rax
push   %rax
call   1050 <sscanf@plt>
add    $0x60,%rsp
cmp    $0xa,%eax
jg     1202 <TcpCheckTcpLine+0xc2>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
jmp    122d <TcpCheckTcpLine+0xed>
cmp    %ebp,0x4(%rsp)
jne    122d <TcpCheckTcpLine+0xed>
lea    0xe5e(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    (%rsp),%eax
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    0x10(%rsp),%rdi
call   1060 <TcpCheckProccesses@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x358,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [79 x i8] c"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"warning, got bogus tcp line.\0A\00"
@.str.2 = [7 x i8] c"-> %s\0A\00"
define i32 @TcpCheckTcpLine(i32 %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca [128 x i8]
%24 = alloca [128 x i8]
%25 = alloca [512 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %4
store i32 0, i32* %5
br label %53
29: ; preds = %4
%30 = load i8*, i8** %7
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %24, i64 0, i64 0
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %23, i64 0, i64 0
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %25, i64 0, i64 0
%34 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i32* %18, i8* %31, i32* %16, i8* %32, i32* %17, i32* %19, i64* %11, i64* %10, i32* %21, i64* %12, i64* %13, i32* %20, i32* %22, i64* %14, i8* %33)
store i32 %34, i32* %15
%35 = load i32, i32* %15
%36 = icmp slt i32 %35, 11
br i1 %36, label %37, label %40
37: ; preds = %29
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %52
40: ; preds = %29
%41 = load i32, i32* %16
%42 = load i32, i32* %8
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i8*, i8** %7
%46 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i32, i32* %20
%48 = load i32*, i32** %9
store i32 %47, i32* %48
%49 = load i64, i64* %14
%50 = call i32 @TcpCheckProccesses(i64 %49)
store i32 %50, i32* %5
br label %53
51: ; preds = %40
br label %52
52: ; preds = %51, %37
store i32 0, i32* %5
br label %53
53: ; preds = %52, %44, %28
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [79 x i8] c"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"warning, got bogus tcp line.\0A\00"
@.str.2 = [7 x i8] c"-> %s\0A\00"
define i32 @TcpCheckTcpLine(i32 %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [128 x i8]
%18 = alloca [128 x i8]
%19 = alloca [512 x i8]
%20 = bitcast i64* %5 to i8*
%21 = bitcast i64* %6 to i8*
%22 = bitcast i64* %7 to i8*
%23 = bitcast i64* %8 to i8*
%24 = bitcast i64* %9 to i8*
%25 = bitcast i32* %10 to i8*
%26 = bitcast i32* %11 to i8*
%27 = bitcast i32* %12 to i8*
%28 = bitcast i32* %13 to i8*
%29 = bitcast i32* %14 to i8*
%30 = bitcast i32* %15 to i8*
%31 = bitcast i32* %16 to i8*
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%35 = icmp eq i32 %0, 0
br i1 %35, label %50, label %36
36: ; preds = %4
%37 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i32* %12, i8* %33, i32* %10, i8* %32, i32* %11, i32* %13, i64* %6, i64* %5, i32* %15, i64* %7, i64* %8, i32* %14, i32* %16, i64* %9, i8* %34)
%38 = icmp slt i32 %37, 11
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %50
42: ; preds = %36
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, %2
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%47 = load i32, i32* %14
store i32 %47, i32* %3
%48 = load i64, i64* %9
%49 = call i32 @TcpCheckProccesses(i64 %48)
br label %50
50: ; preds = %39, %42, %4, %45
%51 = phi i32 [ %49, %45 ], [ 0, %4 ], [ 0, %42 ], [ 0, %39 ]
ret i32 %51
}