#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 */
scalar_t__ ntohl(unsigned int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
void dump_int(char *output, int maxlen, void *value, int len) {
  if (len == (int)sizeof(unsigned int))
    snprintf(output, maxlen, "%lu",
             (unsigned long)ntohl((*((unsigned int *)(value)))));
  else
    snprintf(output, maxlen, "Invalid INT");
}


x86 assembly (clang, -O0):
<dump_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jne    1176 <dump_int+0x56>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <ntohl@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    %rax,%rcx
lea    0xe96(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    118b <dump_int+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xe80(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_int>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0x4,%ecx
jne    1150 <dump_int+0x30>
mov    (%rdx),%edi
call   1040 <ntohl@plt>
lea    0xec5(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <snprintf@plt>
lea    0xead(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [12 x i8] c"Invalid INT\00"
define void @dump_int(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %19
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = load i8*, i8** %7
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
%17 = call i64 @ntohl(i32 %16)
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %17)
br label %23
19: ; preds = %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %20, i32 %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %19, %11
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [12 x i8] c"Invalid INT\00"
define void @dump_int(i8* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = icmp eq i32 %3, 4
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = bitcast i8* %2 to i32*
%8 = load i32, i32* %7
%9 = tail call i64 @ntohl(i32 %8)
%10 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %13
11: ; preds = %4
%12 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
ret void
}