#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_addr;
};
struct sockaddr {
  int sa_family;
};
struct ntp_control {
  int dummy;
};

/* Variables and functions */
int AF_INET;
char *inet_ntoa(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
int check_source(int data_len, struct sockaddr *sa_source, unsigned int sa_len,
                 struct ntp_control *ntpc) {
  struct sockaddr_in *sa_in = (struct sockaddr_in *)sa_source;
  (void)sa_len;
  if (0) {
    printf("packet of length %d received\n", data_len);
    if (sa_source->sa_family == AF_INET) {
      printf("Source: INET Port %d host %s\n", ntohs(sa_in->sin_port),
             inet_ntoa(sa_in->sin_addr));
    } else {
      printf("Source: Address family %d\n", sa_source->sa_family);
    }
  }
  (void)ntpc;
  if ((123) != ntohs(sa_in->sin_port)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_source>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1030 <ntohs@plt>
mov    %eax,%ecx
mov    $0x7b,%eax
cmp    %ecx,%eax
je     1154 <check_source+0x44>
movl   $0x1,-0x4(%rbp)
jmp    115b <check_source+0x4b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_source>:
push   %rax
mov    (%rsi),%edi
call   1030 <ntohs@plt>
xor    %ecx,%ecx
cmp    $0x7b,%eax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.ntp_control = type { i32 }
%struct.sockaddr_in = type { i32, i32 }
@AF_INET = global i32 0
define i32 @check_source(i32 %0, %struct.sockaddr* %1, i32 %2, %struct.ntp_control* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr*
%8 = alloca i32
%9 = alloca %struct.ntp_control*
%10 = alloca %struct.sockaddr_in*
store i32 %0, i32* %6
store %struct.sockaddr* %1, %struct.sockaddr** %7
store i32 %2, i32* %8
store %struct.ntp_control* %3, %struct.ntp_control** %9
%11 = load %struct.sockaddr*, %struct.sockaddr** %7
%12 = bitcast %struct.sockaddr* %11 to %struct.sockaddr_in*
store %struct.sockaddr_in* %12, %struct.sockaddr_in** %10
%13 = load i32, i32* %8
%14 = load %struct.ntp_control*, %struct.ntp_control** %9
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @ntohs(i32 %17)
%19 = icmp ne i32 123, %18
br i1 %19, label %20, label %21
20: ; preds = %4
store i32 1, i32* %5
br label %22
21: ; preds = %4
store i32 0, i32* %5
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.ntp_control = type { i32 }
@AF_INET = global i32 0
define i32 @check_source(i32 %0, %struct.sockaddr* nocapture %1, i32 %2, %struct.ntp_control* nocapture readnone %3) {
%5 = getelementptr %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i32 @ntohs(i32 %6)
%8 = icmp ne i32 %7, 123
%9 = zext i1 %8 to i32
ret i32 %9
}