#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 uint8_t;
typedef int const uint32_t;

/* Variables and functions */
int htonl(int);
scalar_t__ memcmp(int const *, int const *, int);
size_t bootp_check_reply(const uint8_t *msg, const uint8_t *mac_addr,
                         uint32_t xid) {
  uint32_t magic = htonl(0x63825363);
  if (msg[0] != 2) {
    return 0;
  } else if (msg[1] != 1) {
    return 1;
  } else if (msg[2] != 6) {
    return 2;
  } else if (memcmp(&msg[4], &xid, sizeof(uint32_t)) != 0) {
    return 4;
  } else if (memcmp(&msg[28], mac_addr, 6) != 0) {
    return 28;
  } else if (memcmp(&msg[236], &magic, 4) != 0) {
    return 236;
  }
  return 236 + 4;
}


x86 assembly (clang, -O0):
<bootp_check_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    $0x63825363,%edi
call   1030 <htonl@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
je     115a <bootp_check_reply+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x4(%rax)
je     1175 <bootp_check_reply+0x55>
movq   $0x1,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
mov    -0x10(%rbp),%rax
cmpl   $0x6,0x8(%rax)
je     1190 <bootp_check_reply+0x70>
movq   $0x2,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
mov    -0x10(%rbp),%rdi
add    $0x10,%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11bd <bootp_check_reply+0x9d>
movq   $0x4,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
mov    -0x10(%rbp),%rdi
add    $0x70,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11ea <bootp_check_reply+0xca>
movq   $0x1c,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
mov    -0x10(%rbp),%rdi
add    $0x3b0,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     121a <bootp_check_reply+0xfa>
movq   $0xec,-0x8(%rbp)
jmp    123b <bootp_check_reply+0x11b>
jmp    121f <bootp_check_reply+0xff>
jmp    1224 <bootp_check_reply+0x104>
jmp    1229 <bootp_check_reply+0x109>
jmp    122e <bootp_check_reply+0x10e>
jmp    1233 <bootp_check_reply+0x113>
movq   $0xf0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bootp_check_reply>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,0x4(%rsp)
mov    $0x63825363,%edi
call   1030 <htonl@plt>
mov    %eax,(%rsp)
cmpl   $0x2,(%rbx)
jne    11bd <bootp_check_reply+0x9d>
mov    $0x1,%eax
cmpl   $0x1,0x4(%rbx)
jne    11bf <bootp_check_reply+0x9f>
mov    $0x2,%eax
cmpl   $0x6,0x8(%rbx)
jne    11bf <bootp_check_reply+0x9f>
lea    0x10(%rbx),%rdi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jne    11bf <bootp_check_reply+0x9f>
lea    0x70(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
mov    %rax,%rcx
mov    $0x1c,%eax
test   %rcx,%rcx
jne    11bf <bootp_check_reply+0x9f>
add    $0x3b0,%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <memcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    0xec(,%rcx,4),%rax
jmp    11bf <bootp_check_reply+0x9f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @bootp_check_reply(i32* %0, i32* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = call i32 @htonl(i32 1669485411)
store i32 %9, i32* %8
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %3
store i64 0, i64* %4
br label %52
15: ; preds = %3
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32, i32* %17
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %15
store i64 1, i64* %4
br label %52
21: ; preds = %15
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 6
br i1 %25, label %26, label %27
26: ; preds = %21
store i64 2, i64* %4
br label %52
27: ; preds = %21
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 4
%30 = call i64 @memcmp(i32* %29, i32* %7, i32 4)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i64 4, i64* %4
br label %52
33: ; preds = %27
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 28
%36 = load i32*, i32** %6
%37 = call i64 @memcmp(i32* %35, i32* %36, i32 6)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %33
store i64 28, i64* %4
br label %52
40: ; preds = %33
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 236
%43 = call i64 @memcmp(i32* %42, i32* %8, i32 4)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
store i64 236, i64* %4
br label %52
46: ; preds = %40
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
store i64 240, i64* %4
br label %52
52: ; preds = %51, %45, %39, %32, %26, %20, %14
%53 = load i64, i64* %4
ret i64 %53
}

LLVM IR (-O2):
define i64 @bootp_check_reply(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
store i32 %2, i32* %4
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @htonl(i32 1669485411)
store i32 %7, i32* %5
%8 = load i32, i32* %0
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %31
10: ; preds = %3
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = getelementptr inbounds i32, i32* %0, i64 2
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 6
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = getelementptr inbounds i32, i32* %0, i64 4
%20 = call i64 @memcmp(i32* %19, i32* %4, i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = getelementptr inbounds i32, i32* %0, i64 28
%24 = call i64 @memcmp(i32* %23, i32* %1, i32 6)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = getelementptr inbounds i32, i32* %0, i64 236
%28 = call i64 @memcmp(i32* %27, i32* %5, i32 4)
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i64 240, i64 236
br label %31
31: ; preds = %26, %22, %18, %14, %10, %3
%32 = phi i64 [ 0, %3 ], [ 1, %10 ], [ 2, %14 ], [ 4, %18 ], [ 28, %22 ], [ %30, %26 ]
ret i64 %32
}