#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 /*<<< orphan*/ u_int64_t;
typedef int /*<<< orphan*/ rem_host;
typedef int /*<<< orphan*/ int_client;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int get_pinhole(unsigned short, char *, int, unsigned short *, char *, int,
                unsigned short *, int *, unsigned int *, int /*<<< orphan*/ *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *, ...);
int /*<<< orphan*/ stderr;
int print_pinhole(int uid) {
  int r;
  char rem_host[64];
  unsigned short rem_port;
  char int_client[64];
  unsigned short int_port;
  int proto;
  unsigned int timestamp;
  u_int64_t packets, bytes;
  r = get_pinhole((unsigned short)uid, rem_host, sizeof(rem_host), &rem_port,
                  int_client, sizeof(int_client), &int_port, &proto, &timestamp,
                  &packets, &bytes);
  if (r < 0) {
    fprintf(stderr, "get_pinhole(%d) returned %d\n", uid, r);
  } else {
    printf("pinhole %d : [%s]:%hu => [%s]:%hu proto=%d ts=%u\n", uid, rem_host,
           rem_port, int_client, int_port, proto, timestamp);
    printf("    packets=%llu bytes=%llu\n", packets, bytes);
  }
  return r;
}


x86 assembly (clang, -O0):
<print_pinhole>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %edi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %ax,%dx
lea    -0x60(%rbp),%rsi
lea    -0xb0(%rbp),%r8
mov    $0x40,%r9d
lea    -0x62(%rbp),%rcx
lea    -0xb2(%rbp),%r14
lea    -0xb8(%rbp),%rbx
lea    -0xbc(%rbp),%r11
lea    -0xc0(%rbp),%r10
lea    -0xc4(%rbp),%rax
movzwl %dx,%edi
mov    %r9d,%edx
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1040 <get_pinhole@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11cf <print_pinhole+0x9f>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe3b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1227 <print_pinhole+0xf7>
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rdx
movzwl -0x62(%rbp),%ecx
lea    -0xb0(%rbp),%r8
movzwl -0xb2(%rbp),%r9d
ff
mov    -0xb8(%rbp),%r10d
mov    -0xbc(%rbp),%eax
lea    0xe20(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc0(%rbp),%esi
movslq -0xc4(%rbp),%rdx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pinhole>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %edi,%ebx
sub    $0x8,%rsp
lea    0x18(%rsp),%rax
lea    0x1c(%rsp),%rbp
lea    0x20(%rsp),%r10
lea    0x24(%rsp),%r11
lea    0x14(%rsp),%r14
movzwl %bx,%edi
lea    0x68(%rsp),%rsi
lea    0x16(%rsp),%rcx
lea    0x28(%rsp),%r8
mov    $0x40,%edx
mov    $0x40,%r9d
push   %rax
push   %rbp
push   %r10
push   %r11
push   %r14
call   1040 <get_pinhole@plt>
add    $0x30,%rsp
mov    %eax,%ebp
test   %eax,%eax
js     11de <print_pinhole+0xae>
movzwl 0xe(%rsp),%ecx
movzwl 0xc(%rsp),%r9d
mov    0x1c(%rsp),%r10d
mov    0x18(%rsp),%r11d
lea    0xe73(%rip),%rdi
lea    0x60(%rsp),%rdx
lea    0x20(%rsp),%r8
mov    %ebx,%esi
xor    %eax,%eax
push   %r11
push   %r10
call   1030 <printf@plt>
add    $0x10,%rsp
mov    0x14(%rsp),%esi
movslq 0x10(%rsp),%rdx
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11f7 <print_pinhole+0xc7>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1050 <fprintf@plt>
mov    %ebp,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"get_pinhole(%d) returned %d\0A\00"
@.str.1 = [50 x i8] c"pinhole %d : [%s]:%hu => [%s]:%hu proto=%d ts=%u\0A\00"
@.str.2 = [29 x i8] c" packets=%llu bytes=%llu\0A\00"
define i32 @print_pinhole(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = alloca i16
%6 = alloca [64 x i8]
%7 = alloca i16
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %2
%12 = load i32, i32* %2
%13 = trunc i32 %12 to i16
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%16 = call i32 @get_pinhole(i16 zeroext %13, i8* %14, i32 64, i16* %5, i8* %15, i32 64, i16* %7, i32* %8, i32* %9, i32* %10, i32* %11)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %1
%20 = load i32, i32* @stderr
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22)
br label %40
24: ; preds = %1
%25 = load i32, i32* %2
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%27 = load i16, i16* %5
%28 = zext i16 %27 to i32
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%30 = load i16, i16* %7
%31 = zext i16 %30 to i32
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = call i32 (i8*, i32, i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26, i32 %28, i8* %29, i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %10
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i8*
%39 = call i32 (i8*, i32, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %35, i8* %38)
br label %40
40: ; preds = %24, %19
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"get_pinhole(%d) returned %d\0A\00"
@.str.1 = [50 x i8] c"pinhole %d : [%s]:%hu => [%s]:%hu proto=%d ts=%u\0A\00"
@.str.2 = [29 x i8] c" packets=%llu bytes=%llu\0A\00"
define i32 @print_pinhole(i32 %0) {
%2 = alloca [64 x i8]
%3 = alloca i16
%4 = alloca [64 x i8]
%5 = alloca i16
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = bitcast i16* %3 to i8*
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%13 = bitcast i16* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = trunc i32 %0 to i16
%19 = call i32 @get_pinhole(i16 zeroext %18, i8* %10, i32 64, i16* %3, i8* %12, i32 64, i16* %5, i32* %6, i32* %7, i32* %8, i32* %9)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %19)
br label %37
24: ; preds = %1
%25 = load i16, i16* %3
%26 = zext i16 %25 to i32
%27 = load i16, i16* %5
%28 = zext i16 %27 to i32
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = call i32 (i8*, i32, i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %10, i32 %26, i8* %12, i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i8*
%36 = call i32 (i8*, i32, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %32, i8* %35)
br label %37
37: ; preds = %24, %21
ret i32 %19
}