#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 ss7 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, unsigned char, ...);
int((tns_dump))(struct ss7 *ss7, int messagetype, unsigned char *parm,
                int len) {
  ss7_message(ss7, "\t\t\tType of Network: %x\n", (parm[0] >> 4) & 0x7);
  ss7_message(ss7, "\t\t\tNetwork ID plan: %x\n", parm[0] & 0xf);
  ss7_message(ss7, "\t\t\tNetwork ID: %x %x\n", parm[1], parm[2]);
  ss7_message(ss7, "\t\t\tCircuit Code: %x\n", (parm[3] >> 4) & 0xf);
  return len;
}


x86 assembly (clang, -O0):
<tns_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
and    $0x7,%eax
lea    0xec2(%rip),%rsi
movzbl %al,%edx
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
lea    0xebb(%rip),%rsi
movzbl %al,%edx
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%al
mov    -0x18(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
lea    0xeaf(%rip),%rsi
movzbl %al,%edx
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x3(%rax),%eax
sar    $0x4,%eax
and    $0xf,%eax
lea    0xea2(%rip),%rsi
movzbl %al,%edx
mov    $0x0,%al
call   1030 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tns_dump>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rdi,%rbx
movzbl (%rdx),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xed3(%rip),%rsi
xor    %eax,%eax
call   1030 <ss7_message@plt>
movzbl 0x0(%rbp),%edx
and    $0xf,%edx
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <ss7_message@plt>
movzbl 0x1(%rbp),%edx
movzbl 0x2(%rbp),%ecx
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <ss7_message@plt>
mov    0x3(%rbp),%al
shr    $0x4,%al
movzbl %al,%edx
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <ss7_message@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [24 x i8] c"\09\09\09Type of Network: %x\0A\00"
@.str.1 = [24 x i8] c"\09\09\09Network ID plan: %x\0A\00"
@.str.2 = [22 x i8] c"\09\09\09Network ID: %x %x\0A\00"
@.str.3 = [21 x i8] c"\09\09\09Circuit Code: %x\0A\00"
define i32 @tns_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.ss7*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store %struct.ss7* %0, %struct.ss7** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load %struct.ss7*, %struct.ss7** %5
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = ashr i32 %13, 4
%15 = and i32 %14, 7
%16 = trunc i32 %15 to i8
%17 = call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 zeroext %16)
%18 = load %struct.ss7*, %struct.ss7** %5
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = and i32 %22, 15
%24 = trunc i32 %23 to i8
%25 = call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %24)
%26 = load %struct.ss7*, %struct.ss7** %5
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %29, i32 %33)
%35 = load %struct.ss7*, %struct.ss7** %5
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 3
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = ashr i32 %39, 4
%41 = and i32 %40, 15
%42 = trunc i32 %41 to i8
%43 = call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %42)
%44 = load i32, i32* %8
ret i32 %44
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [24 x i8] c"\09\09\09Type of Network: %x\0A\00"
@.str.1 = [24 x i8] c"\09\09\09Network ID plan: %x\0A\00"
@.str.2 = [22 x i8] c"\09\09\09Network ID: %x %x\0A\00"
@.str.3 = [21 x i8] c"\09\09\09Circuit Code: %x\0A\00"
define i32 @tns_dump(%struct.ss7* %0, i32 %1, i8* nocapture %2, i32 returned %3) {
%5 = load i8, i8* %2
%6 = lshr i8 %5, 4
%7 = and i8 %6, 7
%8 = tail call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 zeroext %7)
%9 = load i8, i8* %2
%10 = and i8 %9, 15
%11 = tail call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %10)
%12 = getelementptr inbounds i8, i8* %2, i64 1
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %2, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = tail call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %13, i32 %16)
%18 = getelementptr inbounds i8, i8* %2, i64 3
%19 = load i8, i8* %18
%20 = lshr i8 %19, 4
%21 = tail call i32 (%struct.ss7*, i8*, i8, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %20)
ret i32 %3
}