#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*/ isup_get_number(char *, unsigned char *, int, int);
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, ...);
int((called_party_num_dump))(struct ss7 *ss7, int messagetype,
                             unsigned char *parm, int len) {
  int oddeven = (parm[0] >> 7) & 0x1;
  char numbuf[64] = "";
  ss7_message(ss7, "\t\t\tNature of address: %x\n", parm[0] & 0x7f);
  ss7_message(ss7, "\t\t\tNI: %x\n", (parm[1] >> 7) & 0x1);
  ss7_message(ss7, "\t\t\tNumbering plan: %x\n", (parm[1] >> 4) & 0x7);
  isup_get_number(numbuf, &parm[2], len - 2, oddeven);
  ss7_message(ss7, "\t\t\tAddress signals: %s\n", numbuf);
  return len;
}


x86 assembly (clang, -O0):
<called_party_num_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
sar    $0x7,%eax
and    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
and    $0x7f,%edx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x7,%edx
and    $0x1,%edx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edx
sar    $0x4,%edx
and    $0x7,%edx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x2,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x2,%edx
mov    -0x20(%rbp),%ecx
call   1040 <isup_get_number@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1050 <ss7_message@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<called_party_num_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rdi,%r15
movzbl (%rdx),%edx
mov    %edx,%ebp
shr    $0x7,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
and    $0x7f,%edx
lea    0xea3(%rip),%rsi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x7,%edx
lea    0xea8(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
movzbl 0x1(%rbx),%edx
shr    $0x4,%edx
and    $0x7,%edx
lea    0xe98(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <ss7_message@plt>
add    $0x2,%rbx
lea    -0x2(%r14),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%ecx
call   1030 <isup_get_number@plt>
lea    0xe86(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <ss7_message@plt>
mov    %r14d,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [11 x i8] c"\09\09\09NI: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.3 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @called_party_num_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.ss7*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [64 x i8]
store %struct.ss7* %0, %struct.ss7** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %7
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 7
%16 = and i32 %15, 1
store i32 %16, i32* %9
%17 = bitcast [64 x i8]* %10 to i8*
%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, 127
%24 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load %struct.ss7*, %struct.ss7** %5
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = ashr i32 %29, 7
%31 = and i32 %30, 1
%32 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load %struct.ss7*, %struct.ss7** %5
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = ashr i32 %37, 4
%39 = and i32 %38, 7
%40 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i32, i32* %8
%45 = sub nsw i32 %44, 2
%46 = load i32, i32* %9
%47 = call i32 @isup_get_number(i8* %41, i8* %43, i32 %45, i32 %46)
%48 = load %struct.ss7*, %struct.ss7** %5
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%50 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %48, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = load i32, i32* %8
ret i32 %51
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [26 x i8] c"\09\09\09Nature of address: %x\0A\00"
@.str.1 = [11 x i8] c"\09\09\09NI: %x\0A\00"
@.str.2 = [23 x i8] c"\09\09\09Numbering plan: %x\0A\00"
@.str.3 = [24 x i8] c"\09\09\09Address signals: %s\0A\00"
define i32 @called_party_num_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 returned %3) {
%5 = alloca [64 x i8]
%6 = load i8, i8* %2
%7 = lshr i8 %6, 7
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = and i8 %6, 127
%11 = zext i8 %10 to i32
%12 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %2, i64 1
%14 = load i8, i8* %13
%15 = lshr i8 %14, 7
%16 = zext i8 %15 to i32
%17 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i8, i8* %13
%19 = lshr i8 %18, 4
%20 = and i8 %19, 7
%21 = zext i8 %20 to i32
%22 = tail call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i8, i8* %2, i64 2
%24 = add nsw i32 %3, -2
%25 = call i32 @isup_get_number(i8* %9, i8* %23, i32 %24, i32 %8)
%26 = call i32 (%struct.ss7*, i8*, ...) @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %9)
ret i32 %3
}